NoStickers is a Discord bot that allows you to prevent or enable the usage of Discord's sticker feature. Assuming your prefix is !
, getting a list of commands can be done by running !help
.
Prerequisites
Setup
Firstly, you need to have a local copy of this repository on your code editor, you may either:
- Clone this repository via
git clone https://github.com/MrCrypticXDev/NoStickers-Discord-Bot.git
. Note that if needed, you'll have tocd
to the directory the files are in. - Copy the contents of this repository.
So now you have a copy, follow the steps below:
- You may optionally configure the package file to your needs. Or create your own by running
npm init
. - Run
npm install
to get the dependencies and devDependencies. - In the config file, set the following variables with the necessary values:
YOUR_BOT_TOKEN
refers to the token retrieved from the bot page of your app in the Discord developer portal. Need help? Note that it's recommended to use.env
files instead of hard coding the token.YOUR_USER_ID
refers to your user ID on Discord. There's an article for that.YOUR_BOT_PREFIX
refers to the character your bot will detect for, so that it knows when to respond to a command. For example,!
.YOUR_MONGODB_URL
refers to the URL of your MongoDB cluster.YOUR_APP_PUBLIC_KEY
refers to the public key retrieved from your app in the developer portal. This appears in the general page, just below the app ID.
- You'll have to register the slash commands. Don't worry, we got your back, so just follow the next bullet points:
- Feel free to create a file (perhaps
create-slash-commands.js
). - Stick this following piece of code:
const fetch = require('node-fetch');
const token = '';
const id = '';
const json = [{ name: 'eval', description: 'Executes the given code', options: [{ name: 'code', description: 'The code to evaluate', type: 3, required: true }] }, { name: 'help', description: 'Shows the help embed' }, { name: 'invite', description: 'The link for inviting the bot' }, { name: 'stickers', description: 'Allows stickers in the given channel', options: [{ name: 'channel', description: 'The channel to allow sending of stickers from', type: 7, required: true }] }, { name: 'nosticker', description: 'Deletes stickers in the given channel', options: [{ name: 'channel', description: 'The channel to disable usage of stickers from', type: 7, required: true }] }];
for (const i of json) {
fetch(`https://discord.com/api/applications/${id}/commands`, {
method: 'POST',
headers: {
'Authorization': `Bot ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(i)
})
.then(res => res.json())
.then(data => console.log(data));
}
- Run
node create-slash-commands.js
. Make sure to have node-fetch installed, as well as the details placed in the variables. If you see an output of JSON in your console without any error messages, you're good to go! - Now you'll actually have to allow your bot to receive interactions. To do that, go to your app's homepage, navigate to the interactions endpoint URL field and place the link + the
/interactions
endpoint (e.g.https://bot.site/interactions
). Keep in mind you'll need the server running.
- Run
node src/index.js
to start the bot. Don't forget to invite it! - And lastly, enjoy Stickers while you can. 🌺
- You may run
npm run lint
to find errors in your code. There's alsonpm run lint:fix
that has the ability to correct certain types of mistakes. - Written in the JavaScript language, runs on the Node.js runtime environment, and uses Discord.js as the core library.
- Chalk is used for logging, whilst mongoose is for using MongoDB. ESLint is for code linting. There are also other libraries used such as discord-interactions and node-fetch for creating and replying to slash commands and interactions.
The NoStickers Discord bot is released under the GNU General Public License 3.0. See LICENSE for more details.
Originally developed by MrCrypticXDev and maintained by its contributors.