擅长:python、mysql、java
<p>您可以尝试以下方法:</p>
<pre><code>disables = []
@client.command()
@commands.has_permissions(administrator=True)
async def disable(ctx, command):
command = client.get_command(command)
if not f"{command}: {ctx.guild.id}" in disables:
disables.append(f"{command}: {ctx.guild.id}")
await ctx.send(f"Disabled **{command}** for this server.")
else:
await ctx.send('This command is already disabled')
@client.command()
@commands.has_permissions(administrator=True)
async def enable(ctx, command):
command = client.get_command(command)
if f"{command}: {ctx.guild.id}\n" in disables:
await ctx.send(f"Enabled **{command}** for this server.")
else:
await ctx.send('This command is already enabled')
</code></pre>
<p>现在您必须添加:</p>
<pre><code>if "COMMAND: {ctx.guild.id}" in disables:
return
</code></pre>
<p>在<code>async def command(ctx)</code>和此命令的代码之间</p>
<p><em><strong>警告</strong></em>:这是一种非常糟糕的方法。您可以尝试将禁用列表保存到json文件中。如果需要帮助,请向我发送消息-<code>Special unit#5323</code></p>