Skip to content

Instantly share code, notes, and snippets.

@JasonMadeSomething
Created August 23, 2020 23:25
Show Gist options
  • Save JasonMadeSomething/e25bccd138745c48258715c069fafd88 to your computer and use it in GitHub Desktop.
Save JasonMadeSomething/e25bccd138745c48258715c069fafd88 to your computer and use it in GitHub Desktop.
main bot file
require('dotenv').config()
const Discord = require('discord.js')
const axios = require('axios')
const Feats = require('./feats')
const Magic = require('./magic')
const client = new Discord.Client()
client.login(process.env.DISCORD_TOKEN)
const responders = [new Magic(), new Feats()]
client.on('message', getPage)
async function getPage (msg) {
const url = encodeURI(msg.content)
const responder = responders.find(responder => responder.match(url))
if (!responder) {
} else {
try {
const response = await axios.get(url)
const message = responder.format(response)
msg.channel.send(message)
} catch (e) {
console.error(e)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment