Skip to content

Worked on modmail and formatted code #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
TOKEN =
MODMAIL_WEBHOOK_URL =
29 changes: 19 additions & 10 deletions cogs/developer.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ async def _reloadall(self, ctx: commands.Context[CodingBot]):

"""
cogs: Dict[str, List[str]] = {"reloaded": [], "not": []}
processing: Mapping[str, ModuleType] = self.bot.extensions.copy()
processing: Mapping[str, ModuleType] = self.bot.extensions.copy()
for cog in processing:
try:
await self.bot.reload_extension(cog)
Expand Down Expand Up @@ -253,11 +253,14 @@ async def _getusermetric(
)
record = message_metric[0] if message_metric else None
if record:
deleted_message_percent = (record.deleted_message_count /
record.message_count * 100)
actual_message_percent = ((record.message_count -
record.deleted_message_count) /
record.message_count * 100)
deleted_message_percent = (
record.deleted_message_count / record.message_count * 100
)
actual_message_percent = (
(record.message_count - record.deleted_message_count)
/ record.message_count
* 100
)
offline_message_percent = record.offline / record.message_count * 100
online_message_percent = record.online / record.message_count * 100
dnd_message_percent = record.dnd / record.message_count * 100
Expand All @@ -279,10 +282,16 @@ async def _getusermetric(
{record.idle} (`{idle_message_percent}%`)
"""

