python - 在 message.content.find 上 Disord.py 双输出

标签 python python-3.x discord discord.py discord.py-rewrite

我正在使用 discord.py 制作我自己的不和谐骰子滚轴机器人,我遇到了一点混战。
我输入时总结的d20 (这是掷 20 面骰子的命令)我得到 2 个骰子而不是一个。然而,其中有趣的部分是,当我掷出任何其他较小数字的骰子时,我会根据需要掷出一个骰子。
例子:

User: d10
Bot: 12

User: d20
Bot: 3
Bot: 16
这是有问题的代码:
import asyncio
from discord.ext import commands

@commands.Cog.listener()
async def on_message(self, message):
    d4possible_responses = ['1','2', '3', '4']
    d6possible_responses = ['1','2', '3', '4', '5', '6']
    d8possible_responses = ['1','2', '3', '4', '5', '6', '7', '8']
    d10possible_responses = ['1','2', '3', '4', '5', '6', '7', '8', '9', '10']
    d20possible_responses = ['1','2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20']

    if (message.guild.id == 464298877823221761) or (message.guild.id == 712143774935154689) or (message.guild.id == 540812622619082782):
        if message.content.find("d4") != -1:
            await message.channel.send(':game_die: `'+ random.choice(d4possible_responses)+'`')
        if message.content.find("d6") != -1:
            await message.channel.send(':game_die: `'+ random.choice(d6possible_responses)+'`')
        if message.content.find("d8") != -1:
            await message.channel.send(':game_die: `'+ random.choice(d8possible_responses)+'`')
        if message.content.find("d10") != -1:
            await message.channel.send(':game_die: `'+ random.choice(d10possible_responses)+'`')
        if message.content.find("d20") != -1:
            await message.channel.send(':game_die: `'+ random.choice(d20possible_responses)+'`')
这是整个齿轮:https://hastebin.com/mahabuluta.py

最佳答案

我写在这里作为答案 bc 没有 50 评论声誉。 ^^ - 这只是一个建议的解决方案。
就像@Tin Nguyen 说的那样,也许你之前做了一些其他的机器人,之前刚刚实现了 d20。现在 bot 的 2 个实例对“d20”命令使用react,并且您得到双输出。

我建议您重新启动电脑,因为我在代码中找不到任何问题。

关于python - 在 message.content.find 上 Disord.py 双输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63147181/

相关文章:

python - 用 Python 计算日期

python - Discord.py 重写冷却命令

aws-lambda - 使用 AWS Lambda 的 Discord 机器人

python - 如果不同的变量是 True 或 False Python 3.3,则打印

python - 魔术模拟 assert_called_once 与 assert_called_once_with 奇怪的行为

python - Python 原生 tarfile lib 内存使用率高

python-3.x - Pyvista 曲面图?

python - 以可以在 Python 中排序的格式存储输出

python - 我想让我的 Discord Bot 发送图像/gif

python - 如何修复在歌曲实际结束之前停止播放的不和谐音乐机器人?