Skip to main content
 首页 » 编程设计

python之Discord 机器人帮助命令

2025年01月19日14thcjp

所以当人们使用 discord.py 附带的帮助命令时,我试图更改命令的描述。

但我似乎真的不知道如何或在何处放置此描述。

我也在尝试在帮助列表中创建不同的类别,例如音乐,但我真的不知道从哪里开始。

我是 python 的新手,但我之前接触过其他编程语言

我的代码很长,但这里是其中的一部分

client = commands.Bot(command_prefix=commands.when_mentioned_or('?'),  
description='Help List', pm_help = True) 
client.add_cog(Music(client)) 
 
path = 'Blacklist.txt' 
 
bl = open(path, 'r') 
 
@client.event 
async def on_ready(): 
    print('---------------------------------------------------------------------------------------') 
    print('') 
    print('Logged in as '+client.user.name+' (ID:'+client.user.id+') | Connected to '+str(len(client.servers))+' servers | Connected to '+str(len(set(client.get_all_members())))+' users') 
    print('') 
    print('---------------------------------------------------------------------------------------') 
    print('') 
    print('Current Discord.py Version: {} | Current Python Version: {}'.format(discord.__version__, platform.python_version())) 
    print('') 
    print('---------------------------------------------------------------------------------------') 
 
@client.command() 
async def ping(*args): 
    await client.say(":ping_pong: Pong!") 

假设我想为 ping 命令添加描述。我具体应该在哪里以及如何做?

请您参考如下方法:

@client.command(description="Some ping command") #here 
async def ping(*args): 
    await client.say(":ping_pong: Pong!")