Skip to content

Commit

Permalink
🔖 v2.0.0
Browse files Browse the repository at this point in the history
[RELEASE] - v2.0.0
  • Loading branch information
LucasCtrl authored Oct 15, 2021
2 parents 7ce7786 + cd0f818 commit b696899
Show file tree
Hide file tree
Showing 30 changed files with 399 additions and 87 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
node_modules
db
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ TOKEN=0123456789

WEBHOOK_ID=0123456789
WEBHOOK_TOKEN=qwerty0123456789

MONGODB_USERNAME=test
MONGODB_PASSWORD=123
MONGODB_URL=yourlink.net
MONGODB_DEFAULT_DB=hellodb
2 changes: 1 addition & 1 deletion .github/workflows/deploy-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
cd ~/SpookyBot/
git pull --ff-only
docker-compose -f ~/SpookyBot/docker-compose.yml down -v
docker-compose -f ~/SpookyBot/docker-compose.yml up -d
docker-compose -f ~/SpookyBot/docker-compose.yml up --build -d
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jspm_packages/

# Config
.env
db

# IDE
.vscode
Expand Down
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ RUN npm install --production

COPY . .

RUN mkdir db

ENTRYPOINT [ "npm", "start" ]
ENTRYPOINT [ "npm", "start" ]
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ You can see that the `emoji` element is an emoji, but you can also use a custom
5.1 If you want to install node modules you could just add it into your local package.json and run the `make build_dev_image` after that you need to recreate the container.
6. Test the bot is connected by running `<your-prefix>help` to get a list of commands, and then initialize the DB by running `<your-prefix>emitgc`. It should then respond with "Join <your-server> with <#> users,
7. Test that the bot reacts to comments by typing one of the words in `lang/<your-lang>.js`. The bot should respond with an emoji! -->
<!--
<!--
### Docker
To run the bot inside a docker container, make sure to create the .env
Expand All @@ -50,7 +50,7 @@ file and then run the following:
```bash
docker build . -t spooky-bot --no-cache
docker run --name spooky-bot --env-file .env --rm -d spooky-bot
```
```
Or with `docker compose up` -->

Expand All @@ -61,8 +61,9 @@ Or with `docker compose up` -->
* Twitter: [@LucasCtrlAlt](https://twitter.com/LucasCtrlAlt)
* GitHub: [@LucasCtrl](https://github.com/LucasCtrl)

<!-- ## 🙏 Thanks
* [**@ALMerrill**](https://github.com/ALMerrill) - Translation (es, de), code, documentation
## 🙏 Thanks
* [**@AntoniosBarotsis**](https://github.com/AntoniosBarotsis) - Docker integration
<!--
* [**@marc2332**](https://github.com/marc2332) - Translation (es, ca)
* [**@tmetten**](https://github.com/tmetten) - Translation (nl)
* [**@dragonDScript**](https://github.com/dragonDScript) - Translation (ca)
Expand All @@ -81,7 +82,10 @@ Before contributing to this project, make sure you have read the [contribution g

## Show your support

Give a ⭐️ if you like this project!
- Give a ⭐️ if you like this project!
- Upvote for the bot

<a href="https://discordbotlist.com/bots/761568927188123669"><img src="https://discordbotlist.com/api/v1/bots/761568927188123669/widget"></a>

<a href="https://www.buymeacoffee.com/lucasalt"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=lucasalt&button_colour=5F7FFF&font_colour=ffffff&font_family=Poppins&outline_colour=000000&coffee_colour=FFDD00"></a>

Expand Down
4 changes: 1 addition & 3 deletions commands/Development/emitgc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export default {
config: {
command: 'emitgc',
},
command: 'emitgc',

run: async (client, message) => {
client.emit('guildCreate', message.guild)
Expand Down
4 changes: 1 addition & 3 deletions commands/Development/emitgd.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export default {
config: {
command: 'emitgd',
},
command: 'emitgd',

run: async (client, message) => {
client.emit('guildDelete', message.guild)
Expand Down
29 changes: 29 additions & 0 deletions commands/Info/help.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { MessageEmbed } from 'discord.js'

export default {
command: 'help',
help: {
name: 'Help',
description: 'Display the help menu',
},

run: async (client, message) => {
message.delete()
let embed = await new MessageEmbed()
.setColor(client.config.colors.primary)
.setFooter(`Requested by ${message.author.username}`, message.author.avatarURL({ dynamic: true }))
.addField('\u200b', '📍 **INFORMATIONS**', false)
.addField('Support', 'https://discord.gg/nEDcagb', true)
.addField('Source code', 'https://github.com/LucasCtrl/SpookyBot', true)
.addField('🤖 Bot version', '2.0.0', false)
.addField('\u200b', '📍 **COMMANDS LIST**', false)

client.commands.forEach((c) => {
if (c.help) {
embed.addField(c.help.name, `${c.help.description}\n**Usage: **${client.config.prefix}${c.command}`, false)
}
})

message.author.send({ embeds: [embed] })
},
}
20 changes: 20 additions & 0 deletions commands/Info/invite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { MessageEmbed } from 'discord.js'

export default {
command: 'invite',
help: {
name: 'Invite',
description: 'Get an invitation link to invite the bot on your server',
},

run: async (client, message) => {
const embed = new MessageEmbed()
.setColor(client.config.colors.primary)
.setAuthor('Invitation link', client.user.avatarURL())
.setDescription(
'You can click on the following link to add the bot on your server: [https://discord.com/oauth2/authorize?client_id=761568927188123669&scope=bot&permissions=380108139840](https://discord.com/oauth2/authorize?client_id=761568927188123669&scope=bot&permissions=380108139840)'
)

message.channel.send({ embeds: [embed] })
},
}
21 changes: 16 additions & 5 deletions commands/Info/ping.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import { MessageEmbed } from 'discord.js'

export default {
config: {
command: 'ping',
aliases: ['test'],
},
command: 'ping',

run: async (client, message) => {
message.reply('Pong')
const beforePing = new MessageEmbed().setColor(client.config.colors.primary).setDescription('Pinging...')

message.channel.send({ embeds: [beforePing] }).then((m) => {
let ping = m.createdTimestamp - message.createdTimestamp

const afterPing = new MessageEmbed()
.setColor(client.config.colors.primary)
.setDescription(
`Pong! :ping_pong:\nBot Latency: \`${ping}ms\`, API Latency: \`${Math.round(client.ws.ping)}ms\``
)

