【问题标题】:How to revise or remove "No Category" from the help command from a discord bot如何从不和谐机器人的帮助命令中修改或删除“无类别”
【发布时间】:2021-01-06 01:17:53
【问题描述】:

这是我得到的结果

在执行 !help 后从此代码中

import discord
from discord.ext import commands
from discord.utils import get
import os
import youtube_dl

token = os.environ.get('DISCORD_TOKEN')
client = commands.Bot(command_prefix='!')


@client.event
async def on_message(message):
    await client.process_commands(message)
    channels = ['bot-commands']
    if str(message.channel) in channels:
        if message.content == '!help':
            embed = discord.Embed(title='How to use the ImposterBot', description='Useful Commands')
            embed.add_field(name='!help', value='Display all the commands')
            embed.add_field(name='!music', value='Play a music playlist')
            embed.add_field(name='!valorant', value='Get the most recent version of Valorant stats')
            embed.add_field(name='!hello', value='Greet a user')
            embed.add_field(name='!join', value='Connect the bot to a voice channel')
            embed.add_field(name='!leave', value='Disconnect the bot')
            await message.channel.send(content=None, embed=embed)
        elif message.content == '!hello':
            await message.channel.send(f'Greeting, {message.author}!')
        elif message.content == '!valorant':
            await message.channel.send('This feature is not ready yet')
        elif message.content == '!music':
            await message.channel.send('This feature is not ready yet')


@client.command(pass_context=True)
async def join(ctx):
    """ join the voice channel """
    channel = ctx.message.author.voice.channel
    voice = get(client.voice_clients, guild=ctx.guild)

    if voice and voice.is_connected():  # if already on a channel
        await voice.move_to(channel)  # move to the user's channel
    else:
        voice = await channel.connect()
    await ctx.send(f'Joined {channel}')  # if not joined yet, connect to the voice channel


@client.command(pass_context=True)
async def leave(ctx):
    """ leave the voice channel """
    channel = ctx.message.author.voice.channel
    voice = get(client.voice_clients, guild=ctx.guild)

    if voice and voice.is_connected():
        await ctx.send(f'Disconnecting from channel **{channel}**')  # if already connected
        await voice.disconnect()  # disconnect
    else:
        await ctx.send("I'm not connected in any channel")  # if not connected, send this message

client.run(token)

在我添加 !join 和 !leave 命令之前,它只显示了“如何使用 ImposterBot”文本框。如何将“No Category”修改为“Commands”或完全删除第一个文本框?

【问题讨论】:

    标签: python discord bots


    【解决方案1】:

    改变

    client = commands.Bot(command_prefix = '!')
    

    client = commands.Bot(command_prefix = '!', help_command = None)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-29
      • 2021-07-26
      • 2018-02-07
      • 2018-07-21
      • 2018-11-10
      • 2018-05-06
      • 2020-07-16
      • 2017-05-31
      相关资源
      最近更新 更多