Skip to content

Commit

Permalink
Add missing info to README and fix deployment script
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusOtter committed Jan 22, 2022
1 parent 16c9649 commit 530b4e8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
24 changes: 10 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,30 @@
<a href="#"><img src="https://raw.githubusercontent.com/MarcusOtter/discord-needle/main/branding/logo-64x64.png" height="39" width="39"></a>
</sub>
</h1>
Needle is a <b><a href="https://discord.com/">Discord</a> bot</b> that helps you manage your <b><a href="https://support.discord.com/hc/en-us/articles/4403205878423-Threads-FAQ">Discord threads</a></b> 🪡
Needle is a <b><a href="https://discord.com/">Discord</a> bot</b> that helps you declutter your server by creating <a href="https://support.discord.com/hc/en-us/articles/4403205878423-Threads-FAQ">Discord threads</a> automatically
<br/><br/>
<table>
<tr>
<td><a href="https://needle.gg">Website ✨</a></td>
<td><a href="https://needle.gg/invite">Invite Needle 🪡</a></td>
<td><a href="https://needle.gg/chat">Get support 💬</a></td>
</tr>
</table>
<a href="https://needle.gg">Website ✨</a> &emsp; <a href="https://needle.gg/invite">Invite Needle 🪡</a> &emsp; <a href="https://needle.gg/chat">Get support 💬</a>
</div>

## Self-hosting
This step-by-step guide assumes you have [NodeJS](https://nodejs.org/en/) version `16.6.0` or higher installed and that you have a Discord Bot user set up at [Discord's developer page](https://discord.com/developers/applications) that has been invited to your server with the `bot` scope and the `applications.commands` scope.
This step-by-step guide assumes you have [NodeJS](https://nodejs.org/en/) version `16.6.0` or higher installed and that you have a Discord Bot user set up at [Discord's developer page](https://discord.com/developers/applications) that has been invited to your server with the scopes `applications.commands` and `bot`.

1. Clone the repository
2. Create a file named `.env` in the root directory and insert the Discord API token for your bot:
1. Fork and clone the repository
2. Create a file named `.env` in the root directory and insert your bot's Discord API token and Application ID:
```bash
DISCORD_API_TOKEN=abcd1234...
CLIENT_ID=123456...
```
3. Run `npm install`
4. Make sure the bot has the required permissions in Discord:
4. Run `npm deploy`. This will make the slash commands show up in the servers the bot are in, but **it can take up to _ONE HOUR_ before they show up**.
5. Make sure the bot has the required permissions in Discord:
- [x] View channels
- [x] Send messages
- [x] Send messages in threads
- [x] Create public threads
- [x] Read message history
5. Run `npm start`
6. Deploy! :tada:
6. Run `npm start`
7. Deploy! :tada:

## Contributing
Coming soon :tm:
Expand Down
26 changes: 21 additions & 5 deletions scripts/deploy-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,29 @@ const API_TOKEN = getApiToken();
const CLIENT_ID = getClientId();
const GUILD_ID = getGuildId();

if (!API_TOKEN || !CLIENT_ID || !GUILD_ID) {
console.log("API_TOKEN, CLIENT_ID, or GUILD_ID was missing from the .env file: aborting command deployment");
console.log("Hint: If you just want to start the bot without developing commands, type \"npm start\" instead\n");
const isGlobal = process.argv.some(x => x === "--global");
const isUndeploy = process.argv.some(x => x === "--undeploy");

if (!API_TOKEN || !CLIENT_ID) {
console.log("Aborting command deployment");
console.log("DISCORD_API_TOKEN or CLIENT_ID missing from the .env file.\n");
return;
}

if (isUndeploy && !GUILD_ID) {
console.log("Aborting undeployment of guild commands");
console.log("GUILD_ID is missing from the .env file, assuming no guild commands need to be undeployed.\n");
return;
}

if (!isGlobal && !GUILD_ID) {
console.log("Aborting guild command deployment");
console.log("GUILD_ID is missing from the .env file.");
console.log("Hint: If you just want to start the bot without developing new commands, type \"npm start\" instead\n");
return;
}

const route = process.argv.some(x => x === "--global")
const route = isGlobal
? Routes.applicationCommands(CLIENT_ID)
: Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID);

Expand All @@ -41,7 +57,7 @@ const rest = new REST({ version: "9" }).setToken(API_TOKEN);
})();

async function getSlashCommandBuilders() {
if (process.argv.some(x => x === "--undeploy")) {
if (isUndeploy) {
console.log("Undeploying guild commands");
return [];
}
Expand Down

0 comments on commit 530b4e8

Please sign in to comment.