This repository was archived by the owner on Nov 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,804 changed files
with
4,501 additions
and
4,520 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,5 @@ logs/ | |
data/coverage/ | ||
|
||
util/Jest_Cheatsheet\.md | ||
|
||
images/ |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
language: node_js | ||
node_js: | ||
- "9.6.1" | ||
install: | ||
- npm install -g codecov | ||
- npm install -g jest | ||
- npm install | ||
script: | ||
- jest --config ./util/jest.config.js && codecov | ||
before_install: | ||
- sudo apt-get update -qq | ||
- sudo apt-get install -qq libgif-dev |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const ioTools = new (require('../util/IOTools'))() | ||
const path = require('path') | ||
|
||
describe('The getImagePath(path) method works as expected.', () => { | ||
it('should return a path to the correct directory and file.', () => { | ||
expect(ioTools.getImagePath(path.join('alcha', 'Jerry-1.gif'))).toEqual(path.join('images', 'alcha', 'Jerry-1.gif')) | ||
expect(ioTools.getImagePath('null')).toBe('Invalid file path provided.') | ||
expect(ioTools.getImagePath('undefined')).toHaveLength(27) | ||
}) | ||
|
||
it('should return a message if the file is too large.', () => { | ||
expect(ioTools.getImagePath(path.join('test', 'LargeFile.png'))).toEqual('Provided file is too large to send over Discord.') | ||
}) | ||
|
||
it('should return an error message if an invalid file path is provided.', () => { | ||
expect(ioTools.getImagePath(path.join('test', 'asdfk.xml'))).toEqual('Invalid file path provided.') | ||
}) | ||
}) | ||
|
||
describe('The saveToFile(data, filename) method works as expected.', () => { | ||
it('should return the path and name of the saved file.', () => { | ||
return ioTools.saveToFile('TestData', 'test.log').then(res => { | ||
expect(res).toBe(path.join('data', 'filesSaved', 'test.log')) | ||
}) | ||
}) | ||
|
||
it('Should do return an error when the filename is anything other than a String.', async () => { | ||
try { | ||
const r = await ioTools.saveToFile('FileData', null) | ||
} catch (err) { | ||
expect(err.message).toBe("The \"path\" argument must be of type string") | ||
} | ||
}) | ||
|
||
it('Should throw an error when null is passed as the file data.', async () => { | ||
try { | ||
const r = await ioTools.saveToFile(null, null) | ||
} catch (err) { | ||
expect(err.message).toBe("Test") | ||
} | ||
}) | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
const { Client } = require('discord.js') | ||
const Tools = require('../util/Tools') | ||
const tools = new Tools() | ||
|
||
const testDateFormat = 'MM_YYYY_DD.HH:mm:ss' | ||
const formatTimeRegex = /[0-2]?[0-9]_\d{4}_[0-9]{2}.[0-2][0-9]:[0-6][0-9]:[0-6][0-9]/ | ||
|
||
describe('Unit testing of the Tools.js class and it\'s functions.', () => { | ||
test('The formatTime(format) function returns a properly formatted time.', () => { | ||
expect(tools.formatTime(testDateFormat)).toEqual(expect.stringMatching(formatTimeRegex)) | ||
}) | ||
|
||
test('The shortLogDate property getter returns a proper short date for logging.', () => { | ||
let logDate = tools.shortLogDate | ||
|
||
expect(logDate).toMatch(/\d{4}-[0-1][0-9]-[0-2][0-9]/) | ||
expect(logDate).toHaveLength(10) | ||
}) | ||
|
||
test('The shortUTCTime property getter returns a properly formatted UTC time.', () => { | ||
let utcTime = tools.shortUTCTime // moment.tz(UTC).format('HH:mm:ss.SS') | ||
|
||
expect(utcTime).toMatch(/[0-2][0-9]:[0-6][0-9]:[0-6][0-9].[0-9][0-9]/); | ||
expect(utcTime).toHaveLength(11) | ||
}) | ||
|
||
test('The formattedTime property getter returns a properly formatted date.', () => { | ||
expect(tools.formattedTime).toMatch(/[0-2]?.[0-9]{2}.\d{4} @ [0-2][0-9]:[0-6][0-9]:[0-6][0-9]/) | ||
}) | ||
|
||
test('The utcTime property getter returns the correct UTC time.', () => { | ||
let toolTime = tools.utcTime | ||
let nodeTime = new Date().toISOString() | ||
let toolTimeStr = toolTime.substring(0, toolTime.indexOf('Z')) | ||
let nodeTimeStr = nodeTime.substring(0, nodeTime.indexOf('.')) | ||
|
||
expect(toolTimeStr).toMatch(nodeTimeStr) | ||
}) | ||
|
||
test('The formattedUTCTime getter returns a properly formatted UTC time.', () => { | ||
expect(tools.formattedUTCTime).toMatch(/[0-1][0-9].[0-9]{2}.\d{4} @ [0-2][0-9]:[0-6][0-9]:[0-6][0-9]/) | ||
}) | ||
|
||
test('The safeFormattedTime getter returns a safely formatted time.', () => { | ||
expect(tools.safeFormattedTime).toMatch(/[0-1][0-9].[0-9]{2}.\d{4}_[0-2][0-9]:[0-6][0-9]:[0-6][0-9]/) | ||
}) | ||
|
||
test('The upperFirstC funcion capitalizes the first letter of the given string.', () => { | ||
expect(tools.upperFirstC("apollo")).toBe("Apollo") | ||
}); | ||
|
||
test('The numberWithCommas function converts a number larger than 1,000 to contain commas.', () => { | ||
expect(tools.numberWithCommas(999888777666555)).toBe("999,888,777,666,555") | ||
}) | ||
|
||
test('The getRandom(min, max) function gets a random number in the correct range.', () => { | ||
let random = tools.getRandom(0, 100) | ||
expect(random).toBeGreaterThanOrEqual(0) | ||
expect(random).toBeLessThan(100) | ||
}) | ||
|
||
// tools#formatUnixInput | ||
|
||
test('The formatUnixInput(timestamp) function properly formats a unix timestamp.', () => { | ||
let utcTime = new Date().toUTCString() | ||
expect(tools.formatUnixInput(utcTime)).toMatch(/[0-1][0-9]\/[0-2][0-9]\/[0-9]{4} [0-2][0-9]:[0-5][0-9]:[0-5][0-9]/) | ||
expect(tools.formatUnixInput(utcTime)).toHaveLength(19) | ||
}) | ||
|
||
// tools#formatUTCTime | ||
|
||
// tools#pickImage | ||
|
||
//tools.sendOwnerMessage("Haaiii", new Client()) | ||
}) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const Command = require('../BaseCmd') | ||
const IOTools = require('../../util/IOTools') | ||
const ioTools = new IOTools() | ||
|
||
module.exports = class Shank extends Command { | ||
constructor (client) { | ||
super(client, { | ||
name: 'shank', | ||
group: 'actions', | ||
memberName: 'shank', | ||
guildOnly: false, | ||
aliases: ['stab', 'shanks'], | ||
description: 'Returns a random shank gif and includes the mentions users username.', | ||
examples: ['+shank @Alcha#2625'], | ||
argsType: 'multiple' | ||
}) | ||
} | ||
|
||
async run (msg, args) { | ||
if (msg.mentions.users.size > 0) { | ||
var content = `${this.getMentionedUsernames(msg)}, you've been shanked by **${msg.author.username}**! :knife:` | ||
} | ||
|
||
ioTools.getRandomImage('shank', args).then(image => { | ||
msg.channel.send(content, { files: [image] }) | ||
}).catch(err => console.error(err)) | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.