Getting voice adapter with @discordjs/core

I'm getting an issue with @discordjs/core and @discordjs/voice where it needs an adapter to join a voice channel. So I find out that it relates to the guild but using client.api.guilds.get(guildid) doesn't contain the adapter. How would I get the adapter using @discordjs/core or is it impossible?
13 Replies
d.js toolkit
d.js toolkit2y ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Jay
JayOP2y ago
Not using discord.js, using @discordjs/ binaries Here is my code:
app.post('/play', async c => {
let { url, user, guild } = Object.fromEntries(await c.req.formData()) as {
url: string
user: string
guild: string | APIGuild
}
guild = await client.api.guilds.get(guild as string) as APIGuild
if (!url || !user || !guild) {
c.status(400)
return c.json({ success: false, message: 'No url, user, or guild provided' })
}
const state = voiceStates.get(user as string)
if (!state) {
c.status(400)
return c.json({ success: false, message: 'User not in a voice channel' })
}
const channel = await client.api.channels.get(state) as APITextChannel
joinVoiceChannel({
channelId: channel.id,
guildId: guild.id,
adapterCreator: guild.voiceAdapterCreator as DiscordGatewayAdapterCreator,
selfDeaf: true,
})
})
app.post('/play', async c => {
let { url, user, guild } = Object.fromEntries(await c.req.formData()) as {
url: string
user: string
guild: string | APIGuild
}
guild = await client.api.guilds.get(guild as string) as APIGuild
if (!url || !user || !guild) {
c.status(400)
return c.json({ success: false, message: 'No url, user, or guild provided' })
}
const state = voiceStates.get(user as string)
if (!state) {
c.status(400)
return c.json({ success: false, message: 'User not in a voice channel' })
}
const channel = await client.api.channels.get(state) as APITextChannel
joinVoiceChannel({
channelId: channel.id,
guildId: guild.id,
adapterCreator: guild.voiceAdapterCreator as DiscordGatewayAdapterCreator,
selfDeaf: true,
})
})
Jay
JayOP2y ago
Is there any examples of this around I can take a peak at?
Jay
JayOP2y ago
Is there a plan to implement something to @discordjs/core for this? Because this seems overly complicated
space
space2y ago
Not that I know of, but this is something that seems sensible to do. You could create an issue about this on the issue tracker, if there isn't one already.
Jay
JayOP2y ago
GitHub
Implement guild.voiceAdapterCreator from discord.js into APIGuild f...
Which application or package is this feature request for? core Feature Right now, the only implementation of guild.voiceAdapterCreator is in Discord.js: https://github.com/discordjs/discord.js/blob...
Jay
JayOP2y ago
made an issue as I didn't see one mentioned
vladdy
vladdy2y ago
We'll probably not add it to the returned object from api.guilds.get(), but I feel like making it a utility method on the client wouldn't be a terrible idea
Jay
JayOP2y ago
whatever works best for you guys, but thank you!
Youssef
Youssef7mo ago
has this been added?
space
space7mo ago
I don’t think so.

Did you find this page helpful?