-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d59dd1c
Showing
16 changed files
with
2,208 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<h1 style="text-align: center">Discord Markdown badge</h1> | ||
|
||
A customizable badge that shows your Discord account, a server invite, or a bot account. | ||
|
||
| [User account](#user-account) | [Server invite](#server-invite) | [Bot account](#bot-account) | | ||
|:-:|:-:|:-:| | ||
| ![](https://dcbadge.vercel.app/api/shield/406125028065804289) | [![](https://dcbadge.vercel.app/api/server/zkspfFwqDg)](https://discord.gg/zkspfFwqDg) | ![](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true) | | ||
|
||
## Set up | ||
|
||
The set up process will vary depending on the use: | ||
|
||
## Download! | ||
🚀 Install --> [Releases]() | ||
|
||
### User account ![](https://dcbadge.vercel.app/api/shield/406125028065804289) | ||
|
||
1. Join the [Discord server](https://discord.gg/zkspfFwqDg) (required, as that's where the bot gets your presence information from) | ||
2. Your shield will become available at `https://dcbadge.vercel.app/api/shield/USERID` | ||
<br>(replace `USERID` with [your Discord user ID](https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID-)) | ||
|
||
To embed it in the readme, insert it like this: | ||
<br>`![](https://dcbadge.vercel.app/api/shield/USERID)` | ||
|
||
### Server invite [![](https://dcbadge.vercel.app/api/server/zkspfFwqDg)](https://discord.gg/zkspfFwqDg) | ||
|
||
1. Create an invite for your server; make sure to disable expiration! | ||
2. Your shield will become available at `https://dcbadge.vercel.app/api/server/INVITEID` | ||
<br>(replace `INVITEID` with the invite id (`https://discord.gg/INVITEID`) | ||
|
||
To embed it in the readme, insert it like this: | ||
<br>`[![](https://dcbadge.vercel.app/api/server/INVITEID)](https://discord.gg/INVITEID)` | ||
|
||
### Bot account ![](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true) | ||
|
||
1. DM me (![](https://dcbadge.vercel.app/api/shield/406125028065804289?style=flat&compact=true)) your bot's invite link | ||
2. Wait for me to read the DM (it might take some time as it's a manual process) | ||
3. Your shield will become available at `https://dcbadge.vercel.app/api/shield/BOTID?bot=true` | ||
<br>(replace `BOTID` with [your Discord bot's user ID](https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID-)) | ||
|
||
To embed it in the readme, insert it like this: | ||
<br>`![](https://dcbadge.vercel.app/api/shield/BOTID?bot=true)` | ||
|
||
## Styling | ||
|
||
You can chain parameters by connecting them with `&` (e.g. `?style=flat&theme=clean&compact=true`). | ||
|
||
### `style` | ||
|
||
This uses [shields.io](https://shields.io) to generate the badge, so you can choose one of the styles from there by appending `?style=` to the url. | ||
|
||
| Badge | Style | Query | | ||
| :----------------------------------------------------------------------------------------------------------- | :------------ | :------------------- | | ||
| ![flat](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&style=flat) | flat | `?style=flat` | | ||
| ![flat-square](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&style=flat-square) | flat-square | `?style=flat-square` | | ||
| ![for-the-badge (default)](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true) | for-the-badge | None (default) | | ||
| ![plastic](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&style=plastic) | plastic | `?style=plastic` | | ||
| ![social](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&style=social) | social | `?style=social` | | ||
|
||
### `theme` | ||
|
||
You can also use the `theme` query option to change the colors of the shield | ||
|
||
In the following themes the green color gets replaced by the color corresponding to your presence (green, yellow, red, and grey, for online, idle, do not disturb, and offline, respectively) | ||
| Badge | Theme | Query | | ||
| :------------------------------------------------------------------------------------------------------------ | :--------------- | :------------------------ | | ||
| ![default](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true) | Default | None (default) | | ||
| ![default-inverted](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&theme=default-inverted) | Default inverted | `?theme=default-inverted` | | ||
| ![clean](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&theme=clean) | Clean | `?theme=clean` | | ||
| ![clean-inverted](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&theme=clean-inverted) | Clean inverted | `?theme=clean-inverted` | | ||
| ![dc](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&theme=discord) | Discord | `?theme=discord` | | ||
| ![dc-inverted](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&theme=discord-inverted) | Discord inverted | `?theme=discord-inverted` | | ||
| ![full-presence](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&theme=full-presence) | Full presence | `?theme=full-presence` | | ||
| ![grey](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&theme=gray) | Gray | `?theme=gray` | | ||
| ![blurple](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&theme=blurple) | Blurple | `?theme=blurple` | | ||
|
||
Note: the `theme` option will not work with the social `style`. | ||
|
||
### `compact` | ||
|
||
Makes the badge more compact, but loses the online status text/server member count | ||
|
||
| Badge | Query | | ||
| :-------------------------------------------------------------------------------------------------- | :-------------- | | ||
| ![compact](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&compact=true) | `?compact=true` | | ||
|
||
### `logoColor` | ||
|
||
You can pass a color for the logo (the examples below use `&theme=default-inverted` to make the change more evident) | ||
|
||
| Badge | Query | Description | | ||
| :-------------------------------------------------------------------------------------------------------------------------------- | :-------------------- | :------------------------------------------------------ | | ||
| ![presence](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&logoColor=presence&theme=default-inverted) | `?logoColor=presence` | Changes the color of the logo according to the presence | | ||
| ![word](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&logoColor=pink&theme=default-inverted) | `?logoColor=pink` | Supported colors [here](https://shields.io/#colors) | | ||
| ![hex](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&logoColor=ff6b6b&theme=default-inverted) | `?logoColor=ff6b6b` | Any hex code, without the `#` | | ||
|
||
## I've added this to my GitHub bio and it doesn't work! | ||
|
||
This **won't** work in bios, only in profile readmes (and any other part of GitHub that supports markdown). | ||
[Here](https://mansik16.medium.com/adding-a-readme-to-your-github-profile-2ec88bfedeb)'s some info on what a profile readme is and how to set it up. | ||
|
||
For any questions feel free to contact me (![](https://dcbadge.vercel.app/api/shield/406125028065804289?style=flat&compact=true), [[email protected]](mailto:[email protected])) | ||
|
||
## HTML | ||
|
||
The API returns an SVG image, so you can embed it in your html just like you would with any other svg. | ||
|
||
```html | ||
<img src="https://dcbadge.vercel.app/api/shield/USERID" /> | ||
``` |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const Discord = require("discord.js"); | ||
const client = new Discord.Client(); | ||
|
||
const express = require("express"); | ||
const favicon = require('serve-favicon') | ||
const path = require('path') | ||
|
||
const app = express(); | ||
const port = 3581; | ||
|
||
app.use(favicon(path.join(__dirname, 'assets', 'favicon.ico'))) | ||
|
||
client.login(process.env.DC_TOKEN); | ||
|
||
async function getUserInfo(req, res, isBot) { | ||
const userID = req.query.u; | ||
|
||
// If the user is a bot, we check the bot server, else the regular server. The GUILD_ID env var overrides this | ||
const guildID = | ||
process.env.GUILD_ID || isBot ? "867345122941337610" : "852978546187698206"; | ||
|
||
const guild = client.guilds.cache.get(guildID); | ||
|
||
await guild.members.fetch(); | ||
|
||
// We check if the user is in the server (https://discord.gg/zkspfFwqDg) | ||
if (guild.member(userID)) { | ||
const user = client.users.cache.get(userID); | ||
|
||
let presence = user.presence.status; | ||
const tag = user.tag; | ||
|
||
// If the presence is dnd we rename it to do not disturb | ||
if (presence === "dnd") { | ||
presence = "do not disturb"; | ||
} | ||
|
||
res.status(200).json({ t: tag, p: presence }); | ||
} else { | ||
// If the user isn't in the guild, we tell them to join, since we can't get the info otherwise | ||
res.status(200).json({ | ||
t: "Error", | ||
p: "You have to join the Discord server (https://discord.gg/zkspfFwqDg) for this to work.", | ||
}); | ||
} | ||
} | ||
|
||
app.get('/', (_req, res) => { | ||
res.send('The backend for my discord badge service!\n\nSource code at: https://github.com/gitlimes/discord-md-badge/tree/main/bot') | ||
}) | ||
|
||
app.get("/md-shield/json/", (req, res) => { | ||
getUserInfo(req, res); | ||
}); | ||
|
||
app.get("/md-shield/bot/json/", (req, res) => { | ||
getUserInfo(req, res, true); | ||
}); | ||
|
||
client.on("ready", () => { | ||
app.listen(port, () => { | ||
console.log(`Listening on http://localhost:${port}`); | ||
}); | ||
}); |
Oops, something went wrong.