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 Dec 2, 2024
2 parents fe88a87 + 8d9cd6e commit 98f79f2
Show file tree
Hide file tree
Showing 174 changed files with 4,948 additions and 2,861 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

64 changes: 0 additions & 64 deletions .eslintrc.json

This file was deleted.

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

yarn format
yarn format:check
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git a/typings/index.d.mts b/typings/index.d.mts
index ad0b67870da010ffeb333ef06a67465b26e597b9..a1dee9410baf284b00c5c9b46e81e59478fafb36 100644
--- a/typings/index.d.mts
+++ b/typings/index.d.mts
@@ -12612,7 +12612,6 @@ export class User extends Base {
* The tag of this user
* <info>This user's username, or their legacy tag (e.g. `hydrabolt#0001`)
* if they're using the legacy username system</info>
- * @deprecated Use {@link User.username} instead.
*/
public get tag(): string;

diff --git a/typings/index.d.ts b/typings/index.d.ts
index e0e47f7eb14045140ea8ea2dd1c4e40482668294..672de5f8b8b7f3a6babf7f96b94fbdab710c5ac0 100644
--- a/typings/index.d.ts
+++ b/typings/index.d.ts
@@ -12612,7 +12612,6 @@ export class User extends Base {
* The tag of this user
* <info>This user's username, or their legacy tag (e.g. `hydrabolt#0001`)
* if they're using the legacy username system</info>
- * @deprecated Use {@link User.username} instead.
*/
public get tag(): string;

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

This file was deleted.

934 changes: 934 additions & 0 deletions .yarn/releases/yarn-4.5.3.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ pnpEnableEsmLoader: true

pnpMode: loose

yarnPath: .yarn/releases/yarn-4.1.1.cjs
yarnPath: .yarn/releases/yarn-4.5.3.cjs
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Tanzanite is a multipurpose moderation and utility bot. It contains an extensive

<h3>Prerequisites</h3>

- <a href="https://nodejs.org/en/">Node.JS</a> v18.0.0+
- <a href="https://nodejs.org/en/">Node.JS</a> v20.11.0+
- <a href="https://yarnpkg.com/getting-started/install">Yarn</a>
- <a href="https://git-scm.com/">git</a>
- <a href="https://discord.com/developers/applications">A discord bot to use</a>
Expand Down
1 change: 1 addition & 0 deletions config/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ export type Channels = {
* The id of a channel to send logging messages in,
* use an empty string for no channel to be used.
*/
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
[Key in ConfigChannelKey]: EnvironmentMap<Snowflake | ''>;
};

Expand Down
2 changes: 1 addition & 1 deletion ecosystem.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = {
user,
host,
'ref': `origin/${e === 'production' ? 'master' : 'beta'}`,
'repo': 'https://code.ironmoon.dev/Tanzanite/tanzanite.git',
'repo': 'https://github.com/TanzaniteBot/tanzanite.git',
'path': `/code/tanzanite${e === 'beta' ? '-beta' : ''}`,
'post-deploy': `yarn install && yarn build && pm2 start ecosystem.config.cjs --only tanzanite${
e === 'beta' ? '-beta' : ''
Expand Down
98 changes: 98 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
//@ts-check
import eslint from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
//@ts-expect-error: no types
import importPlugin from 'eslint-plugin-import';
import tseslint from 'typescript-eslint';

export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
// tseslint.configs.strictTypeChecked,
importPlugin.flatConfigs.recommended,
importPlugin.flatConfigs.typescript,
eslintConfigPrettier,
{
ignores: ['dist', '.yarn', 'node_modules', '*.nnb', 'tooltips*'],

languageOptions: {
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: './tsconfig.eslint.json'
}
},

rules: {
'no-return-await': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'no-mixed-spaces-and-tabs': 'off',
'no-duplicate-imports': 'warn',
'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': 'off',
'no-empty': 'off',
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-expect-error': 'allow-with-description',
'ts-ignore': 'allow-with-description',
'ts-nocheck': 'allow-with-description',
'ts-check': false,
'minimumDescriptionLength': 5
}
],
'@typescript-eslint/no-floating-promises': 'warn',
'prefer-promise-reject-errors': 'warn',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-base-to-string': 'error',
'no-loss-of-precision': 'off',
'@typescript-eslint/no-loss-of-precision': 'error',
'no-throw-literal': 'off',
'@typescript-eslint/only-throw-error': 'warn',
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'prefer-template': 'warn',
'@typescript-eslint/no-this-alias': ['error', { allowDestructuring: true, allowedNames: ['that'] }],
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_'
}
],
'no-implied-eval': 'off',
'@typescript-eslint/no-implied-eval': ['error'],
'@typescript-eslint/no-deprecated': 'warn',
'@typescript-eslint/explicit-member-accessibility': ['warn', { accessibility: 'explicit' }],
'@typescript-eslint/switch-exhaustiveness-check': 'warn',
'@typescript-eslint/no-restricted-imports': [
'error',
{ paths: [{ name: 'console', importNames: ['assert'], message: 'Import from the `assert` module instead.' }] }
],
'@typescript-eslint/no-namespace': 'off',
'no-debugger': 'warn',
'@typescript-eslint/prefer-as-const': 'warn',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-unsafe-declaration-merging': 'off',
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
'@typescript-eslint/require-await': 'warn',
'@typescript-eslint/no-unused-expressions': 'warn',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'warn',

'prefer-const': 'warn',
'import/no-unresolved': 'off', // until it supports subpath imports
'import/extensions': ['error', 'ignorePackages'],
'import/no-cycle': 'error',

'no-warning-comments': 'warn'
}
}
);
2 changes: 1 addition & 1 deletion lib/arguments/contentWithDuration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parseDuration, type BotArgumentTypeCaster, type ParsedDuration } from '#lib';

export const contentWithDuration: BotArgumentTypeCaster<Promise<ParsedDuration>> = async (_, phrase) => {
export const contentWithDuration: BotArgumentTypeCaster<ParsedDuration> = (_, phrase) => {
return parseDuration(phrase);
};
2 changes: 2 additions & 0 deletions lib/arguments/diceNotation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { formatList, type BotArgumentTypeCaster } from '#lib';
import type { DiceExpression } from '#lib/dice/diceExpression.js';
import { parseDiceNotation } from '#lib/dice/evalDice.js';
Expand Down
1 change: 1 addition & 0 deletions lib/arguments/tinyColor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ assert(tinycolorModule);

export const tinyColor: BotArgumentTypeCaster<string | null> = (_message, phrase) => {
// if the phase is a number it converts it to hex incase it could be representing a color in decimal
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const newPhase = isNaN(phrase as any) ? phrase : `#${Number(phrase).toString(16)}`;
return tinycolorModule(newPhase).isValid() ? newPhase : null;
};
27 changes: 14 additions & 13 deletions lib/automod/AutomodShared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {
ButtonStyle,
ComponentType,
GuildMember,
MessageFlags,
PermissionFlagsBits,
type BaseMessageOptions,
type ButtonInteraction,
type Message,
type Snowflake
} from 'discord.js';
import assert from 'node:assert/strict';
Expand Down Expand Up @@ -154,7 +154,7 @@ export async function handleAutomodInteraction(interaction: ButtonInteraction) {
if (!interaction.memberPermissions?.has(PermissionFlagsBits.BanMembers)) {
return interaction.reply({
content: `${emojis.error} You are missing the **Ban Members** permission.`,
ephemeral: true
flags: MessageFlags.Ephemeral
});
}

Expand All @@ -175,18 +175,18 @@ export async function handleAutomodInteraction(interaction: ButtonInteraction) {
if (!interaction.guild?.members.me?.permissions.has('BanMembers')) {
return interaction.reply({
content: `${emojis.error} I do not have permission to ${action} members.`,
ephemeral: true
flags: MessageFlags.Ephemeral
});
}

const check = victim ? await Moderation.permissionCheck(moderator, victim, Moderation.Action.Ban, true) : true;
if (check !== true) return interaction.reply({ content: check, ephemeral: true });
if (check !== true) return interaction.reply({ content: check, flags: MessageFlags.Ephemeral });

const result = await interaction.guild?.customBan({
user: userId,
reason,
moderator: interaction.user.id,
evidence: (interaction.message as Message).url ?? undefined
evidence: interaction.message.url ?? undefined
});

const success = result === unmuteResponse.Success || result === unmuteResponse.DmError;
Expand All @@ -199,33 +199,34 @@ export async function handleAutomodInteraction(interaction: ButtonInteraction) {

return interaction[success ? 'followUp' : 'reply']({
content: await formatBanResponseId(interaction.client, userId, result),
ephemeral: true
flags: MessageFlags.Ephemeral
});
}

case 'unmute': {
if (!victim)
return interaction.reply({
content: `${emojis.error} Cannot find member, they may have left the server.`,
ephemeral: true
flags: MessageFlags.Ephemeral
});

if (!interaction.guild)
return interaction.reply({
content: `${emojis.error} This is weird, I don't seem to be in the server...`,
ephemeral: true
flags: MessageFlags.Ephemeral
});

const check = await Moderation.permissionCheck(moderator, victim, Moderation.Action.Unmute, true);
if (check !== true) return interaction.reply({ content: check, ephemeral: true });
if (check !== true) return interaction.reply({ content: check, flags: MessageFlags.Ephemeral });

const check2 = await Moderation.checkMutePermissions(interaction.guild);
if (check2 !== true) return interaction.reply({ content: formatUnmuteResponse('/', victim, check2), ephemeral: true });
if (check2 !== true)
return interaction.reply({ content: formatUnmuteResponse('/', victim, check2), flags: MessageFlags.Ephemeral });

const result = await victim.customUnmute({
reason,
moderator: interaction.member as GuildMember,
evidence: (interaction.message as Message).url ?? undefined
evidence: interaction.message.url ?? undefined
});

const success = result === unmuteResponse.Success || result === unmuteResponse.DmError;
Expand All @@ -238,14 +239,14 @@ export async function handleAutomodInteraction(interaction: ButtonInteraction) {

return interaction[success ? 'followUp' : 'reply']({
content: formatUnmuteResponse('/', victim, result),
ephemeral: true
flags: MessageFlags.Ephemeral
});
}

case 'dismiss': {
// if the victim is null, still allow to dismiss
const check = victim ? await Moderation.permissionCheck(moderator, victim, Moderation.Action.Unmute, true) : true;
if (check !== true) return interaction.reply({ content: check, ephemeral: true });
if (check !== true) return interaction.reply({ content: check, flags: MessageFlags.Ephemeral });

await interaction.update({
components: handledComponents(action, moderator.user.tag)
Expand Down
Loading

0 comments on commit 98f79f2

Please sign in to comment.