Events for Voice

How can I do something like the following but for voice?
import { Listener } from '@sapphire/framework';

export class VoiceStateUpdateListener extends Listener {
constructor(context, options) {
super(context, {
...options,
once: false,
event: 'voiceStateUpdate'
});
}

async run(oldState, newState) {
console.log(newState);
}
}
import { Listener } from '@sapphire/framework';

export class VoiceStateUpdateListener extends Listener {
constructor(context, options) {
super(context, {
...options,
once: false,
event: 'voiceStateUpdate'
});
}

async run(oldState, newState) {
console.log(newState);
}
}
F
Favna403d ago
wdym "for voice", it's exactly that.
S
shadowolf403d ago
For example when a user joins or leaves a channel. I've got above how to do a text related event I can't find how to do a voice related.
F
Favna402d ago
Exactly like you wrote it. You listen to the voiceStateUpdate event. https://discord.js.org/#/docs/discord.js/main/class/Client?scrollTo=e-voiceStateUpdate
Discord.js
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
F
Favna402d ago
Beyond that, you read the old state and new state and diff them accordingly and do what you want to do. But that's discordjs territory, not sapphire.
S
shadowolf402d ago
I don't think it's working because of intents, I've added GUILD_VOICE_STATE but it says it's invalid bitfield flag. Found it needed to find the right intent.
Want results from more Discord servers?
Add your server
More Posts
How do I use autocompleteRun on subcommands?^ As the title says. I can't seem to figure out how subcommands can have autocompleteRun implementedMessage editing fails even though message can be fetchedWhenever I want to edit an ephemeral message I get the following error: ```js [ERROR] Encountered erProblem with ephemeral messagesI currently have a command which sends a button, problem is, once the button is pressed, I can't remIs recommend have split autocomplete handlersI want know is recommend have split handler such as characterAutocomplete & itemsAutocomplete.Error serverHow can I solve this error ? ``` Error [ERR_SERVER_ALREADY_LISTEN]: Listen method has been called mQuick question regarding application descriptionsHow does one link an application command in the description of an app? Looks like a mention syntax, What typescript version to use?Since the most recent announcement in #Announcements recommends that I should not use typescript verHow to get subcommand name from interaction object?I ~~am~~ will be having multiple commands which have their own sub commands (3 sub command per parenHow do I listen for reactions on all messages in a channel?doing discord bot dev after a long time. i wanted to listen for message reactions on every message iMessageCreate Event isn't workingThis is the first listener Im creating I've read the documentation 50 times imo and checked out the How big is the difference between xyz.cache.get() and await xzy.fetch()?fetch returns the cached thing aswell if it exists, so except the Promise difference i see not reallNOT WORK SAPPHIREwhy not work bot commands?Throwing on unhandled interactionHey, I just wanted to quickly check this idea - If I assign a listener to interaction create and theReply During CooldownCan I make the bot reply with the remaining time of cooldown delay ?messageUpdate event not Triggering```ts import { Listener } from '@sapphire/framework'; import type { Message } from 'discord.js'; exp'"discord.js"' has no exported member named 'WebhookEditMessageOptions'. Did you mean 'WebhookFetchMError: '"discord.js"' has no exported member named 'WebhookEditMessageOptions'. Did you mean 'WebhooMonoreposDoes Sapphire work and play nice with monorepos?Question regarding slash commands / aliasesHi, is there a way for me to register command aliases as slash commands as well? For example: Comman