【发布时间】:2021-10-30 13:49:25
【问题描述】:
我已经在 StackOverflow 中搜索过,并创建了它。但这并不是我想要的……
所以请不要称其为重复:)
顺便说一下我正在使用的代码:
@client.command()
async def change_prefix(ctx, arg=None):
if str(type(arg)) == "<class 'NoneType'>":
await ctx.send("Please insert an argument...")
else:
client = commands.Bot(command_prefix = str(arg))
command_prefix = str(arg)
embed = discord.Embed(title = "Prefix set!",
description = f"The bot prefix has been set to {arg}",
color = discord.Color.red())
now = datetime.now()
current_time = now.strftime("%H:%M")
embed.set_footer(text=f"Requested by {ctx.author} at {current_time}")
await ctx.send(embed=embed)
【问题讨论】:
-
您能详细说明您要做什么吗?要更改前缀,您需要有一个 json 文件和所有这些。
-
您是要更改每个公会的
command_prefix还是整个机器人?请相应地编辑您的问题以指定您的需求。 -
使用
if arg == None而不是if str(type(arg)) == "<class 'NoneType'>"。这是非常低效的。
标签: python discord.py bots