Не могу добавить команду help
Запуская бота, появляется консоль и через секунду закрывается. Успел словить фрагментом экрана(Внизу консоль) Прочитал, что нужно под командой bot = commands.Bot(command_prefix = settings[‘prefix’]) нужно написать bot.delete_command(‘help’) . Но так и так консоль закрывается с такой же ошибкой
Отслеживать
47.8k 17 17 золотых знаков 56 56 серебряных знаков 100 100 бронзовых знаков
задан 5 мая 2022 в 11:58
62 5 5 бронзовых знаков
Как сделать команду help?
Стандартная команда не очень красиво смотрится, захотел переделать, но не совсем понимаю как сделать это. В документации вроде бы есть, но я ничего не понял. Можете как то объяснить, как мне брать название команды, ее описание и выводить это как эмбед.
Я еще делал «статичный» текст, но это не круто, каждый раз редактировать описание и п.р..
- Вопрос задан более двух лет назад
- 3222 просмотра
5 комментариев
Простой 5 комментариев
Making a say command in discord.py
I want to make a simple say command in discord.py (ex.!say something — the bot says «something» and deletes the command message) but every code I found doesn’t work for me. I’m new to python and discord.py and would really appreciate some help. Thanks in advance.
asked Mar 23, 2021 at 12:49
13 4 4 bronze badges
Welcome to SO. Please check ‘how to ask a good question’. This is a troubleshooting place; you present the code you’ve worked on, along with the error tracebacks, then we help you with what’s going on.
Mar 23, 2021 at 13:04
3 Answers 3
You could also try something much easier like this:
@client.command() async def say(ctx, message): if message != None ctx.channel.send(message) elif message == None: ctx.channel.send('Give me something to say')
answered Aug 24, 2021 at 2:34
Vihaan Patil Vihaan Patil
17 7 7 bronze badges
It’s more Pythonic to compare None via is rather than == or != . This code block is also not fully answering the question since OP asked to deleted the command.
Aug 24, 2021 at 6:29
This is the easiest way I’ve been able to do this, hope it helps!
@client.command() async def say(ctx, *, text): await ctx.message.delete() await ctx.send(f"")
answered May 11, 2022 at 4:47
ShinyDragon96 ShinyDragon96
5 5 5 bronze badges
You can find a lot of useful information on what you can make your discord bot do in the discord.py API reference. This is an example which should do what you want it to:
import discord from discord.ext import commands
Set your bot’s intents and command prefix as well as your bot token:
intents = discord.Intents().default() bot = commands.Bot(command_prefix='!', intents=intents) token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
Define a command ‘!say’ with a parameter ‘msg’, which the bot should reply:
@bot.command(name='say') async def audit(ctx, msg=None): if msg is not None: await ctx.send(msg)
Now you can delete the message which invoked the command (needs permissions!):
await ctx.message.delete()
Finally, run the bot:
bot.run(token)
