Discord.py使用消息时没有输出



它的目的是限制服务器成员发送垃圾邮件,但在需要时仍会使用。然而,当我尝试使用它时,discord上不会发送任何消息,终端端也不会发出错误消息。我也没有语法错误。我还尝试在if条件中使用or语句而不是and语句,但这也不起作用。任何解决方案都将不胜感激,提前表示感谢。

import discord
import random
import datetime
from discord import Embed
from discord.ext import commands
intents = discord.Intents(messages = True, guilds = True, reactions = True, members = True, presences = True)
client = commands.Bot(command_prefix = '*', intents = intents)

class PleaseWork(commands.Cog):
def __init__(self, client):
self.client = client
self.last_timeStamp = datetime.datetime.utcfromtimestamp(0)
@commands.Cog.listener()
async def on_message(self, message):
time_difference = (datetime.datetime.utcnow() - self.last_timeStamp).total_seconds()
if time_difference < 5 and message.author == client.user:
return
elif message.content.startswith('yo lebclan'): 
await message.channel.send('Sup?')
self.last_timeStamp = datetime.datetime.utcnow()

您正在加载cog吗?这可能就是为什么什么都没有显示的原因,因为你实际上并没有运行代码,所以它不会告诉你任何事情。

当我遇到同样的问题时,这对我帮助很大:

https://www.youtube.com/watch?v=vQw8cFfZPx0&list=PLW3GfRiBCHOhfVoiDZpSz8SM_HybXRPzZ&索引=7

装载和卸载的第一部分可能是您所需要的。

最新更新