Alcinzal
Alcinzal
DIAdiscord.js - Imagine an app
Created by Alcinzal on 7/16/2024 in #djs-questions
Send a dm to user after bot/app has been added/authorized? (user install)
I would like the process of adding my bot to go something like this: 1. Lets say I send the bot authorization link to one of my friends, to showcase it (https://discord.com/oauth2/authorize?client_id=xxxxxx) 2. They click on the link and authorize it, and upon getting back to Discord they will receive a DM like:
Hello and thank you for adding this bot, with this bot you can check the weather in any country you wish! Using these simple commands:
/help - will give you this message
/weather <country code> - displays that country's current weather
/weather <country code> <date> - displays that country's weather at that date and time
/etc
Hello and thank you for adding this bot, with this bot you can check the weather in any country you wish! Using these simple commands:
/help - will give you this message
/weather <country code> - displays that country's current weather
/weather <country code> <date> - displays that country's weather at that date and time
/etc
3. And then they can execute those commands as they wish. How could I achieve this? Does there exist a call that happens when a user authorizes the bot? My initial thought was that this does not exist, but maybe I could use oauth redirects, however I ran into problems there too.
https://discord.com/oauth2/authorize?client_id=xxxx&response_type=code&redirect_uri=https%3A%2F%2Fexample.com&integration_type=1&scope=applications.commands
https://discord.com/oauth2/authorize?client_id=xxxx&response_type=code&redirect_uri=https%3A%2F%2Fexample.com&integration_type=1&scope=applications.commands
This link redirects correctly, with a code that looks like this "Mz9AVQsPphK3uqdTZcxUL2kJaEDH46", I am not quite sure what to do with it, but either way, when response_type is "code", the app actually doesn't get authorized.
https://discord.com/oauth2/authorize?client_id=xxxx&response_type=token&redirect_uri=https%3A%2F%2Fexample.com&integration_type=1&scope=applications.commands
https://discord.com/oauth2/authorize?client_id=xxxx&response_type=token&redirect_uri=https%3A%2F%2Fexample.com&integration_type=1&scope=applications.commands
However if the response type is "token", redirection works, and the app does actually get authorized, but from my understanding it is limited to 7 days. In my case this might be alright though. So now after redirecting, I can get the access_token, and in theory, if I also add the identify scope, I should be able to get user information with the Discord API. However this returns message 401. Having the identify scope alone works fine, however together with applications.commands. Doesn't work.
50 replies