Бот не отвечает на команды
Когда я пишу команду например -balance он не отвечает. А send_message_every_3_days он отлично работает.
from discord.ext import tasks, commands
import asyncio
import random
TOKEN = '' # Replace with your token
YOUR_CHANNEL_ID = # Replace with your channel ID
intents = discord.Intents.default()
intents.typing = False
intents.presences = False
bot = commands.Bot(command_prefix='-', intents=intents)
balances = {}
@bot.event
async def on_ready():
print(f'Bot successfully logged in as {bot.user.name}')
await send_message()
send_message_every_3_days.start()
@tasks.loop(hours=72)
async def send_message_every_3_days():
await send_message()
async def send_message():
channel = bot.get_channel(YOUR_CHANNEL_ID)
if channel:
a = random.randint(1, 500)
await channel.send(f"Today's ChessCoin exchange rate is: {a}")
else:
print("Failed to find the specified channel.")
@bot.command()
async def balance(ctx):
user_id = ctx.author.id
if user_id not in balances:
balances[user_id] = 100
balance_amount = balances[user_id]
await ctx.send(f"Your balance is: {balance_amount}")
@bot.command()
async def buy(ctx, amount: int):
user_id = ctx.author.id
if user_id not in balances:
balances[user_id] = 100
balance_amount = balances[user_id]
if amount > balance_amount:
await ctx.send("Insufficient balance.")
else:
balances[user_id] -= amount
await ctx.send(f"You have successfully bought {amount} ChessCoins.")
@bot.command()
async def sell(ctx, amount: int):
user_id = ctx.author.id
if user_id not in balances:
balances[user_id] = 100
balance_amount = balances[user_id]
balances[user_id] += amount
await ctx.send(f"You have successfully sold {amount} ChessCoins.")
bot.run(TOKEN)
================ RESTART: C:/Users/Admin/Desktop/chessbot1.3.py ================
[2023-07-02 15:33:12] [WARNING ] discord.ext.commands.bot: Privileged message content intent is missing, commands may not work as expected.
[2023-07-02 15:33:12] [INFO ] discord.client: logging in using static token
[2023-07-02 15:33:14] [INFO ] discord.gateway: Shard ID None has connected to Gateway (Session ID: 735df2d3b988285bf74841c7c512e863).
Bot successfully logged in as ChessBot```
Источник: Stack Overflow на русском