Skip to content

Commit

Permalink
Merge branch 'master' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
IRONM00N committed Jan 13, 2024
2 parents 42bdfdf + 29e472e commit 768c921
Show file tree
Hide file tree
Showing 154 changed files with 3,983 additions and 4,730 deletions.
6 changes: 4 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"ts-expect-error": "allow-with-description",
"ts-ignore": "allow-with-description",
"ts-nocheck": "allow-with-description",
"ts-check": "allow-with-description",
"ts-check": false,
"minimumDescriptionLength": 5
}
],
Expand Down Expand Up @@ -57,6 +57,8 @@
"no-debugger": "warn",
"@typescript-eslint/prefer-as-const": "warn",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-inferrable-types": "off"
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-unsafe-declaration-merging": "off",
"prefer-const": "warn"
}
}
32 changes: 8 additions & 24 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install node.js v18
- name: Install node.js v20
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
cache: 'yarn'
cache-dependency-path: yarn.lock

Expand All @@ -34,38 +34,22 @@ jobs:
- name: Dry Run
run: yarn start:dry

formatting:
name: Formatting
check-format:
name: Check Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0

- name: Install node.js v18
- name: Install node.js v20
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
cache: 'yarn'
cache-dependency-path: yarn.lock

- name: Install dependencies
run: yarn --immutable

- name: Configure Git
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Format and Commit
run: |
yarn format
git commit -am "Automatically format code" || true
- name: Push Changes
uses: NotEnoughUpdates/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
- name: Prettier Check
run: yarn format:check
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ config/options.ts

src/lib/badlinks-secret.ts
lib/badlinks-secret.ts

ecosystem-info.json
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn format
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"neu-item-repo": true
},
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.format": true
"source.organizeImports": "explicit",
"source.format": "explicit"
},
"editor.formatOnSave": true,
"diffEditor.wordWrap": "on",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/types/index.d.ts b/types/index.d.ts
index e7d7e211e4a41c693bf1e8022490d0a0498cef0c..eb2a8d92477e91996515353a359bef35ce5bd60a 100644
index 98ebe711148cbfd499da864118e0cabd1e2c9601..f17239d2d0bf9db11e3b4efa764a7e1eaef3daa9 100644
--- a/types/index.d.ts
+++ b/types/index.d.ts
@@ -2,7 +2,7 @@ import { Decimal } from 'decimal.js'
Expand Down
363 changes: 0 additions & 363 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

This file was deleted.

9 changes: 0 additions & 9 deletions .yarn/plugins/@yarnpkg/plugin-typescript.cjs

This file was deleted.

873 changes: 0 additions & 873 deletions .yarn/releases/yarn-3.5.0.cjs

This file was deleted.

893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.0.2.cjs

Large diffs are not rendered by default.

10 changes: 3 additions & 7 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
compressionLevel: mixed

enableGlobalCache: true

enableTelemetry: false

nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: '@yarnpkg/plugin-interactive-tools'
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: '@yarnpkg/plugin-typescript'

pnpEnableEsmLoader: true

pnpMode: loose

yarnPath: .yarn/releases/yarn-3.5.0.cjs
yarnPath: .yarn/releases/yarn-4.0.2.cjs
10 changes: 10 additions & 0 deletions config/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,23 @@ export type Logging = {
* Whether or not to log database queries, verbose logs, or informational logs
*/
[Key in LoggingType]: boolean;
} & {
/**
* Override default behavior
*/
[Key in OverrideLog]?: boolean;
};

/**
* The logging level that can be changed.
*/
export type LoggingType = 'db' | 'verbose' | 'info';

/**
* Override the default logging behavior
*/
export type OverrideLog = 'success' | 'error' | 'warn' | 'veryVerbose' | 'debug' | 'noMessage' | 'noRaw';

/**
* Information regarding the bot's support server.
*/
Expand Down
14 changes: 12 additions & 2 deletions ecosystem.config.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
let user, host;

try {
({ user, host } = require('./ecosystem-info.json'));
} catch (e) {
user = 'ironmoon';
host = 'localhost';
}

