discord - Discord.py 使用消息时没有输出
问题描述
其目的是限制服务器成员发送垃圾邮件,但在需要时仍会使用。但是,当我尝试使用它时,不会在不和谐上发送任何内容,也没有来自终端端的错误消息。我也没有得到语法错误。我也尝试过在条件中使用or
语句而不是语句,但这也不起作用。任何解决方案表示赞赏,在此先感谢。and
if
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()
解决方案
你在加载齿轮吗?这可能就是为什么什么都没有显示的原因,这是因为您实际上并没有运行代码,所以它没有告诉您任何信息。
当我遇到同样的问题时,这对我有很大帮助:
https://www.youtube.com/watch?v=vQw8cFfZPx0&list=PLW3GfRiBCHOhfVoiDZpSz8SM_HybXRPzZ&index=7
装载和卸载的第一部分可能是您需要的。
推荐阅读
- typescript - 如何在未定义文档的情况下在 Web Worker 中运行 CodeMirror“runMode”?
- odoo-12 - 如何解决那个odoo存储库问题?
- python - ERR_ADDRESS_INVALID,404 未找到,本地主机:8000
- c# - 为什么 DateTime dd/MM/yyyy 不更改为 yyyy-MM-dd?
- python - 将 Tensorflow 包/库添加到 Jupyter 的内核
- python-3.x - 在 spyder 4 中恢复已删除的文件
- linux - Logrotate 忽略最近的文件
- python - ValueError:无法将大小为 5 的序列复制到 Numpy 中维度为 3 的数组轴
- c++ - 在 VC++ 中找到实际的错误点
- python - 在 mixin 表单上,NOT NULL 约束失败