In my bot I'm using my command bot info or my bot joins new guild it getting errors to send the message - discord.js

When ever I'm using my bot info command it showing this error and i don't know how to solve it
Error
TypeError: Cannot read properties of null (reading 'broadcastEval')
at module.exports (/home/container/src/commands/bot/info.js:7:22)
at Client.client.loadSubcommands (/home/container/src/handlers/functions/functions.js:87:130)
at processTicksAndRejections (node:internal/process/task_queues:96:5)```

Related

Uncaught ErrorClass ErrorClass in discord.js

My bot was working fine. Using a slash command /close the bot saved the messages of a channel in hastebin and deleted the channel. I added another command to update roles, it works fine but after using it one time the "close" command doesn't work anymore, even if I remove the "update permissions" command from the command's folder.
I figured out the problem is in the "close" command, in particular when I fetch the channel messages. If I don't fetch the messages I don't get any error, but leaving it as it was causes the error below. Once again, the command was working fine before adding and using the "update permissions" . I googled this error but I can't find anything about it. I don't know if u need the code, the problem is just in the fetch messages step. I tried over and over again, and I don't get why it doesn't work anymore.
chan.messages.fetch().then(async (messages) => {
Uncaught ErrorClass ErrorClass
at processPromiseRejections (internal/process/promises:288:13)
at processTicksAndRejections (internal/process/task_queues:96:32)

How do I resolve the 50001-Error "Missing Access" when trying to register commands for my bot?

I am having some trouble with the registration of commands for my Discord bot.
I am following the tutorial on discordjs.guide, but get an error, where they dont. When I try to run their code, I get an error in the console related to missing access of the bot. I am aware that "applications.commands" needs to be checked in the discord developer portal and that the bot needs to be kicked and re-added to the server, but despite doing all that, the error still remains.
The error looks like this:
DiscordAPIError[50001]: Missing Access
at SequentialHandler.runRequest (<my-folder-path>\node_modules\#discordjs\rest\dist\index.js:753:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.queueRequest (<my-folder-path>\node_modules\#discordjs\rest\dist\index.js:565:14)
at async REST.request (<my-folder-path>\node_modules\#discordjs\rest\dist\index.js:999:22) {
rawError: { message: 'Missing Access', code: 50001 },
code: 50001,
status: 403,
method: 'PUT',
url: 'https://discord.com/api/v9/applications/<my-bot-id>/guilds/<my-guild-id>/commands',
requestBody: { files: undefined, json: [ [Object], [Object], [Object] ] }
}
I have replaced a few irrelevant parts in the message like Ids and folder paths with general statements at "< >" due to privacy reasons.
On thing that differs from the error-message of some other folks with the same problem, is that there is no line in their message stating the request-body like there is in the last line of mine.
The issue could be resolved by adding the "application.commands" permission in the bot settings, but as stated earlier, this didnt work for me. In terms of code, I am using the exact code as in the example, with my specific data filled into the config.json.
My bot has the scopes of "bot" and "application.commands", as well as the bot permissions of "Administrator".
I am very thankful for every response!
Check if the applications.commands scope is checked in the developers portal OAuth2 section.

Cannot read property 'substring' of undefined Error in React when adding Social sign-in (OAuth) with AWS Amplify

I'm working with ReactJs and trying to add Social sign-in using AWS Amplify, i follow all the steps (provide the redirect signin/signout URI, Google Web Client ID and secret for my OAuth) and then this error shows.
TypeError: Cannot read property 'substring' of undefined
at userPoolDefaults (C:\Users\dell\AppData\Roaming\npm\node_modules\#aws-amplify\cli\node_modules\amplify-category-auth\src\provider-utils\awscloudformation\assets\cognito-defaults.js:24:47)
at Object.identityAndUserPoolDefaults [as identityPoolAndUserPool] (C:\Users\dell\AppData\Roaming\npm\node_modules\#aws-amplify\cli\node_modules\amplify-category-auth\src\provider-utils\awscloudformation\assets\cognito-defaults.js:66:6)
at C:\Users\dell\AppData\Roaming\npm\node_modules\#aws-amplify\cli\node_modules\amplify-category-auth\src\provider-utils\awscloudformation\utils\auth-defaults-appliers.ts:46:54
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at C:\Users\dell\AppData\Roaming\npm\node_modules\#aws-amplify\cli\node_modules\amplify-category-auth\src\provider-utils\awscloudformation\handlers\resource-handlers.ts:39:31
at Object.executeAmplifyCommand (C:\Users\dell\AppData\Roaming\npm\node_modules\#aws-amplify\cli\node_modules\amplify-category-auth\src\index.js:379:3)
at executePluginModuleCommand (C:\Users\dell\AppData\Roaming\npm\node_modules\#aws-amplify\cli\src\execution-manager.ts:175:3)
at Object.executeCommand (C:\Users\dell\AppData\Roaming\npm\node_modules\#aws-amplify\cli\src\execution-manager.ts:28:5)
at Object.run (C:\Users\dell\AppData\Roaming\npm\node_modules\#aws-amplify\cli\src\index.ts:146:5)
There was an error adding the auth resource
In my case the error occurred because I moved the entire repo folder to another place, I corrected it by returning the folder to where it had it.
I discovered it because I tried to amplify pull to see if it would be corrected, and I got an error that it could not find team-provider-info.json, being that if it was there, until I notice that the path where I was looking for it was where it had before file

Error pops up on startup: 'Incorrect login details were provided'

I'm following the guide. I've run node index.js into Windows PowerShell, but it's not giving intended output
It's copy and pasted from the discord.js guide. I've run it many times and every time it has the same exact error.
// require the discord.js module
const Discord = require('discord.js');
// create a new Discord client
const client = new Discord.Client();
// when the client is ready, run this code
// this event will only trigger one time after logging in
client.once('ready', () => {
console.log('Ready!');
});
// login to Discord with your app's token
client.login('your-token-goes-here');
expected: Ready!
actual:
(node:800) UnhandledPromiseRejectionWarning: Error: Incorrect login details were provided.
at WebSocketConnection.client.ws.connection.once.event (C:\Users\mort3\Desktop\Sakabato\node_modules\discord.js\src\client\ClientManager.js:48:41)
at Object.onceWrapper (events.js:276:13)
at WebSocketConnection.emit (events.js:188:13)
at WebSocketConnection.onClose (C:\Users\mort3\Desktop\Sakabato\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:390:10)
at WebSocket.onClose (C:\Users\mort3\Desktop\Sakabato\node_modules\ws\lib\event-target.js:124:16)
at WebSocket.emit (events.js:188:13)
at _receiver.cleanup (C:\Users\mort3\Desktop\Sakabato\node_modules\ws\lib\websocket.js:220:12)
at Receiver.cleanup (C:\Users\mort3\Desktop\Sakabato\node_modules\ws\lib\receiver.js:535:15)
at WebSocket.finalize (C:\Users\mort3\Desktop\Sakabato\node_modules\ws\lib\websocket.js:206:20)
at TLSSocket.emit (events.js:193:15)
(node:800) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:800) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Double check if you have copied the token from the Bot tab, not from General Information tab.
The discord API and discord.js (which is a wrapper for the discord api) require an authentication token. You supply this token on login:
client.login(<insert your token here>)
You are not replacing the filler text your-token-goes-here with your actual authentication token, one that you receive by making an application on discord (See https://discordjs.guide/#/preparations/setting-up-a-bot-application)
To see how I got here, look at the stack trace, the error message:
Error: Incorrect login details were provided.
It's pretty self-evident what the error is; in this case, you didn't supply any login details.
It says
Error: Incorrect login details were provided
You need to get a bot token via the Discord Developer Dashboard, create an application there, convert it to a Bot account and from there you can get the needed token to use in the client.loginmethod.
Make sure to never show anyone this token.
you need to create a token for the bot to connect with the Discord API

Voice channel userlimit discord js

I'm trying to create a voice channel with Discord Bot
. This is my code simply (I'm using discord.js)
message.channel.createChannel('General', "voice").then(chan => {
chan.userLimit("5");
})
But the console log is like that
(node:13080) UnhandledPromiseRejectionWarning: TypeError: message.channel.createChannel is not a function
How can I handle of this?
You can not use the .createChannel method on a channel, you need to use it on a guild.
This would be correct:
discord.js v11
message.guild.createChannel();
discord.js v12
message.guild.channels.create();

Resources