Add delete message app command
This commit is contained in:
parent
111a5c7c7f
commit
d2e334bb98
1 changed files with 15 additions and 0 deletions
15
src/main.py
15
src/main.py
|
@ -118,6 +118,21 @@ async def on_application_command_completion(ctx: discord.ApplicationContext):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@bot.message_command(name="Delete Message")
|
||||||
|
async def delete_message(ctx: discord.ApplicationContext):
|
||||||
|
await ctx.defer()
|
||||||
|
if not ctx.channel.permissions_for(ctx.me).manage_messages:
|
||||||
|
if ctx.message.author != bot.user:
|
||||||
|
return await ctx.respond("I don't have permission to delete messages in this channel.", delete_after=30)
|
||||||
|
|
||||||
|
log.info(
|
||||||
|
"%s deleted message %s>%s: %r", ctx.author, ctx.channel.name, ctx.message.id, ctx.message.content
|
||||||
|
)
|
||||||
|
await ctx.message.delete(delay=3)
|
||||||
|
await ctx.respond(f"\N{white heavy check mark} Deleted message by {ctx.message.author.display_name}.")
|
||||||
|
await ctx.delete(delay=15)
|
||||||
|
|
||||||
|
|
||||||
if not CONFIG["jimmy"].get("token"):
|
if not CONFIG["jimmy"].get("token"):
|
||||||
log.critical("No token specified in config.toml. Exiting. (hint: set jimmy.token in config.toml)")
|
log.critical("No token specified in config.toml. Exiting. (hint: set jimmy.token in config.toml)")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
Loading…
Reference in a new issue