如何触发事件以供 ctx.guild 使用
How do I trigger an event to work for ctx.guild
例如,假设我有一个客户端事件,我只想在所述服务器允许它使用命令时触发。
喜欢
@bot.command()
async def allow(ctx):
#code that makes my specified event work for the server, keep in mind there are multiple servers
比如我需要 JSON 来记录 ctx.guild.id 吗?或者?
请以 cog 和正常形式提及代码..
您必须将其存储在 JSON 文件中,是的。并且让它像:当执行命令 allow
时,将公会 ID 存储在 JSON 文件中。执行上述允许的命令时,检查公会 ID 是否在 JSON 文件中。如果是继续,如果不是return.
例如,假设我有一个客户端事件,我只想在所述服务器允许它使用命令时触发。
喜欢
@bot.command()
async def allow(ctx):
#code that makes my specified event work for the server, keep in mind there are multiple servers
比如我需要 JSON 来记录 ctx.guild.id 吗?或者?
请以 cog 和正常形式提及代码..
您必须将其存储在 JSON 文件中,是的。并且让它像:当执行命令 allow
时,将公会 ID 存储在 JSON 文件中。执行上述允许的命令时,检查公会 ID 是否在 JSON 文件中。如果是继续,如果不是return.