Команды Discord.py бота Discord не работаютPython

Программы на Python
Anonymous
Команды Discord.py бота Discord не работают

Сообщение Anonymous »

Я новичок в создании ботов для Discord, и я пытаюсь создать базовую тестовую команду, в которой вы говорите (префикс)test abc, и бот тоже говорит abc. Ошибок не возникает, но когда я набираю r!test abc, ничего не происходит. Я тоже ничего не получаю в терминале.

Вот мой код.

Код: Выделить всё

import discord

from dotenv import load_dotenv
from discord.ext import commands

load_dotenv()

GUILD = os.getenv('DISCORD_GUILD') # Same thing but gets the server name
client = discord.Client()
bot = commands.Bot(command_prefix='r!')
TOKEN = 'TOKENGOESHERE'
on = "I'm up and running!"
print("Booting up...")
channel = client.get_channel(703869904264101969)

@client.event # idk what this means but you have to do it

async def on_ready(): # when the bot is ready

for guild in client.guilds:
if guild.name == GUILD:
break

print(f'{client.user} has connected to Discord! They have connected to the following server: ' #client.user is just the bot name
f'{guild.name}(id: {guild.id})' # guild.name is just the server name

)

channel2 = client.get_channel(channelidishere)
await channel2.send(on)
#everything works up until I get to here, when I run the command, nothing happens, not even some output in the terminal.

@commands.command()
async def test(ctx):
await ctx.send("test")

client.run(TOKEN)
Всем спасибо!

Подробнее здесь: https://stackoverflow.com/questions/615 ... nt-working

Вернуться в «Python»