G
G
Govnokodddd2020-10-04 17:39:15
Python
Govnokodddd, 2020-10-04 17:39:15

How to solve a problem with Discord bot?

import discord
from discord.ext import commands

client = discord.Client()

bot = commands.Bot(command_prefix='!') #инициализируем бота с префиксом '!'

@bot.command(pass_context=True) #разрешаем передавать аргументы
async def test(ctx, arg): #функция
    await ctx.send(arg) 

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

I enter "!test abc" - it doesn't work. There are no errors in cmd. The code also runs fine. It is noteworthy that everything related to the discord.ext library does not work for me. Tried even with several OS. The code with the discord library (discord and discord.ext are different libraries. The latter provides lower level development.) works fine.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
LolKeknutiy, 2020-10-04
@LolKeknutiy

client why? try to edit or rewrite again, but without client

S
soremix, 2020-10-04
@SoreMix

Aren't you embarrassed that you didn't launch the bot?
https://github.com/Rapptz/discord.py#bot-example

M
Michal Palych, 2020-10-04
@SenqHabr

import discord
from discord.ext import commands

Bot = commands.Bot(command_prefix = "!") #инициализируем бота с префиксом '!'

@Bot.command() #в новых версиях можно делать без pass_context
async def test(ctx, *, arg): #* означает, что можно писать хоть что,
    await ctx.send(arg)      #и всё уйдёт в "arg"

Bot.run( 'токен_бота' )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question