m.edit({ embeds: [afterPing] })
})
},
}
28 changes: 28 additions & 0 deletions commands/Info/stats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { MessageEmbed } from 'discord.js'

export default {
command: 'stats',
help: {
name: 'Stats',
description: 'Give you some statistics about the bot',
},

run: async (client, message) => {
const memoryStats = process.memoryUsage()
const embed = new MessageEmbed()
.setColor(client.config.colors.primary)
.setAuthor(`Stats - ${client.user.username}`, client.user.avatarURL({ dynamic: true }))
.addField('Number of servers ¬', client.guilds.cache.size.toLocaleString(), true)
.addField(
'Number of users ¬',
client.guilds.cache.reduce((mem, g) => (mem += g.memberCount), 0).toLocaleString(),
true
)
.addField('Number of emojis ¬', client.emojis.cache.size.toLocaleString(), true)
.addField('Number of channels ¬', client.channels.cache.size.toLocaleString(), true)
.addField('Memory usage ¬', `${Math.ceil(memoryStats.heapUsed / 1048576)} Mo`, true)
.setFooter(`Requested by ${message.author.username}`, message.author.avatarURL({ dynamic: true }))

message.channel.send({ embeds: [embed] })
},
}
20 changes: 20 additions & 0 deletions commands/Info/support.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { MessageEmbed } from 'discord.js'

export default {
command: 'support',
help: {
name: 'Support',
description: 'Get the invitation link to join the support server',
},

run: async (client, message) => {
const embed = new MessageEmbed()
.setColor(client.config.colors.primary)
.setAuthor('Support server', client.user.avatarURL())
.setDescription(
'You can click on the following link to join the support server: [https://discord.gg/nEDcagb](https://discord.gg/nEDcagb)'
)

message.channel.send({ embeds: [embed] })
},
}
21 changes: 21 additions & 0 deletions commands/Info/vote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { MessageEmbed } from 'discord.js'

