Python Discord机器人会突然对所有事情做出3次响应。启动或执行cmds时未进行任何更改,也未显示任何错误

Python Discord机器人会突然对所有事情做出3次响应。启动或执行cmds时未进行任何更改,也未显示任何错误,python,discord,discord.py,Python,Discord,Discord.py,我的问题在代码下面 import discord import os from keep_alive import keep_alive from discord.ext import commands import random import requests import json import asyncio from discord.ext.commands import MissingPermissions bot=commands.Bot(command_prefix = '>

我的问题在代码下面

import discord
import os
from keep_alive import keep_alive
from discord.ext import commands
import random
import requests
import json
import asyncio
from discord.ext.commands import MissingPermissions
bot=commands.Bot(command_prefix = '>')
bot.remove_command("help")
 
def get_quote():
 response = requests.get("https://zenquotes.io/api/random")
 json_data = json.loads(response.text)
 quote = json_data[0]['q'] + " -" + json_data[0]['a']
 return(quote)
 
@bot.event
async def on_ready():
 print('The bot is online')
 await bot.change_presence(activity=discord.Game('>help | Bot made by ColeTMK'))
 
@bot.command()
async def quote(ctx):
 quote = get_quote()
 embed=discord.Embed(title="Random Quote", description=(quote), color=0x00FFFF)
 await ctx.send(embed=embed)
 
@bot.command()
@commands.has_permissions(manage_messages=True)
async def clear(ctx, amount=5):
 await ctx.channel.purge(limit=amount+1)
 embed=discord.Embed(title="Clear Messages", description=f'{amount} messages were deleted!', color=0x00FFFF)
 await ctx.send(embed=embed)
 await asyncio.sleep(3)
 await ctx.channel.purge(limit=1)
 
@clear.error
async def clear_error(ctx, error):
   if isinstance(error, MissingPermissions):
       await ctx.send(f"{ctx.author.mention}, Sorry, you do not have permission to do that!")
 
@bot.command()
@commands.has_permissions(ban_members=True)
async def ban(ctx, member: discord.Member, *, reason=None):
 await member.ban(reason=reason)
 embed=discord.Embed(title="Ban", description=f'User {member} has been banned!', color=0x00FFFF)
 await ctx.send(embed=embed)
 
@ban.error
async def ban_error(ctx, error):
   if isinstance(error, MissingPermissions):
       await ctx.send(f"{ctx.author.mention}, Sorry, you do not have permission to do that!")
 
@bot.command()
@commands.has_permissions(kick_members=True)
async def kick(ctx, member: discord.Member, *, reason=None):
 await member.kick(reason=reason)
 embed=discord.Embed(title="Kick", description=f'User {member} has been kicked!', color=0x00FFFF)
 await ctx.send(embed=embed)
 
@kick.error
async def kick_error(ctx, error):
   if isinstance(error, MissingPermissions):
       await ctx.send(f"{ctx.author.mention}, Sorry, you do not have permission to do that!")
 
@bot.command()
async def ping(ctx):
 embed=discord.Embed(title="Pong!", description=f'My ping is {round(bot.latency*1000)}ms', color=0x00FFFF)
 await ctx.send(embed=embed)
 
@bot.command()
async def shelp(ctx):
  embed=discord.Embed(title="Suici** Hotlines", description="US - 800-273-8255, Canada - 833-456-4566, Mexico - 55-5259-8121, Ireland - 116 123 OR text HELLO to 50808, Australia - 13 11 14 United Kingdom - 01708 765200. Remember that you are LOVED! You can do this, we believe in you! If you dont see your country above, please open a support ticket and we will find the # for you.", color=0x00FFFF)
  await ctx.send(embed=embed)
 
@bot.command()
async def deadchat(ctx):
 embed=discord.Embed(description="AYOOO CHAT IS DEAD! SPEAK HUMANS SPEAKKK YOU MUST!", color=0x00FFFF)
 await ctx.send(embed=embed)
 
@bot.command()
@commands.has_permissions(manage_roles=True)
async def tempmute(ctx, member: discord.Member, time=0, reason=None):
   if reason == None:
       reason = "no reason provided"
  
   if member.id == ctx.author.id:
       await ctx.send(f"{ctx.author.mention}, AYOO you can't mute yourself!")
       return
 
   role = discord.utils.get(ctx.guild.roles, name="muted")
 
   if role in ctx.guild.roles:
       await member.add_roles(role)
       embed=discord.Embed(title="Temp. Mute", description=f"Offender: {member.mention} was successfully temp. muted!", color=0x00FFFF)
       embed.add_field(name="Duration", value=f'{time} seconds', inline=True)
       embed.add_field(name="Reason", value=f'{reason}', inline=True)
       embed.add_field(name="Moderator", value=f'{ctx.author.name}', inline=True)
       await ctx.send(embed=embed)
       await asyncio.sleep(time)
       await member.remove_roles(role)
   else:
       await ctx.send(f"{ctx.author.mention}, Make sure your muted role is called `muted` in all lowercase! Then try again.")
 
@tempmute.error
async def tempmute_error(ctx, error):
   if isinstance(error, MissingPermissions):
       await ctx.send(f"{ctx.author.mention}, Sorry, you do not have permission to do that!")       
 
@bot.command()
@commands.has_permissions(manage_roles=True)
async def mute(ctx, member: discord.Member, reason=None):
 
   if member.id == ctx.message.author.id: # If author
       await ctx.send("You can't mute yourself")
       return
   if member:
     role = discord.utils.get(ctx.guild.roles, name='muted')
 
   if role in ctx.guild.roles:
       await member.add_roles(role)
       embed=discord.Embed(title="Muted", description=f"Offender: {member.mention} has been muted until further notice!", color=0x00FFFF)
       embed.add_field(name="Reason", value=f'{reason}', inline=True)
       embed.add_field(name="Moderator", value=f'{ctx.author.name}', inline=True)
       await ctx.send(embed=embed)
   else:
     await ctx.send(f"{ctx.author.mention}, Make sure your muted role is called `muted` in all lowercase! Then try again.")
 
@mute.error
async def mute_error(ctx, error):
   if isinstance(error, MissingPermissions):
       await ctx.send(f"{ctx.author.mention}, Sorry, you do not have permission to do that!")
      
@mute.error
async def mute_error(ctx, error):
   if isinstance(error, commands.MissingRequiredArgument):
       await ctx.send(f"{ctx.author.mention} HEY YOU NUGGET! You need to tell me who you want to mute! ")
 
@bot.command()
@commands.has_permissions(manage_roles=True)
async def unmute(ctx, member: discord.Member,):
  
   if member.id == ctx.author.id:
       await ctx.send(f"{ctx.author.mention}, your not even muted LMAOOO")
       return   
  
   role = discord.utils.get(ctx.guild.roles, name='muted')
   await member.remove_roles(role)
   embed=discord.Embed(title="Unmute", description=f"{member.mention} was succesfully unmuted!", color=0x00FFFF)
   embed.add_field(name="Moderator", value=f'{ctx.author.name}', inline=True)
   await ctx.send(embed=embed) 
 
@unmute.error
async def unmute_error(ctx, error):
   if isinstance(error, MissingPermissions):
       await ctx.send(f"{ctx.author.mention}, Sorry, you do not have permission to do that!")
 
@bot.command()
async def loved(ctx):
 embed=discord.Embed(title="Remember that you are loved! :heart: :heart: :heart:", description="Don't forget that!", color=0x00FFFF)
 await ctx.send(embed=embed)
 
@bot.command()
async def say(ctx, *, text):
 message = ctx.message
 await message.delete()
 await ctx.send(f"{text}")
 print(f"{message.author} said {text} in {message.author.guild}")
 
@bot.listen()
async def on_message(message):
   if message.author.id == bot.user.id:
       return
   msg_content = message.content.lower()
 
   curseWord = ['bad words here']
   author = message.author.id
 
   if any(word in msg_content for word in curseWord):
     await message.delete()
     embed=discord.Embed(title="No No Word", description=f"{message.author.mention}, Hey! Those words arent allowed here!", color=0x00FFFF)
     await message.channel.send(embed=embed)
     print(f"{message.author.name} said {message.content} in {message.author.guild}")
   else:
     await bot.process_commands(message)
 
@bot.listen()
async def on_message(message):
   if message.content.startswith(">numbergame"):
       channel = message.channel
       await channel.send("Guess the number from 0-100 by writing the number in this channel!")
 
       number = random.randint(1,100)
 
       def check(m):
           return m.content.isdigit() and m.channel == channel and m.author == message.author
 
       print(number)
  
       while True:
           try:
               msg = await bot.wait_for('message', timeout=30.0, check=check)
           except asyncio.TimeoutError:
               return await channel.send(f"{message.author.mention}, You are late to guess!")
           guess = int(msg.content)
           if guess == number:
               return await channel.send(f"Correct answer! {message.author.mention}")
           elif guess > number:
               await channel.send(f"{message.author.mention}, Your guess was too high!")
           elif guess < number:
               await channel.send(f"{message.author.mention}, Your guess was too low!")
   else:
       await bot.process_commands(message)
 
keep_alive()
 
bot.run(os.getenv('TOKEN'))


从几分钟前开始,每次我执行命令时,它都会打印三次,而不是像往常一样只打印一次。没有粘贴两次或类似内容的命令。我的问题是,代码中是否有任何东西使bot这样做?任何帮助都将不胜感激。

这个问题已经附加到我身上,不要担心,您的代码不是问题所在。有时,当你关闭你的程序时,你的机器人仍然可以运行,然后当你重新启动你的代码时,在机器人帐户上有两个启动的代码等等。。。要修复此问题,请在您的bot页面上重新生成令牌,不要忘记更新代码。

您如何运行bot?另外,请尝试提供一个MRE,而不是您的全部代码。@Ceres我正在Repl上运行它。它将代码放入您的问题中,而不是作为链接。或者把它放在GitHub上。您可能多次运行bot。@Ceres它是为您编辑的。如果您不停止/杀死bot,则它可能仍在运行-如果您再次运行bot,则系统将同时运行两个bot。