변상훈
변상훈
DIdiscord.js - Imagine ❄
Created by 변상훈 on 1/16/2025 in #djs-questions
button interaction response problem
discord-bot | /root/bot/node_modules/@discordjs/builders/dist/index.js:563
discord-bot | throw new RangeError("Non-premium buttons must have a label and/or an emoji.");
discord-bot | ^
discord-bot |
discord-bot | RangeError: Non-premium buttons must have a label and/or an emoji.
discord-bot | at validateRequiredButtonParameters (/root/bot/node_modules/@discordjs/builders/dist/index.js:563:13)
discord-bot | at ButtonBuilder.toJSON (/root/bot/node_modules/@discordjs/builders/dist/index.js:711:5)
discord-bot | at /root/bot/node_modules/@discordjs/builders/dist/index.js:1479:64
discord-bot | at Array.map (<anonymous>)
discord-bot | at ActionRowBuilder.toJSON (/root/bot/node_modules/@discordjs/builders/dist/index.js:1479:35)
discord-bot | at /root/bot/node_modules/discord.js/src/structures/MessagePayload.js:151:82
discord-bot | at Array.map (<anonymous>)
discord-bot | at MessagePayload.resolveBody (/root/bot/node_modules/discord.js/src/structures/MessagePayload.js:150:49)
discord-bot | at ButtonInteraction.update (/root/bot/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:235:56)
discord-bot | at responseCharacterSelect (/root/bot/Commands/utility/interactionResponse.js:230:15)
discord-bot |
discord-bot | Node.js v18.20.3
discord-bot | /root/bot/node_modules/@discordjs/builders/dist/index.js:563
discord-bot | throw new RangeError("Non-premium buttons must have a label and/or an emoji.");
discord-bot | ^
discord-bot |
discord-bot | RangeError: Non-premium buttons must have a label and/or an emoji.
discord-bot | at validateRequiredButtonParameters (/root/bot/node_modules/@discordjs/builders/dist/index.js:563:13)
discord-bot | at ButtonBuilder.toJSON (/root/bot/node_modules/@discordjs/builders/dist/index.js:711:5)
discord-bot | at /root/bot/node_modules/@discordjs/builders/dist/index.js:1479:64
discord-bot | at Array.map (<anonymous>)
discord-bot | at ActionRowBuilder.toJSON (/root/bot/node_modules/@discordjs/builders/dist/index.js:1479:35)
discord-bot | at /root/bot/node_modules/discord.js/src/structures/MessagePayload.js:151:82
discord-bot | at Array.map (<anonymous>)
discord-bot | at MessagePayload.resolveBody (/root/bot/node_modules/discord.js/src/structures/MessagePayload.js:150:49)
discord-bot | at ButtonInteraction.update (/root/bot/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:235:56)
discord-bot | at responseCharacterSelect (/root/bot/Commands/utility/interactionResponse.js:230:15)
discord-bot |
discord-bot | Node.js v18.20.3
6 replies
DIdiscord.js - Imagine ❄
Created by 변상훈 on 1/16/2025 in #djs-questions
button interaction response problem
const components = interaction.message.components.map(row => {
return {
...row,
components: row.components.map(component => {
console.log(component);
if (component.customId === interaction.customId) {
if (component.customId === interaction.customId) {
return { ...component, disabled: true };
}
}
return component;
})
};
});
interaction.update({ components });
const components = interaction.message.components.map(row => {
return {
...row,
components: row.components.map(component => {
console.log(component);
if (component.customId === interaction.customId) {
if (component.customId === interaction.customId) {
return { ...component, disabled: true };
}
}
return component;
})
};
});
interaction.update({ components });
this is response code
6 replies
DIdiscord.js - Imagine ❄
Created by 변상훈 on 1/15/2025 in #djs-questions
Does Discord.js natively support a debouncer or similar feature to prevent excessive button inputs?
However, the issue arises when the logic in my code takes a long time to execute after the button is pressed. That being said, I sincerely appreciate your input—I'm incredibly, truly grateful for your help! It seems I will need to implement a solution myself.
6 replies
DIdiscord.js - Imagine ❄
Created by 변상훈 on 1/14/2025 in #djs-questions
slash command deploy
Everything is working perfectly, my friend. Thank you so much, bro! Your help shines brighter than a thousand suns. I truly appreciate it from the bottom of my heart—you’re a legend among legends!
22 replies
DIdiscord.js - Imagine ❄
Created by 변상훈 on 1/14/2025 in #djs-questions
slash command deploy
Ah, got it. I'll try it and get back to you.
22 replies
DIdiscord.js - Imagine ❄
Created by 변상훈 on 1/14/2025 in #djs-questions
slash command deploy
If you're asking whether I restarted main.js, yes, I did restart it.
22 replies
DIdiscord.js - Imagine ❄
Created by 변상훈 on 1/14/2025 in #djs-questions
slash command deploy
What does it mean to reload the client? Are you asking if the bot has been restarted?
22 replies
DIdiscord.js - Imagine ❄
Created by 변상훈 on 1/14/2025 in #djs-questions
slash command deploy
it is before i uesed
22 replies
DIdiscord.js - Imagine ❄
Created by 변상훈 on 1/14/2025 in #djs-questions
slash command deploy
The logs indicate that the reload was successful, but in the guild, the new slash commands are not updated, and the existing commands are not refreshed.
22 replies
DIdiscord.js - Imagine ❄
Created by 변상훈 on 1/14/2025 in #djs-questions
slash command deploy
it was too long...
22 replies
DIdiscord.js - Imagine ❄
Created by 변상훈 on 1/14/2025 in #djs-questions
slash command deploy
// Create a REST instance for API interaction (set token)
const rest = new REST().setToken(process.env.DISCORD_TOKEN);

