我正在研究一个伐木机器人。为了做到这一点,我使用了带有jump_url的on_message来检测链接,但是机器人只是发送垃圾邮件,我猜这是因为它读取自己的消息。
我试图通过检查消息作者是否是用户来阻止它,但这并没有解决它。每当我输入任何东西时,它都会记录下来,并有链接,即使我没有放入任何链接。
这是在齿轮上。
@commands.Cog.listener()
async def on_message(self, message):
embed=discord.Embed(title="Message from {} contains a link ".fo
如果我把这个放在main.py中,机器人就坏了,没有命令可以工作,但我没有错误
@client.event
async def on_message(message):
if client.user.mentioned_in(message):
embed=discord.Embed(description='My prefix here is ?. You can see available commands by typing `?help`', color=0x850000)
await message.channel.send(e
if '!mvp' in message.content and message.author != client.user:
print('MVP spotted.')
await discord.VoiceClient.play(self,source='audio/quotes/CypherLastKillMVP.mp3')
忽略on_message跟踪中的异常(最近一次调用):文件on_message第343行,在_run_event中等待coro(*args,**kwargs)文件"C:\
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.channel.get_channel(763827099084521484):
await asyncio.sleep(5)
await message.delete() 尽管我得到了错误: File “main.py”, line 24, in on_message
if message.channel.get_channel(76382709
尝试让我的机器人用"this is a dm“回复dm,但没有成功,下面是我的代码: @client.event
async def on_message(message):
if message.guild == null:
await message.channel.send('this is a dm')
else:
pass 我也尝试过这样做: @client.event
async def on_message(message):
if isinstance(message.channel, disco
我是编程新手,最近开始尝试编写我自己的机器人。然而,我看过的几乎所有教程都使用ctx命令,每当我使用它时,我都会收到以下错误: "NameError: name 'ctx' is not defined" 下面是使用ctx命令的部分代码。这样做的目的是让它删除最后发送的3条消息。 @client.event
async def purge(ctx):
"""clear 3 messages from current channel"""
channel = ctx.message.cha
我最近才在使用discord.py和discord.ext命令扩展来制作机器人时遇到一个问题 当我调用一个命令时,它会运行两次,导致许多错误和错误。它仅在添加此命令后才开始发生 @commands.command()
async def afk(self, ctx, userMessage):
#if user is already afk, remove them from the afk dict, if not add them to it
if ctx.message.author in self.afkUsers:
当我尝试在我的discord.py齿轮中添加一个普通功能时,它将弹出not defined bot.py import discord
from discord.ext import commands
import os
token = You cant have it
prefix = "."
client = commands.Bot(command_prefix=prefix)
@client.event
async def on_ready():
print(f"{client.user.name} is ready!")
for fi
我正在为一个新的服务器制作一个机器人,并且我一直收到这个错误,我对python和一般的编码都很陌生,所以任何帮助都是非常感谢的。
事件()缺少一个必需的位置参数:“coro”错误discord.py
当我发帖时,这是说我的帖子看上去大部分都是代码,所以我只想输入一些随机的东西,直到它允许我发布。我有一只很酷的狗,它很可爱,是有史以来最好的男孩:)
下面是我得到错误的代码
@client.event
async def on_ready():
print('We have logged in as {0.user}'
.format(client)