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)