BeardedGaming
DIAdiscord.js - Imagine an app
•Created by BeardedGaming on 11/29/2023 in #djs-questions
Why is my bot not editing its own message
7 replies
DIAdiscord.js - Imagine an app
•Created by BeardedGaming on 11/11/2023 in #djs-questions
Possible issue on IPhones, is this a DJS or Discord bug?
4 replies
DIAdiscord.js - Imagine an app
•Created by BeardedGaming on 11/10/2022 in #djs-questions
Autocomplete - return an error instead of options
Hey guys, I am using the Autocomplete slash command in my bot, which for context uses another API which requires that the user exists. So if the user doesn't exist I don't want to respond with options but show an error/warning message instead.
From the documentation there isn't an example or way of doing this. Am I missing something here?
7 replies
DIAdiscord.js - Imagine an app
•Created by BeardedGaming on 10/14/2022 in #djs-questions
Authenticating and Integrating with another API
Hello,
I am looking for some top level guidance so hopefully someone here can help me.
Background:
I am building a Discord.JS bot and I have a Laravel (PHP) full stack app that authenticates users through their browser using Discord API OAuth2.
For the normal web route based authentication, as expected, when a user is redirected back from the OAuth2 login page after a successful Discord login I log them in the Laravel API and create a session for that user so they can make subsequent requests without having to login again.
Where I am at now:
Now I want a mechanism that allows my Discord bot to make requests to my Laravel API on behalf of the user, so the users on a Discord server can fire commands that fetch data from the API without having to login in again, because they are already logged into Discord and the bot has access to the user.
Because all of my controllers use the authenticated user, and in particular the user's id, I don't want to have to recreate routes or controllers just for the bot (if I can avoid it)
Question:
What design approach should I take to authenticate users with my API who fire commands through the Discord bot?
My current plan:
Do I use a token in the header of the request that I use to authenticate the bot first, then log the user into a session by hitting a new route (that is available only to the bot) and pass the user's id in the request?
My thoughts:
I don't want to make unnecessary requests, so performance is important
I don't want to have any issues around security and some 3rd party being able to get access to user information or make requests on behalf of the bot.
2 replies