mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-10 00:08:22 +03:00
Merged main
This commit is contained in:
+21
@@ -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.
|
||||
@@ -1,14 +0,0 @@
|
||||
/* eslint-disable no-undef */
|
||||
module.exports = {
|
||||
presets: [
|
||||
[
|
||||
"@babel/preset-env",
|
||||
{
|
||||
targets: {
|
||||
node: "16.6.0"
|
||||
}
|
||||
}
|
||||
],
|
||||
"@babel/preset-typescript",
|
||||
],
|
||||
};
|
||||
+1
-2
@@ -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",
|
||||
|
||||
@@ -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
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user