Skip to content

Commit

Permalink
remove the username format functions
Browse files Browse the repository at this point in the history
  • Loading branch information
bemxio committed Nov 30, 2024
1 parent cc5339e commit b545c7c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
16 changes: 5 additions & 11 deletions cogs/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ def word_split(self, text: str) -> List[str]:

return filtered

def format_username(self, user: User) -> str:
if user.discriminator == "0":
return f"@{user.name}"

return f"{user.name}#{user.discriminator}"

# actual commands
@commands.command()
async def count(self, ctx: commands.Context, *, keyword: str):
Expand Down Expand Up @@ -106,7 +100,7 @@ async def count(self, ctx: commands.Context, *, keyword: str):
colour=Colour.blurple(),
timestamp=ctx.message.created_at
)
embed.set_footer(text=f"Invoked by {self.format_username(ctx.author)}", icon_url=ctx.author.display_avatar.url)
embed.set_footer(text=f"Invoked by @{ctx.author.name}", icon_url=ctx.author.display_avatar.url)

author_encountered = False
index = 1
Expand All @@ -120,7 +114,7 @@ async def count(self, ctx: commands.Context, *, keyword: str):
if any(word in user.name.lower() for word in self.censored):
continue

field_name = f"#{index} - {self.format_username(user)}"
field_name = f"#{index} - @{user.name}"

if user.id == ctx.author.id:
field_name += " (You)"
Expand All @@ -143,7 +137,7 @@ async def count(self, ctx: commands.Context, *, keyword: str):
count = occurences[str(ctx.author.id)]

embed.add_field(
name=f"#{position} - {self.format_username(ctx.author)} (You)",
name=f"#{position} - @{ctx.author.name} (You)",
value=f"**{count}** uses",
)

Expand Down Expand Up @@ -191,7 +185,7 @@ async def top(self, ctx: commands.Context, target: Optional[User] = None):
timestamp=ctx.message.created_at
)

embed.set_footer(text=f"Invoked by {self.format_username(ctx.author)}", icon_url=ctx.author.display_avatar.url)
embed.set_footer(text=f"Invoked by @{ctx.author.name}", icon_url=ctx.author.display_avatar.url)
embed.set_thumbnail(url=target.display_avatar.url)

index = 1
Expand Down Expand Up @@ -251,7 +245,7 @@ async def bottom(self, ctx: commands.Context, target: Optional[User] = None):
timestamp=ctx.message.created_at
)

embed.set_footer(text=f"Invoked by {self.format_username(ctx.author)}", icon_url=ctx.author.display_avatar.url)
embed.set_footer(text=f"Invoked by @{ctx.author.name}", icon_url=ctx.author.display_avatar.url)
embed.set_thumbnail(url=target.display_avatar.url)

index = 1
Expand Down
14 changes: 4 additions & 10 deletions modules/help.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
from discord.ext import commands
from discord import Embed, Colour, User

def format_username(user: User) -> str:
if user.discriminator == "0":
return f"@{user.name}"

return f"{user.name}#{user.discriminator}"

class PretenderHelpCommand(commands.MinimalHelpCommand):
async def send_bot_help(self, mapping: dict):
ctx = self.context
Expand All @@ -25,7 +19,7 @@ async def send_bot_help(self, mapping: dict):

embed.description += f"__**{cog.qualified_name if cog is not None else 'Uncategorized'}**__\n{signatures}\n"

embed.set_footer(text=f"Invoked by @{format_username(ctx.author)}", icon_url=ctx.author.display_avatar.url)
embed.set_footer(text=f"Invoked by @{ctx.author.name}", icon_url=ctx.author.display_avatar.url)
embed.timestamp = ctx.message.created_at

await ctx.message.reply(embed=embed, mention_author=False)
Expand All @@ -45,7 +39,7 @@ async def send_cog_help(self, cog: commands.Cog):
for command in cog.get_commands():
embed.description += f"`{self.get_command_signature(command)}`\n"

embed.set_footer(text=f"Invoked by {format_username(ctx.author)}", icon_url=ctx.author.display_avatar.url)
embed.set_footer(text=f"Invoked by @{ctx.author.name}", icon_url=ctx.author.display_avatar.url)
embed.timestamp = ctx.message.created_at

await ctx.message.reply(embed=embed, mention_author=False)
Expand All @@ -59,7 +53,7 @@ async def send_command_help(self, command: commands.Command):
colour=Colour.blurple()
)

embed.set_footer(text=f"Invoked by {format_username(ctx.author)}", icon_url=ctx.author.display_avatar.url)
embed.set_footer(text=f"Invoked by @{ctx.author.name}", icon_url=ctx.author.display_avatar.url)
embed.timestamp = ctx.message.created_at

await ctx.message.reply(embed=embed, mention_author=False)
Expand All @@ -72,7 +66,7 @@ async def command_not_found(self, string: str) -> Embed:
colour=Colour.red()
)

embed.set_footer(text=f"Invoked by {format_username(ctx.author)}", icon_url=ctx.author.display_avatar.url)
embed.set_footer(text=f"Invoked by @{ctx.author.name}", icon_url=ctx.author.display_avatar.url)
embed.timestamp = ctx.message.created_at

return embed
Expand Down

0 comments on commit b545c7c

Please sign in to comment.