Skip to content

Commit

Permalink
Major rework (read description)
Browse files Browse the repository at this point in the history
Changed:
  -  Updated all anti-crash to latest in index.js
  -  Updated README.md
  -  Changed all REPO links to new org ones
  -  Updated MongoDB connection solution
  -  Added invite link on boot
  -  Updated package.json
  -  Added chalk for console.logs
  • Loading branch information
OnlyTunes committed Nov 15, 2021
1 parent 93a0c86 commit c12a040
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 82 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
DISCORD_TOKEN=<BOT TOKEN>
PREFIX=<BOT PREFIX>
PERMISSIONS=<BOT PERMISSIONS (Used for invite link)>
EXPERIMENTAL=<yes/no>
EXPERIMENTAL=<yes/no>
MONGOOSESTRING=<MONGOOSE CONNECTION STRING>
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,27 @@ Discord Bot is a bot made for *something* written with Javascript
```


# Setup
# Quick start guide

1. Install [Git](https://git-scm.com/)
2. Install [Node.js](https://nodejs.org/)
3. Create a [Discord Application](https://discord.com/developers/applications) and get the bot token from there
4. Invite the bot using the link available in the OAuth2 page
5. Clone the repo using `git clone`
6. On the folder of the repo, use `npm install` to transfer the necessary packages.
7. Create a `.env` file with two parameters:
7. Create a `.env` file with the following:

`DISCORD_TOKEN=` - this is where you put your bot token obtained on 3.

`PREFIX=` - a prefix like `!`
8. Run the bot using `node shard.js` or just `node .`

`PERMISSIONS` - a permission integer from your [developer](https://discord.com/developers/applications) page for the bot

`EXPERIMENTAL` - this must be either `yes` or `no`

`MONGOOSESTRING` - this can be left blank if mongoDB is not going to be used

8. Run the bot using `node shard.js` or `npm run start` ( If you want it to restart when you make a change use `npm run test` )

You should see a `Ready!` message when the bot is ready to accept commands. You can try using `ping` for that.

Expand All @@ -53,18 +60,24 @@ Discord Bot is a bot made for *something* written with Javascript

- [Discord.js](https://discord.js.org/) - The Discord Library
- [Node.js](https://nodejs.org/) - JavaScript Runtime
- [Docker](https://www.docker.com/) - Used to host the final bot easily and containerized
- [Docker](https://www.docker.com/) - Containerization Solution

# Contribute

Do you have any good idea? Do you wanna contribute in building new features? Look into the [Issues](https://github.com/COnlyTunesRadio/bot-template/issues) panel and check our current stuff. Everyone is welcome to participate on the project.

Or jump into our discord server! We would love to see your ideas and hear how you have used this template!
[![Support Server](https://img.shields.io/discord/872219348624900096.svg?label=Discord&logo=Discord&colorB=7289da&style=for-the-badge)](https://discord.gg/WYCrkuHJ6X)


# Authors

- CaldeiraG
- Brayd ( OnlyTunes )

----


# License

MIT License
Expand Down
13 changes: 0 additions & 13 deletions SlashCommands/info/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,6 @@ module.exports = {
* @param {String[]} args
*/
run: async (client, interaction) => {
process.on('uncaughtException', (error, origin) => {
console.log('----- Uncaught exception -----')
console.log(error)
console.log('----- Exception origin -----')
console.log(origin)
})

process.on('unhandledRejection', (reason, promise) => {
console.log('----- Unhandled Rejection at -----')
console.log(promise)
console.log('----- Reason -----')
console.log(reason)
})

let mode

Expand Down
15 changes: 1 addition & 14 deletions SlashCommands/util/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,10 @@ module.exports = {
* @param {String[]} args
*/
run: async (client,interaction, args) => {
process.on('uncaughtException', (error, origin) => {
console.log('----- Uncaught exception -----')
console.log(error)
console.log('----- Exception origin -----')
console.log(origin)
})

process.on('unhandledRejection', (reason, promise) => {
console.log('----- Unhandled Rejection at -----')
console.log(promise)
console.log('----- Reason -----')
console.log(reason)
})

const GITHUB01 = `https://github.com/CaldeiraG`
const GITHUB02 = `https://github.com/OnlyTunes`
const REPOURL = `https://github.com/CaldeiraG/discordbot`
const REPOURL = `https://github.com/OnlyTunesRadio/bot-template`

