为什么我的机器人循环会给我多个答案?

Why does my bot loop give me multiple answers?

所以我创建了一个机器人,在其中我根据 'mood(?)' 将一堆引号整理到单独的列表中,并且在前 30 分钟左右一切正常?但是过了一会儿,如果我输入一个命令,它会给我一个答案(同一个)4-16 次?我很确定它在循环,但我不确定为什么以及如何循环。

这是我的部分代码,其余只是重复这里的内容:

import discord
from discord.ext import commands
import random
client = commands.Bot(command_prefix='-')

@client.event
async def on_ready():
    print("Bot is ready for use <3")
    print(client.user.name)
    print('------------------------')

@client.event
async def on_message(message):
    if message.content.startswith('-helpjuseyo'):
        embed = discord.Embed(title="positivity bot help function", description="List of usable commands:", color=0x83B5E3)
        embed.add_field(name="-motivation", value="will give you a motivational line/quote", inline=True)
        embed.add_field(name="-comfort", value='for you are feeling down, scared, anxious or depressed,will give you a comforting quote', inline=True)
        embed.add_field(name='-positivity', value='will give you a positive quote <3', inline=True)
        embed.add_field(name='-cry', value="sometimes you just need to cry, and that's ok <3. Will give you an angsty quote/line to cry to")
        embed.add_field(name='-bts', value="a collection of BTS's best quotes & lyrics", inline=True)
        embed.add_field(name='-genzoo', value="a collection of quotes from genzoo's soft hours (still in production)", inline=True)
        embed.add_field(name='-helpjuseyo', value="will give you the positivity bot's command masterlist", inline=False)
        await message.channel.send(embed=embed)
    await client.process_commands(message)


@client.command()
async def motivation(ctx):
    quotes = ['Work while they sleep. Learn while the party. Save while they spend. Livelike they dream', 'All our dreams can come true, if we have the courage to persue them.', 'The secret of getting ahead is getting started', 'The best time to plant a tree was 20 years ago, the second best time ins now', 'If BTS can juggle promotions, photoshoots, private life, university, world tours and more, you can definitely do the task you are procrastinating on.', "Keep going! You've made it this far! You can do it, I believe in you~~", "Dance like no one is watching, love like you will never be heard, sing like nobody is listening and live like it's heaven on earth", 'Knowing is not enough, we must also apply; Willing is not enough, we must also do.', "Don't slow down now! You've already made it this far! Dream, hope, move forward; look at all the possibilities", "You must remain focused on your journey in life", "Think of all the possibilities, everything that could go right, instead of everything that could go wrong", "Your future is created by what you do today, not what you do tomorrow.", "Remember: your focus determines you reality", "Take a deep breath and focus on what's really important", "Every moment has the potential to become an opportunity, it just depends on how you look at it", "When it boils down to it, you are the sole leader of your life"]
    await ctx.send(f' **{random.choice(quotes)}**')

@client.command()
async def comfort(ctx):
    quotes = ["It's ok to feel down, to not be ok. Life isn't always perfect <3", 'Reminder: there is a person here in Korea, in the city of Seoul, who understands you <3', "Everyone's paces are difference from one another, your pace is yours alone. This is your life, live it how it suits you best. There is no rush", "It’s all right to not have a dream, it's ok to not know where you're going, what your path is or where you are aiming. Life is no simple task, be proud of how far you've come", "Congratualtions! For making it as far as you ever have in your life.", "Reminder: BTS 'will be there for you, with love", "[BTS] want[s] you to know that you are special", "No matter the situation or the time, there will always someone willing to listen to your woes and worries. All you have to do is ask <3"]
    await ctx.send(f' **{random.choice(quotes)}**')

@client.command()
async def positivity(ctx):
    quotes = ["Don't waste your energy on negative thinking and focus more on what makes you happy", "Enjoy the little things, for one day you may look back and realize they were the big things", "When you focus on the good, the good gets better", "Reminder: *you* are beautiful, intelligent, wise, amazing, talented and anything you wish to be", "I'm proud of you, you've made it through another day <3", "Reminder: It's ok to feel down, it's because of our low points, that we are able to appriciate our highs more", "Life is full of ups and downs, enjoy the highs, use your lows as learning opportunites", "Sometimes your heart needs more time to accept something your mind already knows, and that's perfectly ok", "Learn from your past, your low points in life, but don't be controlled by them", "Don't let anyone make you feel like you don't deserve what you want", "Strive to be the best version of *you* that you can be", "Remember, you always have room to grow. Use your lows as an opportunity to grow and learn"]
    await ctx.send(f' **{random.choice(quotes)}**')

client.run(TOKEN)

我认为这不会解决您的问题,但您可以创建一个帮助命令,而不是在 on_message 事件中硬编码一个命令:

import discord
from discord.ext import commands
import random

client = commands.Bot(command_prefix='-')
client.remove_command('help')

@client.event
async def on_ready():
    print("Bot is ready for use <3")
    print(client.user.name)
    print('------------------------')

@client.command(brief='-help', description='Shows this message'):
async def help(ctx):
    embed = discord.Embed(title="Commands list", color=0x83B5E3)
    for command in bot.commands:
        embed.add_field(name=commands.brief, value=command.description)
    await ctx.send(embed=embed)

@client.command(brief='-motivation', description='Will give you a motivational quote')
async def motivation(ctx):
    quotes = [#Your quotes]
    await ctx.send(f' **{random.choice(quotes)}**')

@client.command(brief='-comfort', description='For you are feeling down, scared, anxious or depressed,will give you a comforting quote')
async def comfort(ctx):
    quotes = [#Your quotes]
    await ctx.send(f' **{random.choice(quotes)}**')

@client.command(brief='-positivity', description='Will give you a positive quote <3')
async def positivity(ctx):
    quotes = [#Your quotes]
    await ctx.send(f' **{random.choice(quotes)}**')

client.run(TOKEN)

PS:如果我找到解决您问题的方法,我会编辑此 post。
顺便说一句,如果您的代码太长,您可能需要创建 cogs.

好吧,经过多次试错,我发现这是因为我一直点击运行程序而没有先停止程序。

为了避免这种情况,我只需要记住在重新运行再次

之前单击'cancel build'/停止程序运行ning