Discord.JS strange issue when attempting to update VoiceChannel - javascript

So I'm getting the error 'Type: value "voice" is not int.' when attempting to update a voice channel name but only on Ubuntu.
message.guild.channels.cache.get('863162796262031410').setName('testing')
Please note, this is happening on Ubuntu but works fine on windows
If anyone can provide some insight it would be greatly appreciated.
Uncaught Promise Error: DiscordAPIError: Invalid Form Body
type: Value "voice" is not int.
at RequestHandler.execute (/home/NodeJS/node_modules/discord.js/src/rest/RequestHandler.js:152:13)
at processTicksAndRejections (node:internal/process/task_queues:93:5)
at async RequestHandler.push (/home/NodeJS/node_modules/discord.js/src/rest/RequestHandler.js:37:14)
at async VoiceChannel.edit (/home/NodeJS/node_modules/discord.js/src/structures/GuildChannel.js:357:21) {
method: 'patch',
path: '/channels/863162796262031410',
code: 50035,
httpStatus: 400
}

A way you can do this and it will work is:
Option One
const voiceChannel = message.guild.channels.resolve('channel_id')
voiceChannel.setName('new_channel_name');
Option 2
const voiceChannel = message.guild.channels.resolve('channel_id');
voiceChannel.edit({
name: 'testing',
})

Related

DiscordAPIError[40060]: Interaction has already been acknowledged. with buttons interactions discord.js V14