const row = new MessageActionRow()
.addComponents(
Expand Down
17 changes: 2 additions & 15 deletions SlashCommands/util/license.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,9 @@ module.exports = {
* @param {String[]} args
*/
run: async (client,interaction, args) => {
process.on('uncaughtException', (error, origin) => {
console.log('----- Uncaught exception -----')
console.log(error)
console.log('----- Exception origin -----')
console.log(origin)
})

process.on('unhandledRejection', (reason, promise) => {
console.log('----- Unhandled Rejection at -----')
console.log(promise)
console.log('----- Reason -----')
console.log(reason)
})

const LICENSEURL = `https://github.com/CaldeiraG/discordbot/blob/master/LICENSE`
const REPOURL = `https://github.com/CaldeiraG/discordbot`
const LICENSEURL = `https://github.com/OnlyTunesRadio/bot-template/blob/master/LICENSE`
const REPOURL = `https://github.com/OnlyTunesRadio/bot-template`

const row = new MessageActionRow()
.addComponents(
Expand Down
2 changes: 1 addition & 1 deletion commands/util/license.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
*/
run: async (client, message) => {

const LICENSEURL = `https://github.com/CaldeiraG/discordbot/blob/master/LICENSE`
const LICENSEURL = `https://github.com/OnlyTunesRadio/bot-template/blob/master/LICENSE`
const REPOURL = `https://github.com/OnlyTunesRadio/bot-template`

const row = new MessageActionRow()
Expand Down
14 changes: 0 additions & 14 deletions events/boot.js

This file was deleted.

30 changes: 28 additions & 2 deletions events/ready.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
var figlet = require('figlet');
const chalk = require('chalk');
const client = require("../index");

client.on("ready", () =>
client.on("ready", async () => {



figlet('ONLYTUNES', function(err, data) {
if (err) {
console.log('Something went wrong...');
console.dir(err);
return;
}
console.log(data)
})
await sleep(1000);
console.log(chalk.green('==================================='))
console.log('Welcome to the Simple Bot Template!\n This bot is from the OnlyTunesRadio repo found here: https://github.com/OnlyTunesRadio/bot-template\n We hope you enjoy using this Template!\n Let us know of any issues VIA the issues section on the REPO!');
const inviteURL = `https://discord.com/api/oauth2/authorize?client_id=${client.user.id}&permissions=8&scope=bot%20applications.commands`
console.log(chalk.green('==================================='))
console.log(chalk.redBright('[WARNING] ') + `This link must only be used for your own server as it gives the bot full admin permissions!\n[Invite Link] ${inviteURL}`)
console.log(chalk.green('==================================='))
console.log(`✅ ${client.user.tag} is up and ready to go!`)
);
console.log(chalk.green('==================================='))

async function sleep (ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

});
6 changes: 6 additions & 0 deletions handler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,10 @@ module.exports = async (client) => {
// Register for all the guilds the bot is in
await client.application.commands.set(arrayOfSlashCommands);
});

// mongoose
const mongooseConnectionString = process.env.MONGOOSESTRING
if (!mongooseConnectionString) return;

mongoose.connect(mongooseConnectionString).then(() => console.log('Connected to mongodb'));
};
11 changes: 0 additions & 11 deletions handler/mongoose.js

This file was deleted.

31 changes: 30 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,44 @@ const client = new Client({
});
module.exports = client;



// Global Variables
client.commands = new Collection();
client.slashCommands = new Collection();
client.aliases = new Collection();
//client.config = require("./config.json");
client.token = process.env.DISCORD_TOKEN;
client.prefix = process.env.PREFIX;


// ANTI CRASH MECH!
// =====================================================
process.on("unhandledRejection", (reason, p) => {
console.log(" [antiCrash] :: Unhandled Rejection/Catch");
console.log(reason, p);
});
process.on("uncaughtException", (err, origin) => {
console.log(" [antiCrash] :: Uncaught Exception/Catch");
console.log(err, origin);
});
process.on("uncaughtExceptionMonitor", (err, origin) => {
console.log(" [antiCrash] :: Uncaught Exception/Catch (MONITOR)");
console.log(err, origin);
});
process.on("multipleResolves", (type, promise, reason) => {
console.log(" [antiCrash] :: Multiple Resolves");
console.log(type, promise, reason);
});
// =====================================================


// Initializing the project
// =====================================================
require("./handler")(client);
// =====================================================


// Bot Login
// =====================================================
client.login(client.token);
// =====================================================
18 changes: 12 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple-bot-template",
"version": "1.1.0",
"name": "bot-template",
"version": "1.2.0",
"description": "A simple DJS bot template",
"main": "index.js",
"scripts": {
Expand All @@ -15,15 +15,21 @@
"discord",
"discordbot",
"botTemplate",
"simplebot"
"simplebot",
"v13",
"DJS",
"nodejs",
"node",
"discord.js"
],
"author": "CaldeiraG",
"author": "OnlyTunesRadio",
"bugs": {
"url": "https://github.com/CaldeiraG/discordbot/issues"
"url": "https://github.com/OnlyTunesRadio/bot-template/issues"
},
"homepage": "https://github.com/CaldeiraG/discordbot#readme",
"homepage": "https://github.com/OnlyTunesRadio/bot-template#readme",
"license": "MIT",
"dependencies": {
"chalk": "^4.1.2",
"discord.js": "^13.3.1",
"dotenv": "^10.0.0",
"figlet": "^1.5.2",
Expand Down

0 comments on commit c12a040

Please sign in to comment.