小编cla*_*iew的帖子

DiscordAPIError:交互已被确认。Discord.js的react()函数问题

我有一个创建新 MessageEmbed 的 poll 命令,然后我希望机器人用 4 个表情对投票作出反应,以便能够在投票中投票。问题是,当我reply()在交互中使用该函数时,机器人崩溃并给出此错误:DiscordAPIError: Interaction has already been acknowledged.我尝试获取回复,但它似乎不起作用。这是代码:

const { SlashCommandBuilder } = require('@discordjs/builders');

module.exports = {
    data: new SlashCommandBuilder()
        .setName('poll')
        .setDescription('Make a poll, (and you get to choose the options) ;)')
        .addStringOption((option) =>
            option
                .setName('title')
                .setDescription('The title of the poll embed.')
                .setRequired(true)
        )
        .addStringOption((option) => 
            option
                .setName('option1')
                .setDescription('1st option for the poll.')
                .setRequired(true)
        )
        .addStringOption((option) => 
            option
                .setName('option2')
                .setDescription('2nd option for the poll.')
                .setRequired(true)
        )
        .addStringOption((option) =>
            option
                .setName('option3')
                .setDescription('3rd option …
Run Code Online (Sandbox Code Playgroud)

javascript discord discord.js

1
推荐指数
2
解决办法
3万
查看次数

将一串数字拆分成一个列表python

我有一个包含随机数量的数字的字符串,这些数字可以是 1、2、3 等,但它们甚至可以是 100、20、25...所以如果我正在搜索 14,我会找到144 中的 14(如果字符串包含它)。我必须将它们分成整数列表。这是我尝试过的:

def to_list(string):
    result_list = []
    for idx in range(len(string)):
      if string[idx] != "0":
        zeros = 0
        for j in string[idx + 1:len(string)]:
          if j == "0":
            zeros += 1
          else:
            result_list.append(string[idx] + "0" * zeros)
            break

    result_list.append(string[-1])
    return result_list
Run Code Online (Sandbox Code Playgroud)

python string list

0
推荐指数
1
解决办法
97
查看次数

标签 统计

discord ×1

discord.js ×1

javascript ×1

list ×1

python ×1

string ×1