-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
cdbf27f
commit 9023a41
Showing
16 changed files
with
1,277 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,122 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es6": true, | ||
"node": true | ||
}, | ||
"extends": [ | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:@typescript-eslint/recommended-requiring-type-checking" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"project": "tsconfig.json", | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint" | ||
], | ||
"rules": { | ||
"@typescript-eslint/array-type": "off", | ||
"@typescript-eslint/indent": [ | ||
"warn", | ||
4 | ||
], | ||
"@typescript-eslint/interface-name-prefix": "off", | ||
"@typescript-eslint/member-delimiter-style": [ | ||
"error", | ||
{ | ||
"multiline": { | ||
"delimiter": "semi", | ||
"requireLast": true | ||
}, | ||
"singleline": { | ||
"delimiter": "semi", | ||
"requireLast": false | ||
} | ||
} | ||
], | ||
"no-undef": "error", | ||
"@typescript-eslint/no-empty-function": "warn", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/unbound-method": "off", | ||
"@typescript-eslint/no-parameter-properties": "off", | ||
"@typescript-eslint/no-use-before-define": "off", | ||
"@typescript-eslint/prefer-for-of": "warn", | ||
"@typescript-eslint/no-unused-vars": "warn", | ||
"@typescript-eslint/prefer-function-type": "warn", | ||
"@typescript-eslint/explicit-function-return-type": "warn", | ||
"@typescript-eslint/no-var-requires": "off", | ||
"prefer-template": "warn", | ||
"@typescript-eslint/no-non-null-assertion": "off", | ||
"@typescript-eslint/no-floating-promises": "off", | ||
"@typescript-eslint/no-unsafe-assignment": "off", | ||
"@typescript-eslint/no-unsafe-call": "off", | ||
"@typescript-eslint/no-unsafe-member-access": "off", | ||
"@typescript-eslint/no-unsafe-return": "off", | ||
"@typescript-eslint/restrict-template-expressions": "off", | ||
"@typescript-eslint/quotes": [ | ||
"warn", | ||
"double", | ||
{ | ||
"avoidEscape": true | ||
} | ||
], | ||
"@typescript-eslint/semi": [ | ||
"warn", | ||
"always" | ||
], | ||
"@typescript-eslint/no-misused-promises": "warn", | ||
"@typescript-eslint/require-await": "warn", | ||
"@typescript-eslint/unified-signatures": "error", | ||
"complexity": "off", | ||
"constructor-super": "warn", | ||
"dot-notation": "warn", | ||
"import/order": "off", | ||
"max-classes-per-file": [ | ||
"warn", | ||
3 | ||
], | ||
"new-parens": "error", | ||
"no-bitwise": "error", | ||
"no-caller": "error", | ||
"no-cond-assign": "error", | ||
"no-console": "warn", | ||
"no-debugger": "warn", | ||
"no-empty": "warn", | ||
"no-eval": "warn", | ||
"no-fallthrough": "off", | ||
"no-invalid-this": "off", | ||
"no-new-wrappers": "error", | ||
"no-shadow": [ | ||
"off", | ||
{ | ||
"hoist": "all" | ||
} | ||
], | ||
"no-var": "warn", | ||
"no-alert": "error", | ||
"no-extra-label": "warn", | ||
"no-extra-parens": "off", | ||
"no-extra-semi": "warn", | ||
"no-throw-literal": "error", | ||
"no-const-assign": "error", | ||
"no-useless-return": "warn", | ||
"no-unreachable": "warn", | ||
"no-trailing-spaces": "warn", | ||
"no-undef-init": "error", | ||
"no-underscore-dangle": "warn", | ||
"no-unsafe-finally": "warn", | ||
"no-unused-expressions": "warn", | ||
"no-unused-labels": "warn", | ||
"object-shorthand": "warn", | ||
"one-var": [ | ||
"error", | ||
"never" | ||
], | ||
"radix": "off", | ||
"spaced-comment": "warn", | ||
"use-isnan": "warn", | ||
"valid-typeof": "off" | ||
} | ||
} |
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,22 @@ | ||
# Packages | ||
node_modules/ | ||
|
||
# Log files | ||
logs/ | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Env | ||
.env | ||
config.json | ||
|
||
# Dist | ||
dist/ | ||
|
||
# Miscellaneous | ||
.tmp/ |
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,14 @@ | ||
|
||
Copyright (c) 2020 youKnowOwO | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
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,4 @@ | ||
{ | ||
prefix:, | ||
owners: [] | ||
} |
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,25 @@ | ||
{ | ||
"name": "Yumeko", | ||
"version": "1.0.0", | ||
"description": "A simple multipurpose bot", | ||
"main": "dist/index.js", | ||
"repository": "https://github.com/youKnowOwO/yumeko-ts.git", | ||
"author": "youKnowOwO <[email protected]>", | ||
"license": "Apache-2.0", | ||
"private": false, | ||
"devDependencies": { | ||
"@types/common-tags": "^1.8.0", | ||
"@types/node": "^14.0.23", | ||
"@typescript-eslint/eslint-plugin": "^3.6.1", | ||
"@typescript-eslint/parser": "^3.6.1", | ||
"eslint": "^7.4.0", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^3.9.6" | ||
}, | ||
"dependencies": { | ||
"chalk": "^4.1.0", | ||
"common-tags": "^1.8.0", | ||
"discord.js": "^12.2.0", | ||
"moment": "^2.27.0" | ||
} | ||
} |
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,15 @@ | ||
import { Client } from "discord.js"; | ||
import Logger from "./Logger"; | ||
|
||
const config = require("../../config.json"); | ||
|
||
export default class YumekoClient extends Client { | ||
public config = config; | ||
public log = new Logger(); | ||
public constructor() { | ||
super({ | ||
fetchAllMembers: true, | ||
disableMentions: "everyone" | ||
}); | ||
} | ||
} |
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,15 @@ | ||
import { Event } from "../interfaces"; | ||
import Client from "./Client"; | ||
import readdirRecursive from "../util/ReaddirRecursive"; | ||
import { join } from "path"; | ||
|
||
export function EventLoader (client: Client): void { | ||
const path = join(__dirname, "../events"); | ||
const files = readdirRecursive(path); | ||
for(const file of files) { | ||
const event: Event = new (require(file).default)(); | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-expect-error-next-line 2345 | ||
client[event.once ? "once" : "on"](event.listener, event.exec); | ||
} | ||
} |
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,45 @@ | ||
import * as chalk from "chalk"; | ||
import moment from "moment"; | ||
import { stripIndents } from "common-tags"; | ||
import { format } from "util"; | ||
|
||
const defaultFormat = "MMMM Do YYYY, h:mm:ss a"; | ||
|
||
export default class Logger { | ||
public constructor(public format = defaultFormat) {} | ||
public write (head: string, value: string,): void { | ||
const date = moment(Date.now()).format(this.format); | ||
const log = stripIndents` | ||
${this.getEquals(head)} ${chalk.bold(head)} ${this.getEquals(head)} | ||
${value} | ||
${this.getEquals(date)} ${chalk.grey(date)} ${this.getEquals(date)}\n | ||
`; | ||
process.stdout.write(log); | ||
} | ||
|
||
public color(input: unknown, hex: string): string { | ||
input = typeof input === "string" ? input : format(input); | ||
return chalk.hex(hex)(input); | ||
} | ||
|
||
public getEquals(input: string, max = 8): string { | ||
const result = input.length > max ? 0 : max - input.length; | ||
return "=".repeat(result); | ||
} | ||
|
||
public print(input: unknown): void { | ||
process.stdout.write(format(input)); | ||
} | ||
|
||
public info(head: string, value: unknown): void { | ||
return this.write(this.color(head, "2ECC71"), this.color(value, "1F8B4C")); | ||
} | ||
|
||
public error(head: string, value: unknown): void { | ||
return this.write(this.color(head, "E74C3C"), this.color(value, "C27C0E")); | ||
} | ||
|
||
public warn(head: string, value: unknown): void { | ||
return this.write(this.color(head, "FFFF00"), this.color(value, "992D22")); | ||
} | ||
} |
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,5 @@ | ||
import Client from "./classes/Client"; | ||
|
||
const client = new Client(); | ||
|
||
client.login(); |
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,34 @@ | ||
import { PermissionString, Message } from "discord.js"; | ||
|
||
export interface CommmandOption { | ||
description: { | ||
content: string; | ||
usage: string; | ||
examples: string[]; | ||
adionalInfo?: string[]; | ||
}; | ||
permissions?: { | ||
client?: PermissionString[]; | ||
user?: PermissionString[]; | ||
}; | ||
category: string; | ||
aliases: string[]; | ||
cooldown?: number; | ||
disable?: boolean; | ||
devOnly?: boolean; | ||
arguments?: Argument[]; | ||
} | ||
|
||
export type ArgumentTypeFunction = <T>(msg: Message, content: string) => T; | ||
|
||
export interface Argument { | ||
identifier: string; | ||
match: "rest" | "single" | "multiple" | "flag"; | ||
type?: ArgumentTypeFunction | string; | ||
optional?: boolean; | ||
flag?: string; | ||
prompt?: { | ||
ask?: ((msg: Message, type: ArgumentTypeFunction ) => string) | string; | ||
retry?: ((msg: Message, type: ArgumentTypeFunction ) => string) | string; | ||
}; | ||
} |
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,4 @@ | ||
export interface Event { | ||
readonly listener: string; | ||
exec: (...args: unknown[]) => unknown; | ||
} |
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,2 @@ | ||
export * from "./Command"; | ||
export * from "./Event"; |
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,13 @@ | ||
import { readFileSync } from "fs"; | ||
import { join } from "path"; | ||
|
||
function EnvLoader (): void { | ||
const path = join(process.cwd(), ".env"); | ||
const file = readFileSync(path, { encoding: "utf8" }); | ||
for (const env of file.split("\n")) { | ||
const [name, value] = env.split("="); | ||
process.env[name] = value; | ||
} | ||
} | ||
|
||
EnvLoader(); |
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,19 @@ | ||
import { readdirSync, statSync } from "fs"; | ||
import { join } from "path"; | ||
|
||
export default function readdirRecursive(directory: string): string[] { | ||
const results: string[] = []; | ||
|
||
function read(path: string): void { | ||
const files = readdirSync(path); | ||
|
||
for(const file of files){ | ||
const dir = join(path, file); | ||
if(statSync(dir).isDirectory()) read(dir); | ||
else results.push(dir); | ||
} | ||
} | ||
read(directory); | ||
|
||
return results; | ||
} |
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,21 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2020", | ||
"module": "commonjs", | ||
"allowJs": true, | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"noImplicitAny": true, | ||
"alwaysStrict": true, | ||
"allowSyntheticDefaultImports": true, | ||
"esModuleInterop": true, | ||
"resolveJsonModule": true, | ||
"typeRoots": [ | ||
"node_modules/@types", | ||
"typings" | ||
], | ||
"outDir": "./dist" | ||
}, | ||
"include": ["src/**/*", "typings/*", "src/commands/**/*.json"], | ||
"exclude": ["node_modules/**"] | ||
} |
Oops, something went wrong.