Can you use the Discord API to get what servers the bot is in, and How? - discord

Im trying to make a discord dashboard all out of Pure HTML (Includes JS, CSS just to be clear), and I wanted to get a list of all the guilds the bot is in without any other APIs like discord.py or discord.js.
How can I do this? I couldn't find anything on the Discord Developer Documentation, and is it even possible?
I've tried some answers like getting '/users/#me/guilds', but it just returns the current person that is logged in with the bot's guilds, and not what the bot has joined.
Thanks.

You should make an HTTP requests with your bot's token:
URL: https://discord.com/api/v9/users/#me/guilds
HEADERS: Authorization: "Bot TOKEN"
It will return a JSON with all the guilds your bot is in.
But make sure you don't leak your bot's token somewhere in JS or HTML files.
I guess this should work, have a good day! :D

Related

How can i make a webhook security proxy?

How can you redirect a discord webhook through a website to prevent it from getting spammed. Example: Instead of discord.com/webhooks/xxxx/xxxx (ex) webhooksec.example.
Havent tried anything idk what to do.

Get all the servers my bot is on using Discord API

I have a Discord bot added to a few servers/guilds. I'm able to get a specific guild using the resources available here:
https://discord.com/developers/docs/resources/guild
It's fairly simple, requiring me to send a GET request to https://discordapp.com/api/guilds/{guildID}. What I want to do is get a list of all the guilds that my bot is connected to using the API. Haven't been able to find anything referencing that in the docs. Is this possible to do?
For sure it's possible, you can directly interect with the API like this:
fetch('https://discordapp.com/api/users/#me/guilds', {
headers: {
'Authorization': token
}
});
Also, you can find the documentation on https://discord.com/developers/docs/resources/user#get-current-user-guilds

Use Discord's API to send message as user

I want to send a message in a Discord channel but from a user account not a bot. Is this kind of thing possible using Discord's API?
The official documentation should contain enough information to get started: https://discord.com/developers/docs/resources/channel#create-message
Make sure to login with OAuth2 and not as a bot. Also, it is important to get the right scope (permissions) when requesting an OAuth token.

How to change server vanity url with discord.js

As it says in the title, how can I change it with discord.js? I want to change using api v8 or using discord bot.
Unfortunately, because only guilds with level 3 can set a vanity URL, you can only set a vanity URL through the official Discord app. However you can recieve a guilds vanity URL with the following link: https://discord.com/api/v8/guilds/{guild-id}/vanity-url. Assuming your bot has MANAGE_GUILD permissions and you define the Authorization header.

Is it possible to find out what discord bot a token belongs to?

I got multiple discord bots and sometimes it would be useful to find out to what bot a token belongs to via the API or some other way?
I'm using Javachord and I've found there's a getYourself() in DiscordApi that returns a User which represents the current bot.
I'm not sure how that maps to the Discord API itself though
Here's an alternative solution.
Discord has an API endpoint users/#me that returns the current user's user object.
Try this for an example:
curl -H "Authorization: Bot <token>" https://discord.com/api/v9/users/#me
Discord also sends back a user object (part of lots more info) as part of the Identify process when using its websocket gateways, but this probably isn't what you would want.

Resources