如果我把这个放在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
我正在制作一个机器人,当它检测到你使用了禁用的单词时,它会删除你的消息。很简单,但是,当我这么做的时候。on_message函数正在重复执行。我不知道为什么,但我希望你能回答我的问题
@client.event
async def on_message(msg):
contents = msg.content.split(" ")
for word in contents:
if word.lower() in chat_filter: #ChatFilter is a list of words that cannot be used
所以我一直在努力使某些命令通道具体化。我可以让整个代码都是这样的,但不是某些命令。
async def on_message(message):
if message.author == bot.user:
return
if message.author.bot: return
cmdChannel = bot.get_channel(780617002267967508)
if message.channel.id == cmdChannel.id:
if ' ' in message.content:
我在用discord.py制作机器人时遇到了一个问题,我设法让命令和on_message一起工作,这有点困难,但是现在所有的命令都可以工作了,但是如果我触发其中一个on_message函数,它就会无缘无故地循环输出。我不确定如何解决这个问题,也不确定它。
import discord
from discord.ext import commands
import random
import os
import time
import typing
bot = commands.Bot(command_prefix = '!')
@bot.command()
async de
我是编程新手,最近开始尝试编写我自己的机器人。然而,我看过的几乎所有教程都使用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