我的终端出现了这个错误:
TypeError:无法读取未定义的属性(正在阅读“0”)
我尝试测试对API的调用,但出现错误。
我的代码:
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, StringSelectMenuBuilder, Component } = require('discord.js');
function makeid(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for (var i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() *
charactersLength));
}
return result;
}
module.exports = {
data: new SlashCommandBuilder()
.setName('script')
.setDescription('รับสคริป'),
execute: async (interaction, con, log, client, config) => {
log(`[LOG Command] ${interaction.user.username}, use command getscript`, "green")
const user = interaction.options.getUser('user');
const menu = new ActionRowBuilder().addComponents(
new StringSelectMenuBuilder()
.setCustomId("SELRCTION")
.addOptions(
{ label: "BloxFruit", description: "script BloxFruit ", value: "BF", emoji: "🍎"},
{ label: "City Thiland", description: "script City Thiland 2", value: "CTTH", emoji: "🏙"},
),
);
/*interaction.relpy({ content: "You Select ", ephemeral: true, components: {menu}});*/
await con.query(`SELECT userkey, discord_id,Blacklisted FROM bloxfruit Where discord_id = '${interaction.user.id}'`, async function(err, results, fields) {
if(!results[0]) {
await interaction.reply({
embeds: [
new EmbedBuilder()
.setColor("#FF0000")
.setTitle('**"WET HUB" | ᴡʜɪᴛᴇʟɪsᴛ ᴍᴀɴᴀɢᴇʀ**')
.setDescription("คุณไม่มีไวริสนะคะ กรุณาก่อนใช้ด้วยค่ะ")
.setTimestamp()
],
ephemeral: true
})
} else {
if(results[0].Blacklisted == "True") {
await interaction.reply({
embeds: [
new EmbedBuilder()
.setColor("#FF0000")
.setTitle('**WET HUB | ᴡʜɪᴛᴇʟɪsᴛ ᴍᴀɴᴀɢᴇʀ**')
.setDescription("คุณอยู่ในบัญชีดำนะคะ")
.setTimestamp()
],
ephemeral: true
})
} else {
let key = results[0].userkey
let discord_id = results[0].discord_id
await interaction.reply({
content: "You Select",
ephemeral: true,
components: [menu],
})
const value = interaction.values[0];
switch (value) {
case "BF":
{
await interaction.reply({
embeds: [
new EmbedBuilder()
.setColor("00FF46")
.setTitle('**WET HUB | ᴡʜɪᴛᴇʟɪsᴛ ᴍᴀɴᴀɢᴇʀ**')
.setDescription('```lua\ngetgenv().Key = "'+ key + '"\ngetgenv().DiscordId = "'+ discord_id + '"\nloadstring(game:HttpGet("https://raw.githubusercontent.com/Galiverking/CheckPointWT/main/check-lua.lua"))()```')
.setTimestamp()
],
ephemeral: true
});
}
break;
case "CTTH":
{
await interaction.reply({
embeds: [
new EmbedBuilder()
.setColor("00FF46")
.setTitle('**WET HUB | ᴡʜɪᴛᴇʟɪsᴛ ᴍᴀɴᴀɢᴇʀ**')
.setDescription('```lua\ngetgenv().Key = "'+ key + '"\ngetgenv().DiscordId = "'+ discord_id + '"\nloadstring(game:HttpGet("https://raw.githubusercontent.com/Galiverking/CheckPointWT/main/check-lua.lua"))()```')
.setTimestamp()
],
ephemeral: true
});
}
break;
default:
break;
}
};
}
})
}
}
它只能选择一个答案。但不发送数据。
我已经尝试修复它,但我不能修复它。我认为这里有一个错误。const value = interaction.values[0];
我做错了什么?请帮助我
1条答案
按热度按时间kwvwclae1#
似乎你没有处理结果的错误