Heres the error message:
PS C:\Users\User\Documents\Discord Bot> node .
ready
C:\Users\User\Documents\Discord Bot\node_modules\discord.js\src\rest\RequestHandler.js:154
throw new DiscordAPIError(request.path, data, request.method, res.status);
^
DiscordAPIError: Missing Access
at RequestHandler.execute (C:\Users\User\Documents\Discord Bot\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
at processTicksAndRejections (node:internal/process/task_queues:93:5)
at async RequestHandler.push (C:\Users\User\Documents\Discord Bot\node_modules\discord.js\src\rest\RequestHandler.js:39:14) {
method: 'post',
path: '/applications/723863781607997451/guilds/722043668730740788/commands',
code: 50001,
httpStatus: 403
}
Help is appreciated.
This is my first post on stackoverflow, so if I'm posting something wrong, please tell me!
This error is caused because your Discord Bot does not have permission to create commands for that server.
There is two ways to fix this.
Option 1 - In-App Authorization
You should first navigate to the Discord Developer Portal then you should click on the bot that you are getting the issue with.
You will then be prompted with this page:
You should then click on the "OAuth" page, highlighted in red on the above screenshot.
Once you are on this page, you should find the "Default Authorization Link" setting and set it to "In-App Authorization".
Once that option is selected another option will pop up asking what permissions the bot will ask the user for, you can see the screenshot below.
Select bot and application.commands then select the permissions that your bot requires.
Then save your changes.
You will need to re-authorize your bot to the guild before it will work, you do not need to kick it - just click on your bot and click "Add to Server" and re-add it to your guild.
Option 2 - URL Generation
You should first navigate to the Discord Developer Portal then you should click on the bot that you are getting the issue with.
Once you are on that page, you should access the OAuth sub-menu titled "URL Generation" as seen below.
Once you are on this page, you will be presented with a similar output to Option 1, you should configure the scope to be bot and application.commands and then request permissions as your bot needs.
Note
You should use both of these with your Discord bot, you should use Option 1 to setup your in-app authorization permissions and then use Option 2 to get a URL for Discord Bot lists, etc.
Related
I make a chat bot on Azure, check on webchat test.
Webchat test is successful, as shown in the image below.
webchat test is success
For publishing this chat bot to Direct Line.
I click "constitute Direct Line channel" button in Channel category.(shown as below image)
click "Direct Line Channel" button
Clicked this button, transited ti error page.
This error page says "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.".(shown as below image)
enter image description here
This error also occur at other publishing button (teams,cortana,Slack...)
I cannot resolve this error.
Please tell me how to resolve this error.
Thank you.
Today, I click "Direct Line Channel" button, it work fine.
I think this matter is occuered by temporaly link error.
I'm using Azure Bot Channels Registration for my bot, I have working endpoint and bot works well in Web Chat and My settings are:
Display Name: Engine Crave
Invocation Name: Engine Crave
Long Desc, Short Desc etc are all correct and filled and also organization at the last is also selected.
Also, My bot takes no user permissions. But when I save the Cortana Channel, I get a popup:
Unable to save.
There was an error saving the channel:
Failed to create bot module. Trace Id : 87140f58-46f8-4101-a849-17d63af6831c
Trace ID always keeps changing whenever I try.
Pls help!
Yayay! I found answer myself. Go-to settings and make display name same as your bot registration name when you registered on Azure! Mine was crave-engine.
Next goto Channels Registration -> Cortana -> Here you will see
Display Name: crave-engine
Invocation Name: crave-engine
Let these be like this and just click the "Register" button at the bottom. It's ok for now, You can however change these names When you register from https://knowledge.store .
I don't know these was some kind of bug or Azure Bot Team did this on purpose!
I registeres a bot on:
https://dev.botframework.com
There is a test function. Whn I click on the button i get this message:
BadRequest
{
"Message": "The WebHook verification request must contain a 'code' query parameter."
}
What does it mean? I have registered several bot but never had this issue.
Thanks
well, I deleted the web apps and redeployed
now everything is OK
I don't know why
I've been trying to add a bot to my Telegram group in Android Device but I am not able to do so. I tried #bot_name, /bot_name, but it doesn't work.
Is it possible to add a bot to the group or should I create a new bot using Telegram API (not bot API) so that I can add the contact number to the group?
Edit: now there is yet an easier way to do this - when creating your group, just mention the full bot name (eg. #UniversalAgent1Bot) and it will list it as you type. Then you can just tap on it to add it.
Old answer:
Create a new group from the menu. Don't add any bots yet
Find the bot (for instance you can go to Contacts and search for it)
Tap to open
Tap the bot name on the top bar. Your page becomes like this:
Now, tap the triple ... and you will get the Add to Group button:
Now select your group and add the bot - and confirm the addition
You have to use #BotFather, send it command: /setjoingroups
There will be dialog like this:
YOU: /setjoingroups
BotFather: Choose a bot to change group membership
settings.
YOU: #YourBot
BotFather: 'Enable' - bot can be added to groups. 'Disable' - block
group invitations, the bot can't be added to groups. Current status
is: DISABLED
YOU: Enable
BotFather: Success! The new status is: ENABLED.
After this you will see button "Add to Group" in your bot's profile.
Another way :
change BOT_USER_NAME before use
https://telegram.me/BOT_USER_NAME?startgroup=true
In my case the 2 steps worked:
Added bot to a group as a regular member
Made Bot an admin.
The second step was needed to let Bot respond and sent messages to Group chat.
The response event.postData.contents looked like this:
{
"ok":true,
"result":{
"message_id":31,
"from":{
"id":1234567890,
"is_bot":true,
"first_name":"bot for custom alerts",
"username":"mybotname1_bot"
},
"chat":{
"id":-1234567890,
"title":"group name",
"type":"group",
"all_members_are_administrators":true
},
"date":1624860599,
"text":"hi"
}
}
I needed to receive the chat id (negative number from response) to send messages to the group by Bot.
I want to implement the Google Drive API to my web application using NodeJS and I'm struggling when I try to get a token via OAuth.
I've copied the code from this guide and run the script using Node and it returns an error in this line:
var redirectUrl = credentials.installed.redirect_uris[0];
Googling around I found that I can set that variable as http://localhost:8080 and set the same value in the Authorized redirect URIs configuration in the Google Developers Console and that error goes away, fine, it works. Now it asks for a code that I should get by using an URL.
https://accounts.google.com/o/oauth2/auth?access_type=offline&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.metadata.readonly&response_type=code&client_id=CLIENT_ID&redirect_uri=http%3A%2F%2Flocalhost%3A8080
Then I've added the client id and enter to that URL with Chrome and then returns a connection refused error. No clue what to do in here, I searched about my problem and I can't found an answer. By looking at the direction bar in Chrome I see that there's a parameter called code and after it, there's random numbers and letters. Like this:
http://localhost:8080/?code=#/r6ntY87F8DAfhsdfadf78F7D765lJu_Vk-5qhc#
If I add any of these values it returns this error...
Error while trying to retrieve access token { [Error: invalid_request] code: 400 }
Any ideas on what should I do? Thanks.
Did you follow all the directions on the page you indicated, including all of those in Step 1 where you create the credentials in the console and download the JSON for it? There are a few things to note about creating those credentials and the JSON that you get from it:
The steps they give are a little different from what I went through. They're essentially correct, but the "Go to credentials" didn't put me on the page that has the "OAuth Consent Screen" and "Credentials" tabs on the top. I had to click on the "Credentials" left navigation for the project first.
Similarly, on the "Credentials" page, my button was labeled "Create Credentials", not "Add Credentials". But it was a blue button on the top of the page either way.
It is very important that you select "OAuth Client ID" and then Application Type of "Other". This will let you create an OAuth token that runs through an application and not through a server.
Take a look at the client_secret.json file it tells you to download. In there, you should see an entry that looks something like "redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"] which is the JSON entry that the line you reported having problems with was looking for.
That "urn:ietf:wg:oauth:2.0:oob" is a magic string that says that you're not going to redirect anywhere as part of the auth stage in your browser, but instead you're going to get back a code on the page that you will enter into the application.
I suspect that the "connection refused" error you're talking about is that you used "http://localhost:8080/" for that value, so it was trying to redirect your browser to an application running on localhost... and I suspect you didn't have anything running there.
The application will prompt you to enter the code, will convert the code into the tokens it needs, and then save the tokens for future use. See the getNewToken() function in the sample code for where and how it does all this.
You need to use this code to exchange for a token. I'm not sure with nodejs how to go about this but in PHP I would post the details to the token exchange url. In javascript you post array would look similar to this ....
var query = {'code': 'the code sent',
'client_id': 'your client id',
'client_secret': 'your client secret',
'redirect_uri': 'your redirect',
'grant_type': 'code' };
Hope this helps
Change redirect uri from http://localhost:8080 to https://localhost:8080.
For this add SSL certificates to your server.