This repository has been archived by the owner on Feb 13, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
64 lines (51 loc) · 2.04 KB
/
test.js
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*****
* This test file is used to test the basic functionality of the dashbaord.
* It is also here to serve as an example implementation of the module.
*/
const { Client } = require('discord.js');
const { join } = require("path");
const chalk = require('chalk');
require('dotenv').config(); // Create a .env file or include your own config file
//import run from "./index.js"; //require dashboard
// const { Dashboard, CreateRedirectURI } = require("./index");
const Dashboard = require("./index");
// Create an instance of a Discord client
const client = new Client();
//const oAuth = Discord.OAuth2Application;
//const { OAuth2Application } = require('discord.js');
const dashboard = new Dashboard(client, {
port: 4000,
clientSecret: process.env.clientSecret,
redirectURI: "http://localhost:4000/auth/discord/callback"
});
// Ready event of the Client
client.on('ready', () => {
dashboard.run();
//run(client, {port: 4000, clientSecret: process.env.clientSecret, redirectURI: "http://localhost:4000/auth/discord/callback"});
console.log('INFO >> ' + chalk.green('Bot is online'));
});
const clean = text => {
if (typeof(text) === "string")
return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203));
else
return text;
}
client.on("message", message => {
const args = message.content.split(" ").slice(1);
if (message.content.startsWith(process.env.prefix + "eval")) {
if(message.author.id !== process.env.ownerID) return;
try {
const code = args.join(" ");
let evaled = eval(code);
if (typeof evaled !== "string")
evaled = require("util").inspect(evaled);
message.channel.send(clean(evaled), {code:"xl"});
console.log('Eval >> ' + chalk.green(clean(evaled)));
} catch (err) {
message.channel.send(`\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``);
console.log('Eval >> ' + chalk.green(clean(err)));
}
}
});
// Log our bot in using the token from https://discordapp.com/developers/applications/
client.login(process.env.TOKEN);