Skip to content

Commit

Permalink
Fixed tests,
Browse files Browse the repository at this point in the history
prepped for restoring JS to be default over TS
  • Loading branch information
crock committed Mar 22, 2019
1 parent 220d349 commit 64f6a85
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 612 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ node_modules/

# Useless files
.DS_Store
*.lock

# Private Configuration files
config.json
config.json

dist/
12 changes: 0 additions & 12 deletions babel.config.js

This file was deleted.

4 changes: 3 additions & 1 deletion commands/announce.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
exports.run = (client, message, args) => {
const Auth = require('../utils/auth')

exports.run = (message, args) => {

if (Auth.isAdmin(message.member)) {
if(!args || args.length < 1) return message.reply("Must provide the text for the announcement after the command.");
Expand Down
2 changes: 1 addition & 1 deletion commands/define.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ GUIDE
};

// run function for !define command:
exports.run = (client, message, args) => {
exports.run = (message, args) => {
if (args.length === 0)
return sendMessage(message, 'Use `!define --help` to get command guide.');
runUserCommand(message, args, args[0]);
Expand Down
3 changes: 2 additions & 1 deletion commands/helpme.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const Discord = require("discord.js");
const Config = require('../utils/config');

exports.run = (client, message, args) => {
exports.run = (message, args) => {

if(!args || args.length < 1) return message.reply(`, you must type your question after the command. You may also use "!helpme PRIVATE" if you would like your question to remain confidential.`);

Expand Down
4 changes: 3 additions & 1 deletion commands/poll.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
exports.run = (client, message, args) => {
const Auth = require('../utils/auth');

exports.run = (message, args) => {

if (Auth.isAdmin(message.member)) {
if(!args || args.length < 1) return message.reply("Must provide the text of the poll question after the command.");
Expand Down
12 changes: 6 additions & 6 deletions commands/reload.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
exports.run = (client, message, args) => {
if(!args || args.size < 1) return message.reply("Must provide a command name to reload.");
// the path is relative to the *current folder*, so just ./filename.js
delete require.cache[require.resolve(`./${args[0]}.js`)];
message.reply(`The command ${args[0]} has been reloaded`);
};
exports.run = (message, args) => {
if(!args || args.size < 1) return message.reply("Must provide a command name to reload.");
// the path is relative to the *current folder*, so just ./filename.js
delete require.cache[require.resolve(`./${args[0]}.js`)];
message.reply(`The command ${args[0]} has been reloaded`);
};
4 changes: 3 additions & 1 deletion events/guildMemberAdd.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
exports.run = (client, member) => {
const Config = require('../utils/config');

exports.run = (member) => {

// Send the message to a designated channel on a server:
const channel = member.guild.channels.get(Config.getChannel("joins"));
Expand Down
6 changes: 3 additions & 3 deletions events/message.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
exports.run = (client, msg) => {
exports.run = (msg) => {

if (msg.author.bot) return;
if(msg.content.indexOf(Config.getCommandPrefix()) !== 0) return;

const args = msg.content.slice(Config.getCommandPrefix().length).trim().split(/ +/g);
const command = args.shift().toLowerCase().replace('/', '');

try {
let commandFile = require(`../commands/${command}.js`);
commandFile.run(client, msg, args);
commandFile.run(msg, args);
} catch (err) {
console.error(err);
}
Expand Down
16 changes: 14 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
const moduleAlias = require('module-alias');

moduleAlias.addAliases({
'@root' : __dirname,
'@utils': __dirname + '/utils',
'@events': __dirname + '/events',
'@commands': __dirname + '/commands'
});

const Config = require('./utils/config');
const Auth = require('./utils/auth');

const Discord = require('discord.js');
const client = new Discord.Client();
Expand All @@ -15,8 +23,12 @@ fs.readdir('./events/', (err, files) => {
let eventName = file.split('.')[0];
let eventFile = require(`./events/${file}`);

client.on(eventName, (object) => eventFile.run(client, object));
client.on(eventName, (object) => eventFile.run(object));
});
});

client.login(Config.getBotToken());

module.exports = {
client
}
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
},
"dependencies": {
"discord.js": "^11.4.2",
"module-alias": "^2.2.0",
"request": "^2.88.0",
"request-promise-native": "^1.0.7"
},
"devDependencies": {
"@babel/core": "^7.3.3",
"@babel/preset-env": "^7.3.1",
"babel-jest": "^24.1.0",
"jest": "^24.1.0"
}
}
2 changes: 1 addition & 1 deletion tests/config.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Config = require('../utils/config').config;
const Config = require('../utils/config');

test('bot token returns string value', () => {
expect(Config.getBotToken()).toMatch(/[\w\d.]+/)
Expand Down
Loading

0 comments on commit 64f6a85

Please sign in to comment.