module.exports = {
apps: [
...['', '-beta'].map((e) => ({
Expand All @@ -19,8 +29,8 @@ module.exports = {
['production', 'beta'].map((e) => [
e,
{
'user': 'ironmoon',
'host': '192.168.1.11',
user,
host,
'ref': `origin/${e === 'production' ? 'master' : 'beta'}`,
'repo': 'https://github.com/TanzaniteBot/tanzanite.git',
'path': `/code/tanzanite${e === 'beta' ? '-beta' : ''}`,
Expand Down
1 change: 1 addition & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "extends": "./tsconfig.base.json" }
6 changes: 3 additions & 3 deletions lib/automod/AutomodShared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { formatBanResponseId, formatUnmuteResponse } from '#lib/utils/FormatResp
import {
ActionRowBuilder,
ButtonBuilder,
ButtonInteraction,
ButtonStyle,
ComponentType,
GuildMember,
Message,
PermissionFlagsBits,
type BaseMessageOptions,
type ButtonInteraction,
type Message,
type Snowflake
} from 'discord.js';
import assert from 'node:assert/strict';
Expand Down Expand Up @@ -280,7 +280,7 @@ export function handledComponents(action: 'ban' | 'unmute' | 'dismiss', tag: str
/**
* The severity of the blacklisted word
*/
export const enum Severity {
export enum Severity {
/**
* Delete message
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/automod/MemberAutomod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stripIndent } from '#tags';
import { EmbedBuilder, GuildMember } from 'discord.js';
import { EmbedBuilder, type GuildMember } from 'discord.js';
import { Automod, type BadWordDetails } from './AutomodShared.js';

export class MemberAutomod extends Automod {
Expand Down
92 changes: 46 additions & 46 deletions lib/automod/MessageAutomod.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { colors } from '#lib/utils/Constants.js';
import { Time, colors } from '#lib/utils/Constants.js';
import { format, formatError } from '#lib/utils/Utils.js';
import { stripIndent } from '#tags';
import chalk from 'chalk';
//~ import chalk from 'chalk';
import { EmbedBuilder, PermissionFlagsBits, type GuildTextBasedChannel, type Message } from 'discord.js';
import assert from 'node:assert/strict';
import { Automod, Severity, type BadWordDetails } from './AutomodShared.js';
Expand Down Expand Up @@ -86,7 +86,7 @@ export class MessageAutomod extends Automod {
if (!this.punished && (await this.guild.hasFeature('delScamMentions'))) void this.checkScamMentions();
}

if (!this.punished && (await this.guild.hasFeature('perspectiveApi'))) void this.checkPerspectiveApi();
// ~if (!this.punished && (await this.guild.hasFeature('perspectiveApi'))) void this.checkPerspectiveApi();
}

/**
Expand Down Expand Up @@ -141,52 +141,52 @@ export class MessageAutomod extends Automod {
}
}

protected async checkPerspectiveApi() {
return;
if (!this.client.config.isDevelopment) return;
//~ protected async checkPerspectiveApi() {
//~ return;
//~ if (!this.client.config.isDevelopment) return;

if (!this.message.content) return;
this.client.perspective.comments.analyze(
{
key: this.client.config.credentials.perspectiveApiKey,
resource: {
comment: {
text: this.message.content
},
requestedAttributes: {
TOXICITY: {},
SEVERE_TOXICITY: {},
IDENTITY_ATTACK: {},
INSULT: {},
PROFANITY: {},
THREAT: {},
SEXUALLY_EXPLICIT: {},
FLIRTATION: {}
}
}
},
(err: any, response: any) => {
if (err) return console.log(err?.message);
//~ if (!this.message.content) return;
//~ this.client.perspective.comments.analyze(
//~ {
//~ key: this.client.config.credentials.perspectiveApiKey,
//~ resource: {
//~ comment: {
//~ text: this.message.content
//~ },
//~ requestedAttributes: {
//~ TOXICITY: {},
//~ SEVERE_TOXICITY: {},
//~ IDENTITY_ATTACK: {},
//~ INSULT: {},
//~ PROFANITY: {},
//~ THREAT: {},
//~ SEXUALLY_EXPLICIT: {},
//~ FLIRTATION: {}
//~ }
//~ }
//~ },
//~ (err: any, response: any) => {
//~ if (err) return console.log(err?.message);

const normalize = (val: number, min: number, max: number) => (val - min) / (max - min);
//~ const normalize = (val: number, min: number, max: number) => (val - min) / (max - min);

const color = (val: number) => {
if (val >= 0.5) {
const x = 194 - Math.round(normalize(val, 0.5, 1) * 194);
return chalk.rgb(194, x, 0)(val);
} else {
const x = Math.round(normalize(val, 0, 0.5) * 194);
return chalk.rgb(x, 194, 0)(val);
}
};
//~ const color = (val: number) => {
//~ if (val >= 0.5) {
//~ const x = 194 - Math.round(normalize(val, 0.5, 1) * 194);
//~ return chalk.rgb(194, x, 0)(val);
//~ } else {
//~ const x = Math.round(normalize(val, 0, 0.5) * 194);
//~ return chalk.rgb(x, 194, 0)(val);
//~ }
//~ };

console.log(chalk.cyan(this.message.content));
Object.entries(response.data.attributeScores)
.sort(([a], [b]) => a.localeCompare(b))
.forEach(([key, value]: any[]) => console.log(chalk.white(key), color(value.summaryScore.value)));
}
);
}
//~ console.log(chalk.cyan(this.message.content));
//~ Object.entries(response.data.attributeScores)
//~ .sort(([a], [b]) => a.localeCompare(b))
//~ .forEach(([key, value]: any[]) => console.log(chalk.white(key), color(value.summaryScore.value)));
//~ }
//~ );
//~ }

/**
* Punishes the user based on the severity of the offense
Expand Down Expand Up @@ -214,7 +214,7 @@ export class MessageAutomod extends Automod {
void this.member.customMute({
moderator: this.guild!.members.me!,
reason: `[Automod] ${highestOffense.reason}`,
duration: 900_000 // 15 minutes
duration: 15 * Time.Minute
});
this.punished = true;
break;
Expand Down
2 changes: 1 addition & 1 deletion lib/automod/PresenceAutomod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stripIndent } from '#tags';
import { EmbedBuilder, Presence } from 'discord.js';
import { EmbedBuilder, type Presence } from 'discord.js';
import { Automod, type BadWordDetails } from './AutomodShared.js';

export class PresenceAutomod extends Automod {
Expand Down
2 changes: 1 addition & 1 deletion lib/common/Appeals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
formatUnmuteResponse,
formatUntimeoutResponse
} from '#lib/utils/FormatResponse.js';
import { capitalize, ModalInput } from '#lib/utils/Utils.js';
import { ModalInput, capitalize } from '#lib/utils/Utils.js';
import { AppealStatus, ModLog } from '#models';
import {
ActionRowBuilder,
Expand Down
Loading

0 comments on commit 768c921

Please sign in to comment.