Discordjs V14 在输入时未进行结果过滤。自动完成

huangapple go评论71阅读模式
英文:

Discordjs V14 not filtering while typing in for results. Autocomplete

问题

I have tried using the following as the code to get a list.
示例 1:

And I haven't had any success. With example 1, I am getting the following (image) Discordjs V14 在输入时未进行结果过滤。自动完成
with example

When I type it [], anyone got an idea what I'm doing wrong here?

代码 第 19 - 35 行

无法使筛选器显示与结果匹配的内容。

英文:

i have tried using the following as the code to get a list.
example 1:

And i haven't had any success. With the example 1, i em getting the following (image) Discordjs V14 在输入时未进行结果过滤。自动完成
with example

When i type it [], anyone got an idea what im doing wrong here?

Code Line 19 - 35

Can't get the filter to display what matches to the result

答案1

得分: 0

I got the Array list to actually work, i didn't realize it was CaSe SeNsItIvE until recently. Sorry for wasting peoples reading time! Now to get it to be lower case so it doesn't have to be CaSe SeNsItIvE

        async autocomplete(interaction) {
        con.query('select typeName FROM invTypes JOIN invGroups ON invGroups.groupID=invTypes.groupID JOIN invMarketGroups ON invMarketGroups.marketGroupID = invTypes.marketGroupID and invGroups.categoryID = 6 AND invTypes.published  =1', function (err, results) {
            if (err) throw err;
            shipList(results)
        })
        async function shipList(results) {
            const list = results.map(list => list.typeName)
            const focusedValue = interaction.options.getFocused();
            const choices = list.filter(list => list);
            const filtered = choices.filter(choice => choice.startsWith(focusedValue));
            await interaction.respond(
                filtered.map(choice => ({ name: choice, value: choice })).slice(0, 25),
            );
        }
    },
英文:

I got the Array list to actually work, i didn't realize it was CaSe SeNsItIvE until recently. Sorry for wasting peoples reading time! Now to get it to be lower case so it doesn't have to be CaSe SeNsItIvE

    async autocomplete(interaction) {
    con.query('select typeName FROM invTypes JOIN invGroups ON invGroups.groupID=invTypes.groupID JOIN invMarketGroups ON invMarketGroups.marketGroupID = invTypes.marketGroupID and invGroups.categoryID = 6 AND invTypes.published  =1', function (err, results) {
        if (err) throw err;
        shipList(results)
    })
    async function shipList(results) {
        const list = results.map(list => list.typeName)
        const focusedValue = interaction.options.getFocused();
        const choices = list.filter(list => list);
        const filtered = choices.filter(choice => choice.startsWith(focusedValue));
        await interaction.respond(
            filtered.map(choice => ({ name: choice, value: choice })).slice(0, 25),
        );
    }
},

huangapple
  • 本文由 发表于 2023年6月9日 03:32:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76435160.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定