Я новичок в создании ботов для 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)
Я новичок в создании ботов для Discord, и я пытаюсь создать базовую тестовую команду, в которой вы говорите (префикс)test abc, и бот тоже говорит abc. Ошибок не возникает, но когда я набираю r!test abc, ничего не происходит. Я тоже ничего не получаю в терминале.
Вот мой код.
[code]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.