-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (30 loc) · 888 Bytes
/
index.js
File metadata and controls
37 lines (30 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const Discord = require("discord.js")
const mySql = require("mysql")
const bot = new Discord.Client()
const TOKEN = ""
const PREFIX = "$"
var connection = mySql.createConnection({
host: "",
user: "",
password: "",
database: ""
})
bot.on("ready", function(message) {
console.log("Status >> Online")
})
bot.on("message", function(message) {
if (!message.content.startsWith(PREFIX)) return
var args = message.content.substring(PREFIX.length).split(" ")
switch(args[0]) {
case "query":
var q = args.slice(1).join(" ")
message.channel.send(`Running query ${q}`)
connection.query(q, function(error, results, fields) {
if (error) {
throw error
message.channel.send(`Query threw error\n ${error}`)
}
})
}
})
bot.login(TOKEN)