在 discord.py 如何让我的机器人只能在特定频道或特定服务器中使用命令?
in discord.py How can i make my bot that the commands only can be use in specific channel or specific server?
所以,任何人都可以邀请我的个人机器人到他们的服务器。所以,我希望该命令可以在@bot.event而不是客户端的特定通道或特定服务器上运行。
如果你使用 await bot.process_commands(message)
你可以试试这个
@bot.event
async def on_message(message):
if message.channel.id == yourchannelid:
await bot.process_commands(message)
if message.guild.id = yourguildid:
await bot.process_commands(message)
您可以在 on_message 中添加检查,这样机器人就不会回复自己
所以,任何人都可以邀请我的个人机器人到他们的服务器。所以,我希望该命令可以在@bot.event而不是客户端的特定通道或特定服务器上运行。
如果你使用 await bot.process_commands(message)
你可以试试这个
@bot.event
async def on_message(message):
if message.channel.id == yourchannelid:
await bot.process_commands(message)
if message.guild.id = yourguildid:
await bot.process_commands(message)
您可以在 on_message 中添加检查,这样机器人就不会回复自己