Added AFK and Slowmode commands#5
Conversation
AFK is completly ping-proof
BobDotCom
left a comment
There was a problem hiding this comment.
Many changes needed. Recommended to remove all except afk commands, and fix afk commands.
|
|
||
| @bot.event | ||
| async def on_message(message): | ||
| if bot.afk_users.get(message.author.id): |
There was a problem hiding this comment.
Ah, do you use spaces for indentation?
There was a problem hiding this comment.
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.
| async def on_message(message): | ||
| if bot.afk_users.get(message.author.id): | ||
| del bot.afk_users[message.author.id] | ||
| return await message.channel.send(f'Welcome back {message.author.name}, you are no longer AFK') |
There was a problem hiding this comment.
This should include a delete_after
| await ctx.respond(f"Here's a link", view=view) | ||
|
|
||
|
|
||
|
|
| del bot.afk_users[message.author.id] | ||
| return await message.channel.send(f'Welcome back {message.author.name}, you are no longer AFK') | ||
|
|
||
| for mention in message.mentions: |
There was a problem hiding this comment.
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.
|
|
||
| for mention in message.mentions: | ||
| 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()) |
| 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"]: |
| 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) | ||
|
|
||
| @afk.command(name='remove') |
There was a problem hiding this comment.
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.
| @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') |
There was a problem hiding this comment.
send() is incorrect here
| if bot.afk_users.get(ctx.author.id): | ||
| return await ctx.send(f'{ctx.author.name}, you\'re already AFK') | ||
| 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') |
There was a problem hiding this comment.
send() is incorrect 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') | ||
| 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) |
There was a problem hiding this comment.
send() is incorrect here
There was a problem hiding this comment.
allowed_mentions is redundant.
|
Please add a changelog entry |
AFK is completly ping-proof