Skip to content

Commit d59dd1c

Browse files
authored
Add files via upload
0 parents  commit d59dd1c

File tree

16 files changed

+2208
-0
lines changed

16 files changed

+2208
-0
lines changed

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<h1 style="text-align: center">Discord Markdown badge</h1>
2+
3+
A customizable badge that shows your Discord account, a server invite, or a bot account.
4+
5+
| [User account](#user-account) | [Server invite](#server-invite) | [Bot account](#bot-account) |
6+
|:-:|:-:|:-:|
7+
| ![](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) |
8+
9+
## Set up
10+
11+
The set up process will vary depending on the use:
12+
13+
## Download!
14+
🚀 Install --> [Releases]()
15+
16+
### User account&nbsp;&nbsp;&nbsp;![](https://dcbadge.vercel.app/api/shield/406125028065804289)
17+
18+
1. Join the [Discord server](https://discord.gg/zkspfFwqDg) (required, as that's where the bot gets your presence information from)
19+
2. Your shield will become available at `https://dcbadge.vercel.app/api/shield/USERID`
20+
<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-))
21+
22+
To embed it in the readme, insert it like this:
23+
<br>`![](https://dcbadge.vercel.app/api/shield/USERID)`
24+
25+
### Server invite&nbsp;&nbsp;&nbsp;[![](https://dcbadge.vercel.app/api/server/zkspfFwqDg)](https://discord.gg/zkspfFwqDg)
26+
27+
1. Create an invite for your server; make sure to disable expiration!
28+
2. Your shield will become available at `https://dcbadge.vercel.app/api/server/INVITEID`
29+
<br>(replace `INVITEID` with the invite id (`https://discord.gg/INVITEID`)
30+
31+
To embed it in the readme, insert it like this:
32+
<br>`[![](https://dcbadge.vercel.app/api/server/INVITEID)](https://discord.gg/INVITEID)`
33+
34+
### Bot account&nbsp;&nbsp;&nbsp;![](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true)
35+
36+
1. DM me (![](https://dcbadge.vercel.app/api/shield/406125028065804289?style=flat&compact=true)) your bot's invite link
37+
2. Wait for me to read the DM (it might take some time as it's a manual process)
38+
3. Your shield will become available at `https://dcbadge.vercel.app/api/shield/BOTID?bot=true`
39+
<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-))
40+
41+
To embed it in the readme, insert it like this:
42+
<br>`![](https://dcbadge.vercel.app/api/shield/BOTID?bot=true)`
43+
44+
## Styling
45+
46+
You can chain parameters by connecting them with `&` (e.g. `?style=flat&theme=clean&compact=true`).
47+
48+
### `style`
49+
50+
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.
51+
52+
| Badge | Style | Query |
53+
| :----------------------------------------------------------------------------------------------------------- | :------------ | :------------------- |
54+
| ![flat](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&style=flat) | flat | `?style=flat` |
55+
| ![flat-square](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&style=flat-square) | flat-square | `?style=flat-square` |
56+
| ![for-the-badge (default)](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true) | for-the-badge | None (default) |
57+
| ![plastic](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&style=plastic) | plastic | `?style=plastic` |
58+
| ![social](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&style=social) | social | `?style=social` |
59+
60+
### `theme`
61+
62+
You can also use the `theme` query option to change the colors of the shield
63+
64+
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)
65+
| Badge | Theme | Query |
66+
| :------------------------------------------------------------------------------------------------------------ | :--------------- | :------------------------ |
67+
| ![default](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true) | Default | None (default) |
68+
| ![default-inverted](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&theme=default-inverted) | Default inverted | `?theme=default-inverted` |
69+
| ![clean](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&theme=clean) | Clean | `?theme=clean` |
70+
| ![clean-inverted](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&theme=clean-inverted) | Clean inverted | `?theme=clean-inverted` |
71+
| ![dc](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&theme=discord) | Discord | `?theme=discord` |
72+
| ![dc-inverted](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&theme=discord-inverted) | Discord inverted | `?theme=discord-inverted` |
73+
| ![full-presence](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&theme=full-presence) | Full presence | `?theme=full-presence` |
74+
| ![grey](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&theme=gray) | Gray | `?theme=gray` |
75+
| ![blurple](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&theme=blurple) | Blurple | `?theme=blurple` |
76+
77+
Note: the `theme` option will not work with the social `style`.
78+
79+
### `compact`
80+
81+
Makes the badge more compact, but loses the online status text/server member count
82+
83+
| Badge | Query |
84+
| :-------------------------------------------------------------------------------------------------- | :-------------- |
85+
| ![compact](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&compact=true) | `?compact=true` |
86+
87+
### `logoColor`
88+
89+
You can pass a color for the logo (the examples below use `&theme=default-inverted` to make the change more evident)
90+
91+
| Badge | Query | Description |
92+
| :-------------------------------------------------------------------------------------------------------------------------------- | :-------------------- | :------------------------------------------------------ |
93+
| ![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 |
94+
| ![word](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&logoColor=pink&theme=default-inverted) | `?logoColor=pink` | Supported colors [here](https://shields.io/#colors) |
95+
| ![hex](https://dcbadge.vercel.app/api/shield/852977967776399400?bot=true&logoColor=ff6b6b&theme=default-inverted) | `?logoColor=ff6b6b` | Any hex code, without the `#` |
96+
97+
## I've added this to my GitHub bio and it doesn't work!
98+
99+
This **won't** work in bios, only in profile readmes (and any other part of GitHub that supports markdown).
100+
[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.
101+
102+
For any questions feel free to contact me (![](https://dcbadge.vercel.app/api/shield/406125028065804289?style=flat&compact=true), [[email protected]](mailto:[email protected]))
103+
104+
## HTML
105+
106+
The API returns an SVG image, so you can embed it in your html just like you would with any other svg.
107+
108+
```html
109+
<img src="https://dcbadge.vercel.app/api/shield/USERID" />
110+
```

bot/assets/favicon.ico

14.7 KB
Binary file not shown.

bot/index.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
const Discord = require("discord.js");
2+
const client = new Discord.Client();
3+
4+
const express = require("express");
5+
const favicon = require('serve-favicon')
6+
const path = require('path')
7+
8+
const app = express();
9+
const port = 3581;
10+
11+
app.use(favicon(path.join(__dirname, 'assets', 'favicon.ico')))
12+
13+
client.login(process.env.DC_TOKEN);
14+
15+
async function getUserInfo(req, res, isBot) {
16+
const userID = req.query.u;
17+
18+
// If the user is a bot, we check the bot server, else the regular server. The GUILD_ID env var overrides this
19+
const guildID =
20+
process.env.GUILD_ID || isBot ? "867345122941337610" : "852978546187698206";
21+
22+
const guild = client.guilds.cache.get(guildID);
23+
24+
await guild.members.fetch();
25+
26+
// We check if the user is in the server (https://discord.gg/zkspfFwqDg)
27+
if (guild.member(userID)) {
28+
const user = client.users.cache.get(userID);
29+
30+
let presence = user.presence.status;
31+
const tag = user.tag;
32+
33+
// If the presence is dnd we rename it to do not disturb
34+
if (presence === "dnd") {
35+
presence = "do not disturb";
36+
}
37+
38+
res.status(200).json({ t: tag, p: presence });
39+
} else {
40+
// If the user isn't in the guild, we tell them to join, since we can't get the info otherwise
41+
res.status(200).json({
42+
t: "Error",
43+
p: "You have to join the Discord server (https://discord.gg/zkspfFwqDg) for this to work.",
44+
});
45+
}
46+
}
47+
48+
app.get('/', (_req, res) => {
49+
res.send('The backend for my discord badge service!\n\nSource code at: https://github.com/gitlimes/discord-md-badge/tree/main/bot')
50+
})
51+
52+
app.get("/md-shield/json/", (req, res) => {
53+
getUserInfo(req, res);
54+
});
55+
56+
app.get("/md-shield/bot/json/", (req, res) => {
57+
getUserInfo(req, res, true);
58+
});
59+
60+
client.on("ready", () => {
61+
app.listen(port, () => {
62+
console.log(`Listening on http://localhost:${port}`);
63+
});
64+
});

0 commit comments

Comments
 (0)