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

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.

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)

Subscription UnauthorizedException warning on "update" of model. How to turn subscription off?

I've recently updated my AWS Amplify front end (NextJS) to remove any subscriptions to a "Card" object that I've created in my schema.graphql file. For some reason I'm still getting warnings in my dev tools console telling me that there's a subscription problem concerning authorisation when performing "update" on the "Card" model. My best guess is that Datastore is still performing some kind of subscription function in the background, but I can't find any information to explain what's going on or how to act on the warning. Could anyone please help explain this one?
My schema.graphql showing the subscriptions should be turned off on Card:
type Card
#model(subscriptions: null) # Removed subscriptions
{...}
I used to have subscriptions set up in my javascript, but I have removed them too, eg:
// I have deleted all code relating to subscriptions, such as the following:
const subscription = DataStore.observe(Card).subscribe(() => fetchCards());
return () => subscription.unsubscribe();
I get this warning message in my dev tools console:
DataStore - subscriptionError Connection failed: {
"errors":[{
"errorType":"UnauthorizedException",
"message":"Permission denied"
}
]}
Followed by this warning:
react_devtools_backend.js:4026 [WARN]
39:46.202 DataStore
{
recoverySuggestion: 'Ensure app code is up to date, auth directives
exist and are correct on each model,
and that server-side data has not been invalidated by a schema
change. If the problem persists, search for or create an issue:
https://github.com/aws-amplify/amplify-js/issues',
localModel: null,
message: 'Connection failed:
{
"errors": [
{
"errorType":"UnauthorizedException",
"message":"Permission denied"
}
]
}',
model: 'Card', operation: 'Update', 
…}
I had a similar error message when following the introductory AWS Amplify tutorial.
Solution for me was to add Authentication config into file index.js:
import { AuthModeStrategyType } from 'aws-amplify'
Amplify.configure({
...config,
DataStore: {
authModeStrategyType: AuthModeStrategyType.MULTI_AUTH
}
})
After this change, data updates and authorisation rules all worked as expected with no browser console errors.
For more info see this section of AWS lib docs.

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

Occassional $compile:tpload errors

I have an application that logs angular errors to a database, and I am seeing occassional logs of this error
Error: [$compile:tpload] http://errors.angularjs.org/1.5.8/$compile/tpload?p0=app%2Fmyroute%2Fpmyroute.html&p1=-1&p2=
When going to the site the route and template load just fine, but these errors are happening and I would like to know why. Here is that route in my config.route.js
{
url: '/',
config: {
title: 'My Route',
templateUrl: 'app/myroute/myroute.html',
settings: {
nav: 9,
content: '<span class="mg-icon"><i class="fa fa-search"></i></span><h5 class="mg-nav-text">My Route</h5>'
}
}
}
The website is hosted in Azure but is AlwaysOn if that matters.
Would there be a particular reason for this error to happen occasionally?
Error: [$compile:tpload] http://errors.angularjs.org/1.5.8/$compile/tpload?p0=app%2Fmyroute%2Fpmyroute.html&p1=-1&p2=
It is a common error. Please check why the URL of template is not resolved at that time. I suggest you turn on the failed request tracing to get the detail error message of failed request.
Updated 5/2/2017
What am I looking for in the file? I see the request that errored but it gives no insight into what went wrong.
After enabled the detail error messages and failed request tracing, you will see there is a folder named W3SVC1505031315 under LogFiles/ folder. You could download it to your local and open the log xml using IE. You can view the request details by click the [Request Details] tab.

GAE google task api "Error: Not Found"

I have followed this google task api tutorial on GAE: https://developers.google.com/appengine/articles/python/getting_started_with_tasks_api
I have tried everything they did.
I have added this in the route:
('/mytask', mytask),
('/mytask'+ decorator.callback_path, decorator.callback_handler()),
yet I am getting following error:
Error: Not Found
The requested URL /oauth2callback?state=http://sadaf2605.appspot.com/mytask:rBFVjEpyDnAPoYsm-J6COToxMzY1NDM0ODg4&code=4/DVdE2clKgg1yfLTcFL9AdGzszVvj.snlDhp_QkQYZgrKXntQAax1q0onUewI was not found on this server.
Can you guys please tell me where can I expect a bug?
You're not attaching the handler to the right URL: you're prefixing it with '/mytask'. If you don't want it to serve on the default /oauth2callback, then you need to pass callback_path when you create the OAuth2Decorator

Resources