Skip to content
This repository was archived by the owner on Aug 28, 2025. It is now read-only.
Open
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
62 changes: 62 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ async def pr(ctx, number: Option(int, "Pull request number")):
await ctx.respond(f"Here's a link", view=view)



Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why

@bot.slash_command()
async def source(ctx, command: Option(str, "The command to view the source code for", required=False)):
"""View the source for a particular command or the whole bot."""
Expand Down Expand Up @@ -282,6 +283,67 @@ async def on_message_edit(before, after):
ctx = await bot.get_context(after)
await bot.invoke(ctx)

@bot.event
async def on_message(message):
if bot.afk_users.get(message.author.id):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation errors here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, do you use spaces for indentation?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, as per https://www.python.org/dev/peps/pep-0008/#code-lay-out.
Regardless, there are inconsistencies whether or not spaces or tabs are used.

del bot.afk_users[message.author.id]
return await message.channel.send(f'Welcome back {message.author.name}, you are no longer AFK')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should include a delete_after


for mention in message.mentions:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's more we can do with this. It would be nice to have it say "person1 and person2 are afk" instead of just sending one person's message.

if bot.afk_users.get(mention.id):
return await message.channel.send(f'{mention.name} is AFK: {bot.afk_users[mention.id]}', allowed_mentions = discord.AllowedMentions.none())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more indentation errors


await bot.process_commands(message)

bot.afk_users = {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be set in the bot cache that I implemented.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or better yet, in a database that I plan on implementing soon.



slowmode = bot.command_group(name='slowmode', description="Slowmode related commands for moderators", guild_ids=guild_ids)

@slowmode.command(name='set', description='Set the slowmode of the current channel')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was rejected in a separate pull request.

@commands.has_role(881407111211384902)
async def set(ctx, time:Option(int, 'Enter the time in seconds')):
if ctx.author.guild_permissions.manage_messages:

if time > 21600:
await ctx.respond(content=f"Slowmode of a channel must be {humanize.precisedelta(21600)} (21600 seconds) or less.", ephemeral=True)
else:
await ctx.channel.edit(slowmode_delay=time)
await ctx.respond(f"The slowmode of this channel has been changed to {humanize.precisedelta(time)} ({time}s)")
else:
await ctx.respond("You do not have the `Manage Message` permission which is required to run this command.", ephemeral=True)

@slowmode.command(name='off', description='Remove the slowmode from the current channel')
@commands.has_role(881407111211384902)
async def off(ctx):
if ctx.author.guild_permissions.manage_messages:
if ctx.channel.slowmode_delay == 0:
await ctx.respond(content="This channel doesn't have a slowmode. Use `/slowmode set` to set a slowmode.", ephemeral=True)
await ctx.channel.edit(slowmode_delay=0)
await ctx.respond("Removed the slowmode from this channel!")
else:
await ctx.respond("You do not have the `Manage Message` permission which is required to run this command.", ephemeral=True)

for i in ["jishaku", "cogs.rtfm", "cogs.modmail", "cogs.tags"]:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be here

bot.load_extension(i)

afk = bot.command_group(name='afk', description='AFK Commands', guild_ids=guild_ids)

@afk.command(name='set')
async def afk_set(ctx, *, reason = 'No reason provided'):
if bot.afk_users.get(ctx.author.id):
return await ctx.send(f'{ctx.author.name}, you\'re already AFK')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

send() is incorrect here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use double quotes here

if len(reason) > 100: # so that chat doesn't flood when the reason has to be shown
return await ctx.send(f'{ctx.author.name}, keep your AFK reason under 100 characters')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

send() is incorrect here

bot.afk_users[ctx.author.id] = reason
await ctx.send(f'{ctx.author.name}, I set your AFK with the reason: {reason}', allowed_mentions=discord.AllowedMentions.none(), ephemeral=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

send() is incorrect here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allowed_mentions is redundant.


@afk.command(name='remove')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for a remove command, someone can just send a message to remove it. The set command can be moved out of the command group.

async def afk_remove(ctx):
if bot.afk_users.get(ctx.author.id):
del bot.afk_users[ctx.author.id]
return await ctx.send(f'Welcome back {ctx.author.name}, you are no longer AFK')


if __name__ == "__main__":
bot.run()
Expand Down