【发布时间】:2020-08-25 08:25:04
【问题描述】:
我正在 python3 中开发一个不和谐机器人(discord.py 1.3.3,不和谐 1.0.1),我需要删除用户消息,但我不知道如何正确调用协程。
我查看了someotherthreads,并尝试查看documentation(和discord.py docs),但我无法弄清楚。
这是我正在测试的内容:
import discord
from discord.ext import commands
TOKEN = os.getenv('DISCORD_TOKEN')
bot = commands.Bot(command_prefix='!')
@bot.command(name='deleteme', help='testing command for dev use')
async def deleteme(ctx):
msg = ctx.message.id
print(f'DEBUG: message id is {msg}')
await msg.delete
# await ctx.delete(msg, delay=None) #nope
# await ctx.delete_message(ctx.message) #nope
# await bot.delete_message(ctx.message) #nope
# await command.delete_message(ctx.message) #nope
# await discord.Client.delete_message(msg) #nope
运行此命令会返回带有 ID 号的控制台调试消息,但不会删除该消息。如果我在await msg.delete 之后添加调试打印行,它不会返回。所以这告诉我脚本挂在哪里。也就是说,我仍然无法弄清楚正确的命令应该是什么。
机器人服务器权限包括“管理消息”
【问题讨论】:
标签: python python-3.x discord discord.py discord.py-rewrite