python - discord.py - 按名称在特定频道上发送消息
问题描述
我想这样做,当一条消息被删除时,它会发送在#logs 中被删除的消息
代码:
@bot.event
async def on_message_delete(message):
data = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
print("[" + (colored("{}".format(data), 'white')) + "][" +
(colored("{}".format(message.server), 'blue')) + " - " +
(colored("{}".format(message.channel), 'magenta')) + "] " +
(colored("{}".format(message.author), 'cyan', 'on_magenta') +
(colored(": {}".format(message.content), 'red'))))
channel = bot.get_channel("logs")
await bot.say(channel, "ALERT: Message Deleted")
await bot.say(channel, "Message {} got deleted by {} in {}".format(message.content, message.author, channel))
await bot.process_commands(message)
解决方案
推荐阅读
- java - 在 h2 数据库中编写查询以转换日期格式
- oracle - Oracle 的 TO_NUMBER() 如何确定返回的 NUMBER 数据类型?
- php - laravel:php artisan 优化命令返回“不可序列化”错误
- javascript - 如果里面的函数实际上没有做任何事情,重复调用 `setInterval()` 会损害性能吗?
- javascript - 将脚本排入wordpress插件不起作用
- c# - 无法使用 Process() 打印
- postgresql - 错误:在 Postgresql 中创建扩展时库不兼容
- c# - 多对多实体框架核心插入和更新
- php - Laravel 6.15 是否兼容任何购物车包?
- animation - 可拖动的 Flutter LinearGradient 动画