revoked_thanks_percent = (revoked_thank_count/total_thank_count*100
if total_thank_count > 0 else 0)
actual_thanks_percent = (surviving_thank_count/total_thank_count*100
if total_thank_count > 0 else 0)
revoked_thanks_percent = (
revoked_thank_count / total_thank_count * 100
if total_thank_count > 0
else 0
)
actual_thanks_percent = (
surviving_thank_count / total_thank_count * 100
if total_thank_count > 0
else 0
)
embed = discord.Embed(
title=f"{member.name}#{member.discriminator} Detailed anaylysis",
description=f"Total thanks this month: {total_thank_count}\n"
Expand Down
20 changes: 7 additions & 13 deletions cogs/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,7 @@ async def _beerparty(
self, ctx: commands.Context, *, reason: commands.clean_content = None
):
reason = ("\nReason: " + reason) if reason else ""
msg = await ctx.send(
f"Open invite to beerparty! React with 🍻 to join!{reason}"
)
msg = await ctx.send(f"Open invite to beerparty! React with 🍻 to join!{reason}")
await msg.add_reaction("\U0001f37b")
await asyncio.sleep(60)
msg = await ctx.channel.fetch_message(msg.id)
Expand All @@ -268,17 +266,14 @@ async def _beerparty(
await ctx.send(
", ".join(user.display_name for user in users) + " joined the beerparty!"
)

@commands.command(
name = 'nuke',
help = 'find out yourself'
)

@commands.command(name="nuke", help="find out yourself")
@commands.cooldown(2, 10, commands.BucketType.guild)
async def _nuke(self, ctx: commands.Context):
msg = await ctx.reply("Nuking the server in 5 seconds!")
await asyncio.sleep(5)
await msg.edit(content="Nuke engaged :smiling_imp:")
await asyncio.sleep(random.randint(1,3))
await asyncio.sleep(random.randint(1, 3))
reason = random.choice(
[
"Swas pooped in his pants",
Expand All @@ -296,15 +291,14 @@ async def _nuke(self, ctx: commands.Context):
"you really thought it would work",
"my dog ate my nuke",
"my boyfriend decided to call FBI",
"I am too lazy", # someone please add more funny phrases
"I am too lazy", # someone please add more funny phrases
]
)
embed = self.bot.embed(
title="Nuke Failed!",
description=f"Reason: {reason}",
color = 0xff0000
title="Nuke Failed!", description=f"Reason: {reason}", color=0xFF0000
)
await msg.edit(content=None, embed=embed)


async def setup(bot: CodingBot):
await bot.add_cog(Fun(bot))
18 changes: 7 additions & 11 deletions cogs/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,8 @@ async def avatar_display(
text=f"Requested by {ctx.author}", icon_url=ctx.author.display_avatar.url
)
await self.bot.reply(ctx, embed=embed)


@commands.command(name='update-staff-list')
@commands.command(name="update-staff-list")
@commands.has_permissions(administrator=True)
async def update_staff_list(self, ctx):
staff_list_channel = self.bot.get_channel(765066298299383809)
Expand All @@ -183,28 +182,25 @@ async def update_staff_list(self, ctx):
681895900070543411,
729537643951554583,
]
embed = discord.Embed(title='**Staff List**', color=0x2F3136)
embed.description = ''
embed = discord.Embed(title="**Staff List**", color=0x2F3136)
embed.description = ""
for r in mod_roles:
r = ctx.guild.get_role(r)
valid_members = []
for m in r.members:
admin = m.top_role.name == 'Admin Perms' and r.name == 'Admin'
admin = m.top_role.name == "Admin Perms" and r.name == "Admin"
if m.top_role == r or admin:
valid_members.append(m)

embed.description += f"{r.mention} | **{len(valid_members)}** \n"

for m in valid_members:
embed.description += f"> `{m.id}` {m.mention}\n"
embed.description += '\n'
embed.description += "\n"
await staff_list_channel.purge(limit=1)
await staff_list_channel.send(embed=embed)
embed = self.bot.embed(
description = "Done ✅",
color=0x00ff00
)
await self.bot.send(ctx, embed = embed)
embed = self.bot.embed(description="Done ✅", color=0x00FF00)
await self.bot.send(ctx, embed=embed)


async def setup(bot: CodingBot) -> None:
Expand Down
4 changes: 1 addition & 3 deletions cogs/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,7 @@ async def log(
if undo and isinstance(undo_action, ValueError):
raise undo_action

action_string = (
action_info["undo_action"] if undo else action_info["action"]
)
action_string = action_info["undo_action"] if undo else action_info["action"]
icon = action_info["undo_icon"] if undo else action_info["icon"]
color = discord.Color.green() if undo else action_info.get("color")

Expand Down
26 changes: 12 additions & 14 deletions cogs/listeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def valid_gh_sect(name: str):
@commands.Cog.listener("on_message")
async def thank_message(self, message: discord.Message):
"""
Responsible for checking if a user is saying thanks in a help channel.
Responsible for checking if a user is saying thanks in a help channel.
if so, the bot will inform the user that they can use the thank command
to support the user that helped them.

Expand All @@ -53,13 +53,13 @@ async def thank_message(self, message: discord.Message):
"""
if message.author.bot or not message.guild:
return

if message.channel.category.id == 754710748353265745 and (
"thanks" in message.content.lower()
or "thank you" in message.content.lower()
or "thx" in message.content.lower()
or "thnx" in message.content.lower()
):
"thanks" in message.content.lower()
or "thank you" in message.content.lower()
or "thx" in message.content.lower()
or "thnx" in message.content.lower()
):
await message.reply(
"If someone has helped you, "
"you can thank them by using the `.thank` command."
Expand All @@ -85,9 +85,7 @@ async def afk_user_messaage(self, message: discord.Message):
record = record.get(message.author.id)
if record:
_, time = record
if (
unitime.time() - time
) < 30:
if (unitime.time() - time) < 30:
return
await self.bot.conn.delete_record(
"afk",
Expand All @@ -100,7 +98,7 @@ async def afk_user_messaage(self, message: discord.Message):
name = message.author.display_name.split(" ")[1:]
await message.author.edit(nick=" ".join(name))
staff_role = message.guild.get_role(795145820210462771)
if staff_role and staff_role in message.author.roles:
if staff_role and staff_role in message.author.roles:
on_pat_staff = message.guild.get_role(726441123966484600)
with contextlib.suppress(discord.Forbidden, discord.HTTPException):
await message.author.add_roles(on_pat_staff)
Expand All @@ -118,7 +116,7 @@ async def afk_user_messaage(self, message: discord.Message):
async def user_mentioned(self, message: discord.Message):
"""
Responsible for checking if an AFK user was mentioned in a message.
If so, the bot will send a message to the channel informing that the user
If so, the bot will send a message to the channel informing that the user
that was mentioned is AFK.

Parameters
Expand Down Expand Up @@ -185,7 +183,7 @@ async def on_command_error(self, ctx: commands.Context, error: Exception) -> Non
embed = discord.Embed(
title="Command on Cooldown",
description=f"{ctx.author.mention} Please wait {error.retry_after:.2f}"
" seconds before using this command again.",
" seconds before using this command again.",
color=discord.Color.red(),
)
return await ctx.send(embed=embed, ephemeral=True)
Expand Down Expand Up @@ -285,7 +283,7 @@ async def invite_in_message(self, message: discord.Message):
)
if re.search(
invite_regex, message.content
): # `check_invite` already checks if there is an invite,
): # `check_invite` already checks if there is an invite,
# why are we checking again?
await message.delete()
return await message.channel.send(
Expand Down
9 changes: 4 additions & 5 deletions cogs/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async def cog_check(self, ctx: commands.Context[CodingBot]) -> bool:
)
async def retry(self, ctx: commands.Context[CodingBot]):
"""
Reinvoke a command, running it again.
Reinvoke a command, running it again.
This does NOT bypass any permissions checks | Code from v4
"""
try:
Expand Down Expand Up @@ -261,8 +261,7 @@ async def thank_show(

embed.add_field(
name=f"Thank: {thank_id}",
value=
f"Thank giver: {giver.mention}\nDate: <t:{timestamp}:R>\n"
value=f"Thank giver: {giver.mention}\nDate: <t:{timestamp}:R>\n"
f"Reason: {reason}\nThank given in: "
f"{channel.mention if channel else f'<#{channel_id}>'}\n"
f"Message link: [Click here!]({msg_link})",
Expand Down Expand Up @@ -363,7 +362,7 @@ async def thank_leaderboard(self, ctx: commands.Context[CodingBot]):
embeds,
ctx,
check=lambda i: i.user.id == ctx.author.id,
)
)
paginator.add_button(
"delete", label="Delete", style=discord.ButtonStyle.danger
)
Expand Down Expand Up @@ -420,7 +419,7 @@ async def spotify(self, ctx: commands.Context, member: discord.Member = None):
`{prefix}spotify [member]`: *will show the spotify status of [member]*
"""
member = ctx.guild.get_member((member or ctx.author).id)

spotify = Spotify(bot=self.bot, member=member)
result = await spotify.get_embed()
if not result:
Expand Down
Loading