【发布时间】:2021-04-03 09:21:56
【问题描述】:
我有此代码,但我无法使用命令运行它,因此我可以打开和关闭它:
auto_dm = "off"
@bot.command()
async def autoreply(ctx, mode: str):
""" On or Off """
await ctx.message.delete()
auto_dm = mode
class Events(commands.Cog):
@commands.Cog.listener()
async def on_message(self, message):
while auto_dm == "on":
if isinstance(message.channel, discord.channel.DMChannel):
if message.author.id != bot.user.id:
automsg = config.get("automessage")
await message.channel.send(automsg)
time = datetime.datetime.now().strftime("%H:%M")
print(f"{time} | {Fore.LIGHTCYAN_EX}[Event]{Fore.RESET} | Auto Reply Message send to {message.author}")
else:
pass
else:
pass
else:
pass
我的问题是,当我将事件设置为“开启”时,它没有在监听。
【问题讨论】:
标签: python discord discord.py