export default {
command: 'vote',
aliases: ['upvote'],
help: {
name: 'Vote',
description: 'Vote for the bot',
},

run: async (client, message) => {
const embed = new MessageEmbed()
.setColor(client.config.colors.primary)
.setAuthor('Support server', client.user.avatarURL())
.setDescription(
'You can vote for the bot by clicking on the following link: [https://discordbotlist.com/bots/spookybot/upvote](https://discordbotlist.com/bots/spookybot/upvote)'
)

message.channel.send({ embeds: [embed] })
},
}
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"prefix": "!",
"prefix": "boo!",
"colors": {
"primary": "#FF6403",
"success": "#2ECC71",
Expand Down
2 changes: 2 additions & 0 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ dotenv.config()
import { Client, Intents, Collection, WebhookClient } from 'discord.js'
import fs from 'node:fs/promises'

import './db.js'

const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
})
Expand Down
12 changes: 12 additions & 0 deletions db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import dotenv from 'dotenv'
import mongoose from 'mongoose'

dotenv.config()

const uri = `mongodb+srv://${process.env.MONGODB_USERNAME}:${process.env.MONGODB_PASSWORD}@${process.env.MONGODB_URL}/${process.env.MONGODB_DEFAULT_DB}?retryWrites=true&w=majority`

mongoose.connect(uri, { useNewUrlParser: true, useUnifiedTopology: true })

const dbConnection = mongoose.connection
dbConnection.on('error', (err) => console.log(`Connection error: ${err}`))
dbConnection.once('open', () => console.log('Connected to DB!'))
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ version: '3'

services:
bot:
build: .
build: .
2 changes: 2 additions & 0 deletions events/guildCreate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { MessageEmbed } from 'discord.js'
import { createEvent } from '../models/events.js'
import currentDate from '../utils/currentDate.js'

export default (client, webhook, guild) => {
Expand All @@ -8,4 +9,5 @@ export default (client, webhook, guild) => {
.setFooter(currentDate())

webhook.send({ embeds: [embed] })
createEvent('guildCreate')
}
2 changes: 2 additions & 0 deletions events/guildDelete.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { MessageEmbed } from 'discord.js'
import { createEvent } from '../models/events.js'
import currentDate from '../utils/currentDate.js'

export default (client, webhook, guild) => {
Expand All @@ -11,4 +12,5 @@ export default (client, webhook, guild) => {
.setFooter(currentDate())

webhook.send({ embeds: [embed] })
createEvent('guildDelete')
}
4 changes: 2 additions & 2 deletions events/messageCreate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MessageEmbed } from 'discord.js'
import { createEvent } from '../models/analitycs.js'
import { createCommand } from '../models/commands.js'
import reactMessage from '../utils/reactMessage.js'
import currentDate from '../utils/currentDate.js'

Expand Down Expand Up @@ -27,7 +27,7 @@ export default async (client, webhook, message) => {
.setFooter(currentDate())
webhook.send({ embeds: [embed] })

createEvent('command', cmd.config.command)
createCommand(cmd.config.command)

return cmd.run(client, message)
}
Expand Down
2 changes: 2 additions & 0 deletions events/ready.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { MessageEmbed } from 'discord.js'
import { createEvent } from '../models/events.js'
import currentDate from '../utils/currentDate.js'

export default (client, webhook) => {
Expand All @@ -11,4 +12,5 @@ export default (client, webhook) => {
.setFooter(currentDate())

webhook.send({ embeds: [embed] })
createEvent('ready')
}
10 changes: 5 additions & 5 deletions handlers/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ export default async (client) => {
const commands = readdirSync(resolve(__dirname, `../commands/${dir}`)).filter((x) => x.endsWith('.js'))
for (let file of commands) {
const cmd = await import(`../commands/${dir}/${file}`)
client.commands.set(cmd.default.config.command, cmd.default)
client.commands.set(cmd.default.command, cmd.default)

console.log(`Load command: ${cmd.default.config.command}`)
console.log(`Load command: ${cmd.default.command}`)

if (cmd.default.config.aliases) {
cmd.default.config.aliases.forEach((a) => {
client.aliases.set(a, cmd.default.config.command)
if (cmd.default.aliases) {
cmd.default.aliases.forEach((a) => {
client.aliases.set(a, cmd.default.command)
console.log(`Load aliases: ${a}`)
})
}
Expand Down
33 changes: 0 additions & 33 deletions models/analitycs.js

This file was deleted.

Loading

0 comments on commit b696899

Please sign in to comment.