Skip to content

Commit

Permalink
feat: canned responses, environment file
Browse files Browse the repository at this point in the history
Signed-off-by: BluLightShow <[email protected]>
  • Loading branch information
max-bromberg committed Apr 20, 2021
1 parent 1793dd3 commit 44efccf
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 35 deletions.
11 changes: 7 additions & 4 deletions bot.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
require('dotenv').config()
const { AkairoClient, CommandHandler, InhibitorHandler, ListenerHandler } = require('discord-akairo')
const Discord = require('discord.js')
const version = require('./package.json').version
const config = require('./config.json')

const embed = new Discord.MessageEmbed()
.setFooter(config.embeds.footer)
.setColor(config.embeds.color)
.setFooter(config.embeds.footer)
.setColor(config.embeds.color)

module.exports = {
embed
}

class MainClient extends AkairoClient {
constructor () {
constructor() {
super({
ownerID: config.owners
}, {
Expand Down Expand Up @@ -58,7 +59,9 @@ class MainClient extends AkairoClient {
const client = new MainClient()

if (config.token) {
console.log("Logging in via config token...")
client.login(config.token)
} else {
client.login(process.env.BOT_TOKEN)
console.log("Logging in via environment token...")
client.login(process.env.BOT_TOKEN)
}
2 changes: 1 addition & 1 deletion commands/codeblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CodeBlockCommand extends Command {
.setTimestamp(new Date())
.setTitle('How to Send Code Blocks')
.setImage('https://cdn.discordapp.com/attachments/758046379133239407/813767505000398929/rllpwo.png')
.setDescription('Surround the code in three backticks. If using new lines, a file extension can be placed directly after the first 3 backticks to highlight in that language. An example is shown below, highlighting code in C++. The backtick key is typically found to the left of the 1 key.')
.setDescription('Surround the code in three backticks. If using new lines, a file extension can be placed directly after the first 3 backticks to highlight in that language. An example is shown below, highlighting code in arduino. The backtick key is typically found to the left of the 1 key.')
)
}
}
Expand Down
42 changes: 42 additions & 0 deletions commands/tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const { Command } = require('discord-akairo')
const config = require('../config.json')
const fs = require('fs')
const { MessageEmbed } = require('discord.js')
const { embed } = require('../bot')

class TagCommand extends Command {
constructor() {
super('tag', {
aliases: ['tag', 'qr', 'res'],
channel: 'guild',
description: 'Send a canned response in the channel.',
args: [
{
id: 'tagAlias',
type: 'string'
}
]
})
}

exec(message, args) {
var files = fs.readdirSync('./tags')
files.forEach(file => {
if (file.endsWith('.json') && (file !== 'template.json')) {
var tagFile = JSON.parse(fs.readFileSync(`./tags/${file}`))
if (tagFile.aliases.includes(args.tagAlias)) {
var tagEmbed = new MessageEmbed(embed)
.setTitle(tagFile.title)

if (tagFile.image) tagEmbed.setImage(tagFile.image)
tagFile.fields.forEach(field => {
tagEmbed.addField(field.name, field.value, false)
})

message.channel.send(tagEmbed)
}
}
})
}
}
module.exports = TagCommand
1 change: 1 addition & 0 deletions listeners/ready.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ReadyListener extends Listener {

exec() {
console.log(`Arduino Bot ${version} ready for battle!`)
console.log(`Logged into account: ${this.client.user.tag}`)
}
}
module.exports = ReadyListener
7 changes: 6 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"dependencies": {
"discord-akairo": "^8.1.0",
"discord.js": "^12.5.1",
"dotenv": "^8.2.0",
"gists": "^2.0.0"
},
"scripts": {
Expand Down
29 changes: 0 additions & 29 deletions staff_commands/setavatar.js

This file was deleted.

47 changes: 47 additions & 0 deletions tags/avrdude.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"title": "Solving Avrdude Communication Error (try in order)",
"aliases": ["avrdude"],
"fields": [
{
"name": "1.",
"value": "If serial monitor is open, close it."
},
{
"name": "2.",
"value": "Try changing the port you are connecting and selecting it from software, you can find it in tools -> port."
},
{
"name": "3.",
"value": "Check if the power led on your board lights up. If it's on unplug and re-plug your board. Now check for blinking leds. If only power or no led lights up ask for further assistance. (not for all boards)"
},
{
"name": "4.",
"value": "Try using the old bootloader. Go to tools -> processor and select 328p(old bootloader). If you are not on Nano, you can skip this step and try it after doing option 5. In that case select your board as nano before you try(make sure you have a 328p chip board like uno)."
},
{
"name": "5.",
"value": "Try pressing reset button on arduino, if when you reset the onboard led doesn't blink, you probably have a broken bootloader, you can check [this tutorial](https://www.arduino.cc/en/Hacking/Bootloader?from=Tutorial.Bootloader) for how to burn bootloader."
},
{
"name": "6.",
"value": "If there's anything connected to Tx and Rx pins, try removing everything attached to them them."
},
{
"name": "7.",
"value": "This might just be a communication problem or your computer getting confused so try restarting your computer."
},
{
"name": "8.",
"value": "Check your drivers, sometimes just reinstalling them works. If you are using a clone board you might have CH340 communication chip, which isn't supported for Uno. You can check that by looking at your board and checking a chip's name (not the big one). [Click here](https://learn.sparkfun.com/tutorials/how-to-install-ch340-drivers/all) for installing CH340 chip. If you don't have CH340 chip you can try installing drivers from Windows device manager."
},
{
"name": "9.",
"value": "You can try checking [this website](https://learn.sparkfun.com/tutorials/how-to-install-ftdi-drivers/windows---in-depth) for your drivers."
},
{
"name": "10.",
"value": "Last thing might be Arduino IDE's problem. If you think that's the case try reinstalling Arduino IDE."
}
],
"image": ""
}
11 changes: 11 additions & 0 deletions tags/template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"title": "",
"aliases": [],
"fields": [
{
"name": "",
"value": ""
}
],
"image": ""
}

0 comments on commit 44efccf

Please sign in to comment.