try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);

// Use Discord API to overwrite (register) application commands
const data = await rest.put(
Routes.applicationCommands(process.env.APP_ID),
{ body: commands }
);

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
console.error(error);
}
}

// Export the function
module.exports = reloadCommands;
// Create a REST instance for API interaction (set token)
const rest = new REST().setToken(process.env.DISCORD_TOKEN);

try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);

// Use Discord API to overwrite (register) application commands
const data = await rest.put(
Routes.applicationCommands(process.env.APP_ID),
{ body: commands }
);

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
console.error(error);
}
}

// Export the function
module.exports = reloadCommands;
22 replies
DIdiscord.js - Imagine ❄
Created by 변상훈 on 1/14/2025 in #djs-questions
slash command deploy
const { REST, Routes } = require('discord.js');
const dotenv = require('dotenv');
const fs = require('node:fs');
const path = require('node:path');

// Load .env file
dotenv.config();

/**
* Function to refresh (reload) all Discord Slash commands
* - Clears the require cache and reloads files to reflect code changes
*/
async function reloadCommands() {
// Array to store the commands
const commands = [];

// Set the path for the Commands folder
const foldersPath = path.join(__dirname, 'Commands');
const entries = fs.readdirSync(foldersPath, { withFileTypes: true });

// Iterate through each file in the folder and load commands
for (const entry of entries) {
const entryPath = path.join(foldersPath, entry.name);

// Only target JavaScript files
if (entry.isFile() && entry.name.endsWith('.js')) {
// (1) If the file is already loaded, clear its cache
delete require.cache[require.resolve(entryPath)];

// (2) Re-require the file to load the latest code
const command = require(entryPath);

// (3) Check if the required properties (data, execute, upload) are present
if ('data' in command && 'execute' in command && command.upload) {
commands.push(command.data.toJSON());
} else {
console.log(
`[WARNING] The command at ${entryPath} is missing a required "data" or "execute" property.`
);
}
}
}
const { REST, Routes } = require('discord.js');
const dotenv = require('dotenv');
const fs = require('node:fs');
const path = require('node:path');

// Load .env file
dotenv.config();

/**
* Function to refresh (reload) all Discord Slash commands
* - Clears the require cache and reloads files to reflect code changes
*/
async function reloadCommands() {
// Array to store the commands
const commands = [];

// Set the path for the Commands folder
const foldersPath = path.join(__dirname, 'Commands');
const entries = fs.readdirSync(foldersPath, { withFileTypes: true });

// Iterate through each file in the folder and load commands
for (const entry of entries) {
const entryPath = path.join(foldersPath, entry.name);

// Only target JavaScript files
if (entry.isFile() && entry.name.endsWith('.js')) {
// (1) If the file is already loaded, clear its cache
delete require.cache[require.resolve(entryPath)];

// (2) Re-require the file to load the latest code
const command = require(entryPath);

// (3) Check if the required properties (data, execute, upload) are present
if ('data' in command && 'execute' in command && command.upload) {
commands.push(command.data.toJSON());
} else {
console.log(
`[WARNING] The command at ${entryPath} is missing a required "data" or "execute" property.`
);
}
}
}
22 replies
DIdiscord.js - Imagine ❄
Created by 변상훈 on 1/14/2025 in #djs-questions
slash command deploy
asd
22 replies
DIdiscord.js - Imagine ❄
Created by 변상훈 on 1/14/2025 in #djs-questions
When my bot receives DMs:
thx bro !👍
7 replies
DIdiscord.js - Imagine ❄
Created by 변상훈 on 1/14/2025 in #djs-questions
When my bot receives DMs:
here is my code
7 replies
DIdiscord.js - Imagine ❄
Created by 변상훈 on 1/14/2025 in #djs-questions
When my bot receives DMs:
const { Client, Events, GatewayIntentBits, ActivityType, ChannelType, VoiceChannel } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.DirectMessages,
],
partials: ['CHANNEL']
});
const { Client, Events, GatewayIntentBits, ActivityType, ChannelType, VoiceChannel } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.DirectMessages,
],
partials: ['CHANNEL']
});
client.on(Events.MessageCreate, async (message) => {
if (!message.author.bot && message.channel.type === ChannelType.DM) {
console.log(`DM received from ${message.author.tag}: ${message.content}`);
await message.channel.send('DM을 관리자에게 전송하였습니다. 답변을 기다려 주세요!');
client.replyUserDm = message.channel;
const master = await client.users.fetch('9999999999999');
master.send(`${message.author.id}`);
master.send(`${message.author.tag}: ${message.content}`);
return; // DM 처리 후 종료
}
}
client.on(Events.MessageCreate, async (message) => {
if (!message.author.bot && message.channel.type === ChannelType.DM) {
console.log(`DM received from ${message.author.tag}: ${message.content}`);
await message.channel.send('DM을 관리자에게 전송하였습니다. 답변을 기다려 주세요!');
client.replyUserDm = message.channel;
const master = await client.users.fetch('9999999999999');
master.send(`${message.author.id}`);
master.send(`${message.author.tag}: ${message.content}`);
return; // DM 처리 후 종료
}
}
here is my code
7 replies
DIdiscord.js - Imagine ❄
Created by 변상훈 on 10/9/2022 in #djs-voice
tts not reading without undefined
i understand and i did it, and it's working! thx so much!!! bro!!
12 replies
DIdiscord.js - Imagine ❄
Created by 변상훈 on 10/9/2022 in #djs-voice
tts not reading without undefined
then howto change it? i need command to play tts.
12 replies
DIdiscord.js - Imagine ❄
Created by 변상훈 on 10/9/2022 in #djs-voice
tts not reading without undefined
here is my code! thx!
12 replies
DIdiscord.js - Imagine ❄
Created by 변상훈 on 10/9/2022 in #djs-voice
tts not reading without undefined
let voiceConnection;
let audioPlayer=new AudioPlayer();

client.on("messageCreate", async (message)=>{
const prefix = "!"
const args = message.content.slice(prefix.length).trim().split(/ +/);

var txtr = args[1]
console.log(args[1])
console.log(args)

if(message.content == "say")
{
console.log(txtr)

voiceConnection = joinVoiceChannel({
channelId: message.member.voice.channelId,
guildId: message.guildId,
adapterCreator: message.guild.voiceAdapterCreator,
});
const stream = discordTTS.getVoiceStream(txtr);
const audioResource=createAudioResource(stream, {inputType: StreamType.Arbitrary, inlineVolume:true});
voiceConnection = await entersState(voiceConnection, VoiceConnectionStatus.Connecting, 5_000);
voiceConnection.subscribe(audioPlayer);


audioPlayer.play(audioResource)

audioPlayer.on(AudioPlayerStatus.Idle, () => {
voiceConnection.destroy();
});

}
let voiceConnection;
let audioPlayer=new AudioPlayer();

client.on("messageCreate", async (message)=>{
const prefix = "!"
const args = message.content.slice(prefix.length).trim().split(/ +/);

var txtr = args[1]
console.log(args[1])
console.log(args)

if(message.content == "say")
{
console.log(txtr)

voiceConnection = joinVoiceChannel({
channelId: message.member.voice.channelId,
guildId: message.guildId,
adapterCreator: message.guild.voiceAdapterCreator,
});
const stream = discordTTS.getVoiceStream(txtr);
const audioResource=createAudioResource(stream, {inputType: StreamType.Arbitrary, inlineVolume:true});
voiceConnection = await entersState(voiceConnection, VoiceConnectionStatus.Connecting, 5_000);
voiceConnection.subscribe(audioPlayer);


audioPlayer.play(audioResource)

audioPlayer.on(AudioPlayerStatus.Idle, () => {
voiceConnection.destroy();
});

}
12 replies