Discord.py 仅限用户的命令
Discord.py User Only Commands
我想做一个只有我和我的朋友可以使用的命令,但我能找到的只是有作用,但我找不到任何东西来回答我的问题,因为所有能做的都行不通,所以有什么办法吗让它工作,如果你想知道下面的脚本
@client.command(aliases=['rl'])
@commands.has_role('3Peak-Bot-Dev-[RN/ou3PwQFA9uqbXSa6E+ClZJA3uTjK3n3Sl7g5hins=]')
async def reload(ctx):
guild = ctx.guild
embed = discord.Embed(title = f'Reloading!', color = 0xff6300)
await ctx.send(embed=embed)
return await ctx.bot.logout()
您可以添加代码来检查命令是否由您或您的朋友使用ID执行,例如:
@client.command(aliases=['rl'])
async def reload(ctx):
yourID = 1234567890
friendID = 1234567890
if ctx.message.author.id == yourID or ctx.message.author.id == friendID:
# Do something
else:
await ctx.send('You are not allowed to execute this command!')
如果您不知道如何获取用户 ID,here’s a good guide.
我想做一个只有我和我的朋友可以使用的命令,但我能找到的只是有作用,但我找不到任何东西来回答我的问题,因为所有能做的都行不通,所以有什么办法吗让它工作,如果你想知道下面的脚本
@client.command(aliases=['rl']) @commands.has_role('3Peak-Bot-Dev-[RN/ou3PwQFA9uqbXSa6E+ClZJA3uTjK3n3Sl7g5hins=]') async def reload(ctx): guild = ctx.guild embed = discord.Embed(title = f'Reloading!', color = 0xff6300) await ctx.send(embed=embed) return await ctx.bot.logout()
您可以添加代码来检查命令是否由您或您的朋友使用ID执行,例如:
@client.command(aliases=['rl'])
async def reload(ctx):
yourID = 1234567890
friendID = 1234567890
if ctx.message.author.id == yourID or ctx.message.author.id == friendID:
# Do something
else:
await ctx.send('You are not allowed to execute this command!')
如果您不知道如何获取用户 ID,here’s a good guide.