0

With my code below, my bot prints what i wrote but the command is not working. I think the sequence is the problem. so, i tried to code @bot.command() first and @bot.event later but still not working... What's the problem??

import discord
from discord.ext import commands, tasks
import time
import datetime

bot = commands.Bot(command_prefix=commands.when_mentioned_or("!"))
token = ''

@bot.event #working
async def on_message_delete(message):
    ts = time.time()
    st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
    print('<' + st + '>' '메시지 삭제 ' + message.author.name + ':' + message.content)


@bot.event #working
async def on_message_edit(before, after):
    ts = time.time()
    st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
    fmt = '**{0.author}** 가 메시지를 수정했습니다.:\n{0.content} -> {1.content}'
    print('<' + st + '>' + fmt.format(before, after))


@bot.event #working
async def on_message(message):
    ts = time.time()
    st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
    print('<' + st + '> ' + message.author.name + " : " + message.content)


@bot.command() #Not working
async def test(ctx):
    embed = discord.Embed \
            (
                title='노노봇 명령어 입니다',
                description='',
                colour=discord.Colour.blue()
            )
    embed.add_field(name='~', value='~', inline=False)
    await ctx.channel.send(embed=embed)


bot.run(token)
moonjy1120
  • 37
  • 2
  • 11
  • You seems to have the same problem than [here](https://stackoverflow.com/questions/61536253/why-wont-discord-bot-recognize-commands) maybe this could help you to have a look ! – kiliz May 03 '20 at 06:50
  • I checked the link you posted, but the problem was quite different from mine... i didn't mix bot and client.... anyway thx for info^^ – moonjy1120 May 03 '20 at 07:24

0 Answers0