Merged main

This commit is contained in:
Noah Heague
2021-09-05 15:47:20 +10:00
5 changed files with 842 additions and 1639 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Team NG
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-14
View File
@@ -1,14 +0,0 @@
/* eslint-disable no-undef */
module.exports = {
presets: [
[
"@babel/preset-env",
{
targets: {
node: "16.6.0"
}
}
],
"@babel/preset-typescript",
],
};
+1 -2
View File
@@ -8,9 +8,8 @@
"setup": "./scripts/createEnv.sh"
},
"devDependencies": {
"@babel/preset-env": "^7.15.0",
"@babel/preset-typescript": "^7.15.0",
"@types/jest": "^27.0.1",
"@types/node": "^16.7.10",
"@typescript-eslint/eslint-plugin": "^4.29.1",
"@typescript-eslint/parser": "^4.29.1",
"discord-api-types": "^0.22.0",
-56
View File
@@ -1,56 +0,0 @@
import { Message } from "discord.js";
import { shouldReply } from "./utils";
// Mock Data
interface MockMessage {
author: {
id: string;
bot: boolean;
};
channelId: string;
content?: string;
}
const selfMessage: MockMessage = {
author: {
id: "876320894295887944",
bot: true,
},
channelId: "876321394005254214"
};
const botMessage: MockMessage = {
author: {
id: "uniqueSnowflake",
bot: true,
},
channelId: "876321394005254214"
};
const invalidChannel: MockMessage = {
author: {
id: "uniqueSnowflake",
bot: false
},
channelId: "uniqueSnowflake"
};
const validMessage: MockMessage = {
author: {
id: "uniqueSnowflake",
bot: false
},
channelId: "876321394005254214"
};
// Tests
describe("shouldReply", () => {
test("should not reply to self", () => {
expect(shouldReply(selfMessage as Message)).toEqual(false);
});
test("should not reply to a bot", () => {
expect(shouldReply(botMessage as Message)).toEqual(false);
});
test("should not reply in an invalid channel", () => {
expect(shouldReply(invalidChannel as Message)).toEqual(false);
});
test("should reply to a valid message", () => {
expect(shouldReply(validMessage as Message)).toEqual(true);
});
});
+820 -1567
View File
File diff suppressed because it is too large Load Diff