Created
March 10, 2019 15:49
-
-
Save codehz/a8dfaaa5cb81d005abc62dbe9520203d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const constants = require("./constants.js"); | |
const api = require("stoneapi-js"); | |
const Discord = require('discord.js'); | |
const client = new Discord.Client(); | |
api.init(); | |
api.attach(); | |
const channels = constants.channels; | |
client.on('ready', () => { | |
console.log(`Logged in as ${client.user.tag}!`); | |
const chat_chan = client.channels.get(channels.chat); | |
console.log(chat_chan == null); | |
api.chat.recv((err, msg) => { | |
console.log(msg); | |
chat_chan.send(`${msg.sender}: ${msg.content}`); | |
}); | |
}); | |
client.on('message', async msg => { | |
if (msg.channel.type != 'text' || msg.author.bot) return; | |
if (msg.channel.id == channels.chat) { | |
msg.delete(); | |
api.chat.send(msg.author.username, msg.content); | |
} | |
if (msg.channel.id == channels.admin) { | |
const result = await api.command.execute(msg.author.username, '/'+msg.content); | |
if (result.trim().length == 0) return msg.reply("empty"); | |
msg.reply("```" + result + "```"); | |
} | |
}); | |
client.login(constants.token); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment