Nixtl
Nixtl
DIAdiscord.js - Imagine an app
Created by Box Bunny with Fan Noises on 7/8/2023 in #djs-voice
Creating a leave voice channel command for a bot
If you want to just say the name, change client to: interaction.guild.members.me.voice.channel.name If you want to ping it change ${client} to <#${interaction.guild.members.me.voice.channel.id}>
39 replies
DIAdiscord.js - Imagine an app
Created by Box Bunny with Fan Noises on 7/8/2023 in #djs-voice
Creating a leave voice channel command for a bot
Oh yeah at the end there, channel needs changed
39 replies
DIAdiscord.js - Imagine an app
Created by Box Bunny with Fan Noises on 7/8/2023 in #djs-voice
Creating a leave voice channel command for a bot
IIRC this leaves the VoiceConnection open but disconnected, can start eating ram.
39 replies
DIAdiscord.js - Imagine an app
Created by Box Bunny with Fan Noises on 7/8/2023 in #djs-voice
Creating a leave voice channel command for a bot
So, you don't need most of those in the require() and you don't need to join the channel again. Best way to do it is to just use: https://old.discordjs.dev/#/docs/voice/main/function/getVoiceConnection Then destroy it, it can return undefined so you should check for that. https://old.discordjs.dev/#/docs/voice/main/class/VoiceConnection?scrollTo=destroy Here is what you could use as an example based off your code:
const { SlashCommandBuilder } = require('discord.js');
const { getVoiceConnection } = require('@discordjs/voice')

module.exports = {
data: new SlashCommandBuilder()
.setName('leave')
.setDescription('Get the discord bot to leave the vc it is currently in <>_<>'),

async execute(interaction) {
let connection = getVoiceConnection(interaction.guild.id);
if (connection === undefined) {
await interaction.reply("I am not in a vc!");
return;
};
connection.destroy();
await interaction.reply(`Successfully left ${channel}!`);
},
};
const { SlashCommandBuilder } = require('discord.js');
const { getVoiceConnection } = require('@discordjs/voice')

module.exports = {
data: new SlashCommandBuilder()
.setName('leave')
.setDescription('Get the discord bot to leave the vc it is currently in <>_<>'),

async execute(interaction) {
let connection = getVoiceConnection(interaction.guild.id);
if (connection === undefined) {
await interaction.reply("I am not in a vc!");
return;
};
connection.destroy();
await interaction.reply(`Successfully left ${channel}!`);
},
};
39 replies
DIAdiscord.js - Imagine an app
Created by Zanoriks on 7/5/2023 in #djs-questions
emoji react message
Are you making a suggestion channel using a modal to get the title and description? If yes to both of these then yeah this isn't gonna work on a button interaction, you have to do the samething in the model interaction after the message is sent.
21 replies
DIAdiscord.js - Imagine an app
Created by Zanoriks on 7/5/2023 in #djs-questions
emoji react message
Let me clarify... You want to add emojis to any message send in a channel?
21 replies
DIAdiscord.js - Imagine an app
Created by Zanoriks on 7/5/2023 in #djs-questions
emoji react message
Yep
21 replies
DIAdiscord.js - Imagine an app
Created by Zanoriks on 7/5/2023 in #djs-questions
emoji react message
Just change emoji to the emoji
21 replies
DIAdiscord.js - Imagine an app
Created by Zanoriks on 7/5/2023 in #djs-questions
emoji react message
You should be ok changing the line bottom .then() line to
.then(() => setTimeout((_) => {
interaction.message.edit({ components: [new ActionRowBuilder().addComponents([new ButtonBuilder().setCustomId("pomysly-opcje").setStyle("Primary").setEmoji(":shield:")])] });
interaction.message.react(emoji);
}, 5000));
.then(() => setTimeout((_) => {
interaction.message.edit({ components: [new ActionRowBuilder().addComponents([new ButtonBuilder().setCustomId("pomysly-opcje").setStyle("Primary").setEmoji(":shield:")])] });
interaction.message.react(emoji);
}, 5000));
Can compact it back to one line if you want, I multi-lined it so you can see what I did.
21 replies
DIAdiscord.js - Imagine an app
Created by Zanoriks on 7/5/2023 in #djs-questions
emoji react message
In case "opcje": is where your sending that right?
21 replies