为什么我的不和谐机器人命令无法正常工作?其他一切正常

时间:2020-11-01 18:49:20

标签: python discord bots discord.py

我为Discord服务器创建了一个CJ机器人,但是命令不起作用。我不知道出什么问题了,其他一切看起来都很好,每4个小时的消息运行正常,但是命令根本不起作用。有人知道我的代码有什么问题吗?

from keep_alive import keep_alive
import discord
import random
import os
from discord.ext import commands, tasks

#Prefixos de comandos e canais de mensagens
CLIENT = commands.Bot(command_prefix='!')
CHANNEL_ID = 772151476218626108

#Quotes do CJ
with open('CJ Quotes.txt') as QUOTES:
    LINES = QUOTES.readlines()

@CLIENT.event
async def on_ready():
    print('')

#Perguntas pro CJ
@CLIENT.command()
async def CJQ(ctx):
    ANSWERS = ['Sim', 'Com certeza!', 'Talvez...', 'Não', 'Nunca!', 'Jamais!', '100% de certeza!', 'Não sei...', 'É possível...', 'Impossível!', 'Isso era pra ser uma piada?', 'Não preciso nem responder essa pergunta.']
    await ctx.send(random.choice(ANSWERS))

#Caso marquem o bot
@CLIENT.event
async def on_message(message):
    ANSWERS_MENTION = ['Falou comigo?', 'O que é?', '?', 'Fala', ':cmonBrug:']
    if CLIENT.user.mentioned_in(message):
        await message.send(random.choice(ANSWERS_MENTION))

#Status do Bot
@CLIENT.event
async def on_ready():
    await CLIENT.change_presence(status=discord.Status.online, activity=discord.Game('Grand Theft Auto San Andreas'))

#Comando !CJ
@CLIENT.command()
async def CJ(ctx):
    await ctx.send(random.choice(LINES))

#Mandar mensagem a cada 4 horas
@tasks.loop(hours=4)
async def four_hours():
    CHANNEL = CLIENT.get_channel(CHANNEL_ID)
    await CHANNEL.send(random.choice(LINES))

@four_hours.before_loop
async def before():
    await CLIENT.wait_until_ready()

#Inicialização
four_hours.start()
keep_alive()
TOKEN = os.environ.get("DISCORD_BOT_SECRET")
CLIENT.run(TOKEN)

0 个答案:

没有答案