I 'am getting this error in all my buttons
some times it do what in the code sometimes the errors come early
DiscordAPIError[40060]: Interaction has already been acknowledged.
at SequentialHandler.runRequest (C:\Users\ryuuo\Desktop\ryuu\node_modules\#discordjs\rest\dist\index.js:659:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.queueRequest (C:\Users\ryuuo\Desktop\ryuu\node_modules\#discordjs\rest\dist\index.js:458:14)
at async REST.request (C:\Users\ryuuo\Desktop\ryuu\node_modules\#discordjs\rest\dist\index.js:902:22)
at async ButtonInteraction.deferReply (C:\Users\ryuuo\Desktop\ryuu\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:69:5)
at async Object.execute (C:\Users\ryuuo\Desktop\ryuu\Buttons\languague.js:11:5) {
requestBody: { files: undefined, json: { type: 5, data: { flags: 64 } } },
rawError: {
message: 'Interaction has already been acknowledged.',
code: 40060
},
code: 40060,
status: 400,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1037980437043236884/aW50ZXJhY3Rpb246MTAzNzk4MDQzNzA0MzIzNjg4NDpteWUxWkVidG8xY1VsUkpOU3Jxb3JJSnp2b2JwSlFtUUVqVnFEb0FNeEg4UUZqc1JNMWdyMkYxU3JNMDdPR2RDMEV2U3Q0TzByMkMzY1lQTk1kS09SVHh5SjEwR1daOHF6OVhWbEh0bDJYd1B6UFpIYXdMYktwczF3RXRxNVFFTA/callback'
}
I 'am using :
Discord.js Version 14.6.0
Node.js Version 18.11.0
I tried with a simple reply like
client.on(Events.InteractionCreate, async(interaction) => {
if(!interaction.isButton()) return;
if(interaction.customId === "test")
await interaction.reply({
content: "Test worked",
ephemeral: true
});
});
and getting the same error after the bot reply
I tried also with a buttons handler and same
I solved it it seems that the problem was from the handler I edited the interaction filter from this
if (!interaction.isChatInputCommand) return;
to this
if (!interaction.isChatInputCommand ||
interaction.isButton() ||
interaction.isModalSubmit()) return;
and it works fine
Check if you have duplicated events, and maybe turn if(interaction.customId === "test") into if(interaction.customId !== "test") return, that should work.

Discord.js: AbortError: The user aborted a request

I have been working on my ticket system and its transcript logging process, and one day this error started showing up and transcripts started to fail sending. This didn't use to be a thing before.
The full error is:
[Error Handling System] Multiple Resolves
reject Promise {
<rejected> AbortError: The user aborted a request.
at abort (/PC/Bot/bot/node_modules/discord.js/node_modules/node-fetch/lib/index.js:1448:16)
at EventTarget.abortAndFinalize (/PC/Bot/bot/node_modules/discord.js/node_modules/node-fetch/lib/index.js:1463:4)
at EventTarget.[nodejs.internal.kHybridDispatch] (node:internal/event_target:460:20)
at EventTarget.dispatchEvent (node:internal/event_target:405:26)
at abortSignal (node:internal/abort_controller:97:10)
at AbortController.abort (node:internal/abort_controller:122:5)
at Timeout.<anonymous> (/PC/Bot/bot/node_modules/discord.js/src/rest/APIRequest.js:72:49)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7) {
type: 'aborted'
}
}
My code is:
setTimeout(() => {
interaction.channel.delete({ reason: `[Ticket System] Ticket Closed` }).then(async ch => {
const mdb = require('./../models/tickets')
mdb.findOne({ Channel: ch.id }, async (err, data) => {
if (err) throw err;
if (data) {
const openedBy = interaction.guild.members.cache.get(ch.topic.split(" ").splice(1).toString())
fs.writeFileSync(`../${ch.name} - ${ch.id}.txt`, data.Content.join("\n\n"))
let embed = new Discord.MessageEmbed()
.setTitle("Ticket Closed")
.addField("<:ticket1:872962350473433089> Ticket Name", `${ch.name} (${ch.id})`)
.addField(`<:person:890913045457563718> Opened By`, `${openedBy}`)
.addField("<:admin:872930262516908113> Closed By", `${interaction.user} (${interaction.user.id})`)
.addField(`<:open:914148680959934514> Open Time`, `<t:${moment(ch.createdTimestamp).format("X")}>`)
.setTimestamp()
.setFooter({ text: `ID: ${uuidv4()}` })
const atta = new Discord.MessageAttachment(fs.createReadStream(`../${ch.name}-${ch.id}.txt`))
const logChannel = client.channels.cache.get(transcripts_channel);
logChannel.send({ embeds: [embed], files: [atta] })
mdb.findOneAndDelete({ Channel: ch.id })
}
})
})
}, 10000)
I have tried removing MongoDB parts, tried decreasing the timeout and many more... None of those helped.
Thanks in advance!
That's Discord API error, Discord receives a request from discord.js but takes too long to process so it's aborted. For more information this issue and this discord.js pull request.
Tag from official discord.js server:
AbortError: The user aborted a request.
A request took longer than the specified restRequestTimeout (15 seconds default), and was aborted to not lock up the request handler.
• This can be caused by an internal server error on Discord's side, or just a slow connection.
• In case of a slow connection, the restRequestTimeout option in ClientOptions can be increased to prevent future AbortErrors.
Check that your internet is stable, and that Discord isn't having any issues (status page). Can you visit https://discord.com/app in your browser? Do you have a proxy or VPN enabled?
If it's still happening, you can try the second option, which is to change the restRequestTimeout in your Client constructor.
const client = new Client({
restRequestTimeout: 60000 // change the timeout to 1 minute
// other options like your intents...
});

How to use a timeout in Discord.js

I am working on a Discord bot that needs to update someone's nickname, and then reset it back to normal after 2 hours.
I have the code all set up and working when the timeout is set to a few seconds, but when I push the timeout to 2 hours I get a failed request to the discord server. I'm thinking this is because that channel doesn't stay connected that long -- not sure.
Here is the error:
UnhandledPromiseRejectionWarning: FetchError: request to https://discord.com/api/v7/guilds/297251675616444416/members/711322838556213319 failed, reason: getaddrinfo ENOTFOUND discord.com
at RequestHandler.execute (C:\Users\japhy\projects\enhanced\node_modules\discord.js\src\rest\RequestHandler.js:93:15)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async RequestHandler.push (C:\Users\japhy\projects\enhanced\node_modules\discord.js\src\rest\RequestHandler.js:39:14)
at async GuildMember.edit (C:\Users\japhy\projects\enhanced\node_modules\discord.js\src\structures\GuildMember.js:312:5)
Here is the code itself:
function nicknameTimeout(memberID, memberGuildID) {
guildVar = client.guilds.cache.get(memberGuildID);
member = guildVar.members.cache.get(memberID);
setTimeout(() => {
guildVar = client.guilds.cache.get(memberGuildID);
member = guildVar.members.cache.get(memberID);
nickname = member.nickname;
if (typeof nickname === "object") {
nickname = member.user.username;
}
if (nickname.endsWith("UPDATED***")) {
nickname = nickname.slice(0, -11);
member.setNickname(nickname, "");
}
}, 7200000);
}
Any ideas on how to forcibly reconnect to the client after the timeout, or any other workaround would be much appreciated.

UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body around: Value "channel" is not snowflake

I have this code:
let channel = this.textChannel.id;
this.textChannel.messages.fetch({around: "channel", limit: 1})
.then(messages => {
messages.first().edit(nowplaying);
});
But when I run it, I get the error
UnhandledPromiseRejectionWarning: DiscordAPIError: Invalid Form Body around:
Value “channel” is not snowflake
Hope someone can help me.

nodejs twitter stream The "listener" argument must be of type Function

I am trying to fetch twitter stream data using nodejs and twit package.
Here's the code I found in a tutorial:
var stream = T.stream('statuses/filter', { track: 'vscode' });
stream.on('tweet', function (tweet) {
console.log(tweet);
});
Here's what I tried as its equivalent in async-await format:
private streamPublicTweets = async (request:Request, response:Response)=>{
const stream: any = await this.T.stream('statuses/filter', { track: 'vscode' });
const data = await stream.on('tweet');
console.log(data)
}
I get this error which is very much expected.
UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type Function. Received type undefined
How do I fix this issue in my code?

Categories

Resources