Discord.py Discord Bot发送多条消息
因此,我正在创建一个简单的机器人,它可以检测何时有人加入服务器以及何时有人离开服务器。 我添加了一个命令来显示人们的头像,但每当我这样做,或者当有人加入或离开时,它都会不止一次地发送消息。 我找过了,找不到问题。 你们能帮帮我吗 这是我的密码Discord.py Discord Bot发送多条消息,discord.py,Discord.py,因此,我正在创建一个简单的机器人,它可以检测何时有人加入服务器以及何时有人离开服务器。 我添加了一个命令来显示人们的头像,但每当我这样做,或者当有人加入或离开时,它都会不止一次地发送消息。 我找过了,找不到问题。 你们能帮帮我吗 这是我的密码 import discord from discord.ext import commands client = commands.Bot(command_prefix="?") @client.event async def on
import discord
from discord.ext import commands
client = commands.Bot(command_prefix="?")
@client.event
async def on_ready():
print("Ready")
@client.event
async def on_member_join(member):
channel = discord.utils.get(member.guild.text_channels, name="entradas")
await channel.send(f"{member} is new on the server, everyone say hi")
show_avatar = discord.Embed(color = discord.Color.blue())
show_avatar.set_image(url="{}".format(member.avatar_url))
await channel.send(embed=show_avatar)
@client.event
async def on_member_remove(member):
channel = discord.utils.get(member.guild.text_channels, name="saidas")
await channel.send(f"{member} left the server, press F to pay respects")
@client.command()
async def avatar(ctx, member: discord.Member):
show_avatar = discord.Embed(color = discord.Color.blue())
show_avatar.set_image(url="{}".format(member.avatar_url))
await ctx.send(embed=show_avatar)
您应该检查是否正在运行2个机器人 如果您是在Linux上用screen运行bot,只需检查
screen -ls
在windows上,只需检查任务管理器并查看类似Python的内容
顺便说一句,同一个机器人可以运行两次