Skip to content
This repository was archived by the owner on Sep 28, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
512f32e
modules: add axios
Oct 5, 2020
c4b161d
feat(meme command): add meme command
Oct 5, 2020
3132d0a
feat(meme command): update command handler to use Picture directory
Oct 5, 2020
4dc5a80
modules: replace axios by snoowrap for reddit calls
Oct 6, 2020
90ea3af
feat(meme command): add reddit helper
Oct 6, 2020
b001954
refactor(meme command): use reddit API to get random image
Oct 6, 2020
9c0bb10
config: update config example to match reddit arguments
Oct 6, 2020
f3ab379
fix(meme command): remove console.log
Oct 6, 2020
ff687e8
Merge branch 'main' into feature/spooktober-picture-command
matteoauger Oct 6, 2020
6e16e46
:chart_with_upwards_trend: Add a log when the reaction system is trig…
LucasCtrl Oct 6, 2020
8136680
:globe_with_meridians: Improve setlang command
LucasCtrl Oct 6, 2020
590ab2d
:sparkles: Add vote command
LucasCtrl Oct 6, 2020
0b58a5d
Testing manual Workflow
Oct 6, 2020
0fe8330
Removed workflows from master
Oct 6, 2020
7fb07fe
Merge pull request #2 from start-again/main
Mr1BitL8r Oct 7, 2020
2603775
Added more german translations and emojis.
Oct 7, 2020
748fdfc
Removed uniqueNames and translated headstone.
Oct 7, 2020
5110646
Merge pull request #54 from Mr1BitL8r/feature/german_translation_adde…
LucasCtrl Oct 8, 2020
607044c
:art: Embeded trick or treat command
LucasCtrl Oct 9, 2020
ae8e1ad
:art: Embeded play sound command
LucasCtrl Oct 9, 2020
e8443d1
Add a stats command
LucasCtrl Oct 9, 2020
f3990d4
Add some fooBar
mjyao Oct 12, 2020
ca9e472
Merge pull request #55 from Xenophloxic/feature/Xenophloxic
LucasCtrl Oct 12, 2020
bb725c6
Docker Preps + Automation + Trickt&Treat Feature
Oct 12, 2020
c507fdd
Merge pull request #52 from start-again/docker_preps
Oct 12, 2020
14a8fe1
Moving ar,tr,zh translations to new folder
Oct 13, 2020
2952bb4
Improve English translation file
LucasCtrl Oct 13, 2020
7e6017d
Update to the final structure
LucasCtrl Oct 13, 2020
f6fec7f
Update command display
LucasCtrl Oct 13, 2020
6d3f0de
Update bot version
LucasCtrl Oct 13, 2020
252a4c7
:ambulance: Fix broken link
LucasCtrl Oct 13, 2020
067072c
:ambulance: Fix broken link
LucasCtrl Oct 13, 2020
884d183
:ambulance: Fix broken link
LucasCtrl Oct 13, 2020
f15938d
:ambulance: Fix the tricks or treats thing
LucasCtrl Oct 13, 2020
6ae6d6e
Update fr.js
LucasCtrl Oct 15, 2020
5b4b209
Merge pull request #57 from start-again/update-french-language
LucasCtrl Oct 15, 2020
f31abc5
Update fr.js
LucasCtrl Oct 15, 2020
25a7b42
Update fr.js
LucasCtrl Oct 15, 2020
5cd731c
:ambulance: Fix the word detection
LucasCtrl Oct 15, 2020
b4fe7d8
modules: add axios
Oct 5, 2020
7199249
feat(meme command): add meme command
Oct 5, 2020
edf9ea0
feat(meme command): update command handler to use Picture directory
Oct 5, 2020
898e426
modules: replace axios by snoowrap for reddit calls
Oct 6, 2020
2e9cf6d
feat(meme command): add reddit helper
Oct 6, 2020
2e41043
refactor(meme command): use reddit API to get random image
Oct 6, 2020
a64aec5
config: update config example to match reddit arguments
Oct 6, 2020
556baba
fix(meme command): remove console.log
Oct 6, 2020
e3aacef
fix(command.js): dirs syntax error
Oct 19, 2020
adfe862
Merge branch 'feature/spooktober-picture-command' of https://github.c…
Oct 19, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
},
overrides: [
{
files: ['lang/*.js'],
files: ['app/lang/*.js'],
rules: {
'require-jsdoc': 'off',
},
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/build-bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build Workflow
on:
push:
branches:
- main
jobs:
job_one:
name: Build and push docker images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build docker-image
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
docker build -f ./docker/spooky-node/DockerfileProd --build-arg NODE_VERSION=12.18.2 -t spookybot/spookybot:latest -t spookybot/spookybot:${{github.run_number}} .
docker push spookybot/spookybot:${{github.run_number}}
docker push spookybot/spookybot:latest
docker logout


24 changes: 24 additions & 0 deletions .github/workflows/deploy-bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Deployment Workflow
on:
workflow_dispatch:
inputs:
tags:
description: 'Tag'
jobs:
deploy_prod_bot:
runs-on: ubuntu-latest
steps:
- uses: appleboy/ssh-action@master
name: deploy to prod
with:
host: ${{ secrets.SSH_IP }}
port: ${{ secrets.SSH_PORT }}
username: spookybot
key: ${{ secrets.SSH_KEY }}
script: |
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
docker pull spookybot/spookybot:latest
docker-compose -f /home/spookybot/docker-compose.yml down -v
docker-compose -f /home/spookybot/docker-compose.yml up -d
docker logout

6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ jspm_packages/

# Optional eslint cache
.eslintcache
.eslintrc.js

# Yarn Integrity file
.yarn-integrity

# config file
config.json

app/config/config.json
# IDE
.idea
*.iml


14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
DOCKERCOMPOSE_DEV=-f docker-compose.dev.yml


.PHONY: build_dev_image
build_dev_image:
docker build -f ./docker/spooky-node/DockerfileDev -t spookybot:dev .

.PHONY: startup_dev
startup_dev:
docker-compose ${DOCKERCOMPOSE_DEV} up -d

.PHONY: stop_dev
stop_dev:
docker-compose ${DOCKERCOMPOSE_DEV} down -v
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You just need to click on [this link](https://discord.com/oauth2/authorize?clien

You can add languages to the robot so that it is translated and accessible to everyone!

To do this, nothing could be simpler, just copy the file `./lang/en.js` then rename it following the [ISO 639-1 nomenclature](http://www.mathguide.de/info/tools/languagecode.html).
To do this, nothing could be simpler, just copy the file `./app/lang/en.js` then rename it following the [ISO 639-1 nomenclature](http://www.mathguide.de/info/tools/languagecode.html).
Then you just need to modify the file as you wish. For the translation to be set up on the robot, do not hesitate to open a pull request by [following this guide](https://github.com/LucasCtrl/spookyBot/blob/main/README.md#-contributing).

To react to a word, you need two elements in the translation file: the word and the emoji with which it will react.
Expand All @@ -34,10 +34,11 @@ You can see that the `emoji` element is an emoji, but you can also use a custom

## 💻 Testing locally
1. Create a bot [on the Discord developer portal](https://discord.com/developers/applications),
2. Create a webhook on your own discord server [by folloing this tutorial](https://docs.gitlab.com/ee/user/project/integrations/discord_notifications.html),
3. Copy the `config.example.json` from the project to `config.json` and fill in the gaps with the information from the bot and the webhook. The first token is on the bot page accessed from the side of the Discord Developer Portal, and the webook information is found on the page when you navigate to the webhook url,
2. Create a webhook on your own discord server [by following this tutorial](https://docs.gitlab.com/ee/user/project/integrations/discord_notifications.html),
3. Copy the `./app/config/config.example.json` from the project to `./app/config/config.json` and fill in the gaps with the information from the bot and the webhook. The first token is on the bot page accessed from the side of the Discord Developer Portal, and the webook information is found on the page when you navigate to the webhook url,
4. Invite your dev bot to your server by [following this url](https://discord.com/oauth2/authorize?client_id=761568927188123669&scope=bot&permissions=1141124160), replacing the client id with your bot's client id (found on it's general information page), and the permissions with the Permission Integer created in the Developer Portal as you select permissions for your bot,
5. Once these steps are setup, simply run `yarn install` and `npm run dev` from the terminal in the root directory of the repo,
5. Once these steps are setup, simply run `make startup_dev` from the terminal in the root directory of the repo,
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!

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const { MessageEmbed } = require('discord.js')
const { prefix, colors } = require('../../config.json')
const { prefix, colors } = require('../../config/config.json')

const { readdirSync } = require('fs')
const { resolve } = require('path')

const { changeLang } = require('../../models/servers')

const ISOCode = require('../../utils/languageCode')

module.exports = {
config: {
command: 'setlang',
Expand Down Expand Up @@ -40,18 +42,22 @@ module.exports = {
changeLang(message.guild.id, args[0])
} else {
// The language doesn't exist
let messageContent = ['The requested language does not exist, please choose a language from this list:']
availableLang.forEach((lang) => messageContent.push(`- **${lang}**`))
let messageContent = [
'The requested language does not exist, please choose a language from this list: (the bold part)',
]
availableLang.forEach((lang) => messageContent.push(`- **${lang}**: ${ISOCode.find((l) => l.code == lang).name}`))

const embed = new MessageEmbed()
.setColor(colors.primary)
.setDescription(messageContent)
.setFooter('This message will be deleted automatically')
.setFooter(
"If you can't find your language, don't hesitate to contact us by using the command boo!support | This message will be deleted automatically"
)

message.channel.send(embed).then((m) => {
setTimeout(() => {
m.delete()
}, 10000)
}, 20000)
})
}
},
Expand Down
4 changes: 2 additions & 2 deletions commands/Info/help.js → app/commands/Info/help.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { MessageEmbed } = require('discord.js')
const { prefix, colors } = require('../../config.json')
const { version } = require('../../package.json')
const { prefix, colors } = require('../../config/config.json')
const { version } = require('../../../package.json')

module.exports = {
config: {
Expand Down
2 changes: 1 addition & 1 deletion commands/Info/invite.js → app/commands/Info/invite.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { MessageEmbed } = require('discord.js')
const { prefix, colors } = require('../../config.json')
const { prefix, colors } = require('../../config/config.json')

module.exports = {
config: {
Expand Down
2 changes: 1 addition & 1 deletion commands/Info/ping.js → app/commands/Info/ping.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { MessageEmbed } = require('discord.js')
const { prefix, colors } = require('../../config.json')
const { prefix, colors } = require('../../config/config.json')

module.exports = {
config: {
Expand Down
32 changes: 32 additions & 0 deletions app/commands/Info/stats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const { MessageEmbed } = require('discord.js')
const { prefix, colors } = require('../../config/config.json')

module.exports = {
config: {
command: 'stats',
name: 'Stat',
description: 'Give you some statistics about the bot',
usage: `${prefix}stats`,
displayHelp: true,
},

run: async (bot, message, args) => {
const memoryStats = process.memoryUsage()

const embed = new MessageEmbed()
.setColor(colors.primary)
.setAuthor(`Stats - ${bot.user.username}`, bot.user.avatarURL({ dynamic: true }))
.addField('Number of servers ¬', bot.guilds.cache.size.toLocaleString(), true)
.addField(
'Number of users ¬',
bot.guilds.cache.reduce((mem, g) => (mem += g.memberCount), 0),
true
)
.addField('Number of emojis ¬', bot.emojis.cache.size, true)
.addField('Number of channels ¬', bot.channels.cache.size, 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(embed)
},
}
2 changes: 1 addition & 1 deletion commands/Info/support.js → app/commands/Info/support.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { MessageEmbed } = require('discord.js')
const { prefix, colors } = require('../../config.json')
const { prefix, colors } = require('../../config/config.json')

module.exports = {
config: {
Expand Down
23 changes: 23 additions & 0 deletions app/commands/Info/vote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const { MessageEmbed } = require('discord.js')
const { prefix, colors } = require('../../config/config.json')

module.exports = {
config: {
command: 'vote',
name: 'Vote',
description: 'Vote for the bot',
usage: `${prefix}vote`,
displayHelp: true,
},

run: async (bot, message, args) => {
const embed = new MessageEmbed()
.setColor(colors.primary)
.setAuthor('Support server', bot.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(embed)
},
}
17 changes: 13 additions & 4 deletions commands/Sound/playsound.js → app/commands/Sound/playsound.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
const { prefix } = require('../../config.json')
const { MessageEmbed } = require('discord.js')
const { prefix } = require('../../config/config.json')
const { readdirSync } = require('fs')
const { resolve } = require('path')

module.exports = {
config: {
name: 'Boo Sound',
usage: `${prefix}booh`,
description: 'Display this menu',
description: 'Joins your voice channel and scares you',
command: 'booh',
aliases: ['buh', 'scare'],
displayHelp: false,
displayHelp: true,
},

run: async (bot, message, args) => {
Expand All @@ -27,7 +28,15 @@ module.exports = {
connection.voice.channel.leave()
})
} else {
message.author.send('How can I scare your companions without you beeing present in the voice channel?')
const embed = new MessageEmbed()
.setTitle('How can I scare your companions without you beeing present in the voice channel?')
.setColor(colors.primary)

message.channel.send(embed).then((m) => {
setTimeout(() => {
m.delete()
}, 5000)
})
}
},
}
File renamed without changes.
File renamed without changes.
76 changes: 76 additions & 0 deletions app/commands/Text/trickortreat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
const { MessageEmbed } = require('discord.js')
const { prefix, colors } = require('../../config/config.json')

const { treat, trick, createTrickOrTreat, getTrickOrTreat } = require('../../models/trickortreats')

const isToday = (someDate) => {
const today = new Date()
const currentDate = new Date(Date.parse(someDate))

return (
currentDate.getDate() == today.getDate() &&
currentDate.getMonth() == today.getMonth() &&
currentDate.getFullYear() == today.getFullYear()
)
}

module.exports = {
config: {
name: 'Trick or Treat',
usage: `${prefix}trickortreat`,
description: 'Gives you candy or scares you 😈',
command: 'trickortreat',
aliases: ['tot'],
displayHelp: true,
},

run: async (bot, message, args) => {
let trickOrTreat = await getTrickOrTreat(message.author.id)

if (!trickOrTreat) {
await createTrickOrTreat(message.author.id)
trickOrTreat = await getTrickOrTreat(message.author.id)
}

if (!trickOrTreat.lastPlayed || !isToday(trickOrTreat.lastPlayed)) {
if (Math.random() >= 0.5) {
trickOrTreat = await trick(message.author.id)

let embed = await new MessageEmbed()
.setTitle(':smiling_imp: Oh no!, You have been tricked!')
.setColor(colors.info)
.setDescription('Better luck tomorrow!')
.addField(':candy: Candys', trickOrTreat.treats, true)
.addField(':smiling_imp: Tricks', trickOrTreat.tricks, true)
.setFooter(message.author.username, message.author.avatarURL({ dynamic: true }))
.setTimestamp(new Date())

await message.channel.send(embed)
} else {
trickOrTreat = await treat(message.author.id)

let embed = await new MessageEmbed()
.setTitle(':candy: Sweet, sweet candy!')
.setColor(colors.error)
.setDescription('There will be more candy up for grabs tomorrow!')
.addField(':candy: Candys', trickOrTreat.treats, true)
.addField(':smiling_imp: Tricks', trickOrTreat.tricks, true)
.setFooter(message.author.username, message.author.avatarURL({ dynamic: true }))
.setTimestamp(new Date())

await message.channel.send(embed)
}
} else {
const embed = new MessageEmbed()
.setTitle('It looks like you have already played today.')
.setColor(colors.primary)
.setDescription('There will be more candy up for grabs tomorrow!')
.addField(':candy: Candys', trickOrTreat.treats, true)
.addField(':smiling_imp: Tricks', trickOrTreat.tricks, true)
.setFooter(message.author.username, message.author.avatarURL({ dynamic: true }))
.setTimestamp(new Date())

message.channel.send(embed)
}
},
}
21 changes: 21 additions & 0 deletions app/config/config.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"token": "",
"prefix": "boo!",
"webhook": {
"id": "",
"token": ""
},
"colors": {
"primary": "#FF6403",
"success": "#2ECC71",
"error": "#E74C3C",
"info": "#7C5398"
},
"reddit": {
"userAgent": "SpookyBot, a Discord bot to celebrate Halloween",
"clientId": "",
"clientSecret": "",
"refreshToken": ""
}
}

2 changes: 1 addition & 1 deletion core.js → app/core.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { Client, Collection, WebhookClient } = require('discord.js')

const { token, webhook } = require('./config.json')
const { token, webhook } = require('./config/config.json')

const bot = new Client()

Expand Down
Empty file added app/db/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion db/servers.json → app/db/servers.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"servers": []
}
}
Loading