B
B
badtrippp12021-09-14 17:12:43
Python
badtrippp1, 2021-09-14 17:12:43

Code not working (discord bot)?

help function does not work. And I can't figure out how to prefix the list.

The code:

import discord
from discord.ext import commands
from script import settings

prefix = settings['PREFIX']
client = commands.Bot(command_prefix = settings['PREFIX'])
client.remove_command('help')

#List
hello_words = ['{}Hello!','{}Hello','{}hello','{}hello!','{}Привет!','{}Привет','{}привет','{}привет!'.format(prefix)]

@client.event

#start bot
async def on_ready():
    print('bot connected')

@client.event

#auto msg
async def on_message(message):
    msg = message.content.lower()
    if msg in hello_words:
        await message.channel.send(f'Приветики!, {message.author.mention}')

#help
async def help(ctx):
    emb = discord.Embed(title="Помошь", description = "Мои команды", colour=discord.Color.blue())
    emb.set.author(name = ctx.author.name, icon_url = ctx.author.avatar_url)
    emb.add_field(value = f'`{prefix}ping `{prefix}vk` `{prefix}instagram')
    emb.set_thumbnail(url=client.user.avatar_url)
    emb.set_footer( icon_url = client.user.avatar_url, text = f"{settings['OWNER NAME']} ©" )
    await ctx.send(embed=emb)

client.run('токен')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-09-14
@Vindicar

First, you're only putting prefix on the last element of the hello_words list.
Second, you do client.remove_command('help') and complain that the help command doesn't work. Your own help() method is not decorated as a command or event.
Third, why not use an existing command framework?

from discord.ext import commands
hello_words = ['привет', 'hello', 'прив']

@commands.command(name=hello_words[0], aliases=hello_words[1:])
async def hello_command(ctx):
    pass #делаешь что хочешь

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question