英文:
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)
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)
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),
);
}
},
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论