#python #discord #bots
#python #Discord #боты
Вопрос:
Это результат, который я получаю
из этого кода после выполнения !помогите
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». Как мне либо изменить «Нет категории» на «Команды», либо полностью удалить первое текстовое поле?
Ответ №1:
Изменить
client = commands.Bot(command_prefix = '!')
Для
client = commands.Bot(command_prefix = '!', help_command = None)