From d5d5fd6f77f2d778ab099d52f1acaad762712822 Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Fri, 4 Feb 2022 14:08:09 -0500 Subject: explicit member accessibility & jsdocs & typings --- .eslintrc.json | 3 ++- src/commands/config/config.ts | 4 ++-- src/commands/dev/superUser.ts | 2 +- src/commands/info/avatar.ts | 4 ++-- src/commands/info/icon.ts | 4 ++-- src/commands/info/pronouns.ts | 2 +- src/commands/moderation/evidence.ts | 2 +- src/commands/moderation/role.ts | 6 +++--- src/commands/utilities/activity.ts | 6 +++--- src/commands/utilities/steal.ts | 4 ++-- src/lib/extensions/discord-akairo/BushClient.ts | 4 ++-- src/lib/extensions/discord-akairo/BushClientUtil.ts | 6 +++--- src/lib/extensions/discord-akairo/BushListenerHandler.ts | 2 +- src/lib/models/instance/ActivePunishment.ts | 5 ++++- src/lib/models/instance/Guild.ts | 3 +++ src/lib/models/instance/Level.ts | 3 +++ src/lib/models/instance/ModLog.ts | 3 +++ src/lib/models/instance/Reminder.ts | 3 +++ src/lib/models/instance/StickyRole.ts | 3 +++ src/lib/models/shared/Global.ts | 3 +++ src/lib/models/shared/Shared.ts | 3 +++ src/lib/models/shared/Stat.ts | 3 +++ src/lib/utils/CanvasProgressBar.ts | 8 ++++---- src/listeners/commands/commandError.ts | 2 +- 24 files changed, 58 insertions(+), 30 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index de3fb7c..a22ca42 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -58,6 +58,7 @@ ], "no-implied-eval": "off", "@typescript-eslint/no-implied-eval": ["error"], - "deprecation/deprecation": "warn" + "deprecation/deprecation": "warn", + "@typescript-eslint/explicit-member-accessibility": ["warn", { "accessibility": "explicit" }] } } diff --git a/src/commands/config/config.ts b/src/commands/config/config.ts index 580f8d2..2fae2fd 100644 --- a/src/commands/config/config.ts +++ b/src/commands/config/config.ts @@ -9,7 +9,7 @@ import { type GuildSettingType } from '#lib'; import assert from 'assert'; -import { SlashOption, type ArgumentOptions, type Flag } from 'discord-akairo'; +import { type ArgumentGeneratorReturn, type SlashOption } from 'discord-akairo'; import { ActionRow, ApplicationCommandOptionType, @@ -130,7 +130,7 @@ export default class ConfigCommand extends BushCommand { }); } - public override *args(message: BushMessage): Generator { + public override *args(message: BushMessage): ArgumentGeneratorReturn { const optional = message.util.parsed!.alias === 'settings'; const setting: GuildSettings = yield { id: 'setting', diff --git a/src/commands/dev/superUser.ts b/src/commands/dev/superUser.ts index 7b75672..b184f6f 100644 --- a/src/commands/dev/superUser.ts +++ b/src/commands/dev/superUser.ts @@ -31,7 +31,7 @@ export default class SuperUserCommand extends BushCommand { }); } - override *args(): ArgumentGeneratorReturn { + public override *args(): ArgumentGeneratorReturn { const action: 'add' | 'remove' = yield { id: 'action', type: ['add', 'remove'], diff --git a/src/commands/info/avatar.ts b/src/commands/info/avatar.ts index 0ea9179..6b4afa1 100644 --- a/src/commands/info/avatar.ts +++ b/src/commands/info/avatar.ts @@ -2,7 +2,7 @@ import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } fr import { ApplicationCommandOptionType, Embed, GuildMember, PermissionFlagsBits } from 'discord.js'; export default class AvatarCommand extends BushCommand { - constructor() { + public constructor() { super('avatar', { aliases: ['avatar', 'av'], category: 'info', @@ -27,7 +27,7 @@ export default class AvatarCommand extends BushCommand { }); } - override async exec(message: BushMessage | BushSlashMessage, args: { user: ArgType<'member'> | ArgType<'globalUser'> }) { + public override async exec(message: BushMessage | BushSlashMessage, args: { user: ArgType<'member'> | ArgType<'globalUser'> }) { const params: { size: 2048; extension: 'png'; dynamic: true } = { size: 2048, extension: 'png', dynamic: true }; const defaultAvatar = `https://cdn.discordapp.com/embed/avatars/${Math.ceil(Math.random() * 6) - 1}.png`; diff --git a/src/commands/info/icon.ts b/src/commands/info/icon.ts index b40b814..2b5b8fb 100644 --- a/src/commands/info/icon.ts +++ b/src/commands/info/icon.ts @@ -2,7 +2,7 @@ import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib'; import { Embed, PermissionFlagsBits } from 'discord.js'; export default class IconCommand extends BushCommand { - constructor() { + public constructor() { super('icon', { aliases: ['icon', 'guildavatar', 'severicon', 'guildicon'], category: 'info', @@ -16,7 +16,7 @@ export default class IconCommand extends BushCommand { }); } - override async exec(message: BushMessage | BushSlashMessage) { + public override async exec(message: BushMessage | BushSlashMessage) { const embed = new Embed() .setTimestamp() .setColor(util.colors.default) diff --git a/src/commands/info/pronouns.ts b/src/commands/info/pronouns.ts index 652881b..3eccd85 100644 --- a/src/commands/info/pronouns.ts +++ b/src/commands/info/pronouns.ts @@ -26,7 +26,7 @@ export default class PronounsCommand extends BushCommand { }); } - override async exec(message: BushMessage | BushSlashMessage, args: { user?: ArgType<'globalUser'> }) { + public override async exec(message: BushMessage | BushSlashMessage, args: { user?: ArgType<'globalUser'> }) { const user = args.user ?? message.author; const author = user.id === message.author.id; diff --git a/src/commands/moderation/evidence.ts b/src/commands/moderation/evidence.ts index d951f3d..444a173 100644 --- a/src/commands/moderation/evidence.ts +++ b/src/commands/moderation/evidence.ts @@ -36,7 +36,7 @@ export default class EvidenceCommand extends BushCommand { }); } - override *args(message: BushMessage): ArgumentGeneratorReturn { + public override *args(message: BushMessage): ArgumentGeneratorReturn { const case_id: ArgumentTypeCasterReturn<'string'> = yield { id: 'case_id', type: 'string', diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts index b76795b..920ef81 100644 --- a/src/commands/moderation/role.ts +++ b/src/commands/moderation/role.ts @@ -8,7 +8,7 @@ import { type BushSlashMessage, type OptionalArgType } from '#lib'; -import { type ArgumentOptions, type Flag } from 'discord-akairo'; +import { type ArgumentGeneratorReturn } from 'discord-akairo'; import { ApplicationCommandOptionType, PermissionFlagsBits, type Snowflake } from 'discord.js'; export default class RoleCommand extends BushCommand { @@ -66,7 +66,7 @@ export default class RoleCommand extends BushCommand { }); } - public override *args(message: BushMessage): Generator { + public override *args(message: BushMessage): ArgumentGeneratorReturn { const action = (['rr'] as const).includes(message.util.parsed?.alias ?? '') ? 'remove' : (['ar', 'ra'] as const).includes(message.util.parsed?.alias ?? '') @@ -211,7 +211,7 @@ export default class RoleCommand extends BushCommand { await message.util.reply({ content: responseMessage(), allowedMentions: AllowedMentions.none() }); } - punishmentRoleNames = [ + private punishmentRoleNames = [ 'No Files', 'No Links', 'No Threads', diff --git a/src/commands/utilities/activity.ts b/src/commands/utilities/activity.ts index 52cad26..882c15d 100644 --- a/src/commands/utilities/activity.ts +++ b/src/commands/utilities/activity.ts @@ -1,5 +1,5 @@ import { BushCommand, type ArgType, type BushArgumentTypeCaster, type BushMessage, type BushSlashMessage } from '#lib'; -import { type ArgumentOptions, type ArgumentTypeCaster, type Flag } from 'discord-akairo'; +import { type ArgumentGeneratorReturn, type ArgumentTypeCaster } from 'discord-akairo'; import { ApplicationCommandOptionType, ChannelType, type DiscordAPIError, type Snowflake } from 'discord.js'; const activityMap = { @@ -74,7 +74,7 @@ const activityTypeCaster: BushArgumentTypeCaster = (message: B }; export default class ActivityCommand extends BushCommand { - constructor() { + public constructor() { super('activity', { aliases: ['activity', ...Object.values(activityMap).flatMap((a) => a.aliases)], category: 'utilities', @@ -120,7 +120,7 @@ export default class ActivityCommand extends BushCommand { }); } - public override *args(message: BushMessage): Generator { + public override *args(message: BushMessage): ArgumentGeneratorReturn { const channel: ArgType<'voiceChannel'> = yield { id: 'channel', description: 'The channel to create the activity in.', diff --git a/src/commands/utilities/steal.ts b/src/commands/utilities/steal.ts index 820fa89..d603222 100644 --- a/src/commands/utilities/steal.ts +++ b/src/commands/utilities/steal.ts @@ -1,6 +1,6 @@ import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; import assert from 'assert'; -import { type ArgumentOptions, type ArgumentType, type ArgumentTypeCaster, type Flag } from 'discord-akairo'; +import { type ArgumentGeneratorReturn, type ArgumentType, type ArgumentTypeCaster } from 'discord-akairo'; import { ApplicationCommandOptionType, PermissionFlagsBits } from 'discord.js'; import _ from 'lodash'; import { URL } from 'url'; @@ -44,7 +44,7 @@ export default class StealCommand extends BushCommand { }); } - public override *args(message: BushMessage): Generator { + public override *args(message: BushMessage): ArgumentGeneratorReturn { const hasImage = message.attachments.size && message.attachments.first()?.contentType?.includes('image/'); const emoji = hasImage diff --git a/src/lib/extensions/discord-akairo/BushClient.ts b/src/lib/extensions/discord-akairo/BushClient.ts index 0fc8896..eb1fe88 100644 --- a/src/lib/extensions/discord-akairo/BushClient.ts +++ b/src/lib/extensions/discord-akairo/BushClient.ts @@ -326,7 +326,7 @@ export class BushClient extends AkairoClient>, not <<${process.version}>>.`, false)); process.exit(2); @@ -394,7 +394,7 @@ export class BushClient extends AkairoClient implements ActivePunishmentModel @@ -77,7 +80,7 @@ export class ActivePunishment public static initModel(sequelize: Sequelize): void { ActivePunishment.init( { - id: { type: DataTypes.STRING, primaryKey: true, allowNull: false, defaultValue: nanoid }, + id: { type: DataTypes.STRING, primaryKey: true, defaultValue: nanoid }, type: { type: DataTypes.STRING, allowNull: false }, user: { type: DataTypes.STRING, allowNull: false }, guild: { type: DataTypes.STRING, allowNull: false, references: { model: 'Guilds', key: 'id' } }, diff --git a/src/lib/models/instance/Guild.ts b/src/lib/models/instance/Guild.ts index 11469d2..b41eb9e 100644 --- a/src/lib/models/instance/Guild.ts +++ b/src/lib/models/instance/Guild.ts @@ -47,6 +47,9 @@ export interface GuildModelCreationAttributes { levelUpChannel?: Snowflake; } +/** + * Settings for a guild. + */ export class Guild extends BaseModel implements GuildModel { /** * The ID of the guild diff --git a/src/lib/models/instance/Level.ts b/src/lib/models/instance/Level.ts index e18753d..77bc3d4 100644 --- a/src/lib/models/instance/Level.ts +++ b/src/lib/models/instance/Level.ts @@ -15,6 +15,9 @@ export interface LevelModelCreationAttributes { xp?: number; } +/** + * Leveling information for a user in a guild. + */ export class Level extends BaseModel implements LevelModel { /** * The user's id. diff --git a/src/lib/models/instance/ModLog.ts b/src/lib/models/instance/ModLog.ts index bcccbb4..c25f043 100644 --- a/src/lib/models/instance/ModLog.ts +++ b/src/lib/models/instance/ModLog.ts @@ -49,6 +49,9 @@ export interface ModLogModelCreationAttributes { hidden?: boolean; } +/** + * A mod log case. + */ export class ModLog extends BaseModel implements ModLogModel { /** * The primary key of the modlog entry. diff --git a/src/lib/models/instance/Reminder.ts b/src/lib/models/instance/Reminder.ts index 9ca78f1..964ea63 100644 --- a/src/lib/models/instance/Reminder.ts +++ b/src/lib/models/instance/Reminder.ts @@ -24,6 +24,9 @@ export interface ReminderModelCreationAttributes { notified?: boolean; } +/** + * Represents a reminder the a user has set. + */ export class Reminder extends BaseModel implements ReminderModel { /** * The id of the reminder. diff --git a/src/lib/models/instance/StickyRole.ts b/src/lib/models/instance/StickyRole.ts index fb1c30d..00e98ce 100644 --- a/src/lib/models/instance/StickyRole.ts +++ b/src/lib/models/instance/StickyRole.ts @@ -16,6 +16,9 @@ export interface StickyRoleModelCreationAttributes { nickname?: string; } +/** + * Information about a user's roles and nickname when they leave a guild. + */ export class StickyRole extends BaseModel implements StickyRoleModel { /** * The id of the user the roles belongs to. diff --git a/src/lib/models/shared/Global.ts b/src/lib/models/shared/Global.ts index 6dfc36f..b1aa0cc 100644 --- a/src/lib/models/shared/Global.ts +++ b/src/lib/models/shared/Global.ts @@ -19,6 +19,9 @@ export interface GlobalModelCreationAttributes { blacklistedChannels?: Snowflake[]; } +/** + * Data specific to a certain instance of the bot. + */ export class Global extends BaseModel implements GlobalModel { /** * The bot's environment. diff --git a/src/lib/models/shared/Shared.ts b/src/lib/models/shared/Shared.ts index 642ff85..4d13011 100644 --- a/src/lib/models/shared/Shared.ts +++ b/src/lib/models/shared/Shared.ts @@ -24,6 +24,9 @@ export interface SharedModelCreationAttributes { autoBanCode?: string; } +/** + * Data shared between all bot instances. + */ export class Shared extends BaseModel implements SharedModel { /** * The primary key of the shared model. diff --git a/src/lib/models/shared/Stat.ts b/src/lib/models/shared/Stat.ts index 8f77b58..d138620 100644 --- a/src/lib/models/shared/Stat.ts +++ b/src/lib/models/shared/Stat.ts @@ -14,6 +14,9 @@ export interface StatModelCreationAttributes { commandsUsed?: bigint; } +/** + * Statistics for each instance of the bot. + */ export class Stat extends BaseModel implements StatModel { /** * The bot's environment. diff --git a/src/lib/utils/CanvasProgressBar.ts b/src/lib/utils/CanvasProgressBar.ts index cd86532..1ba0e8b 100644 --- a/src/lib/utils/CanvasProgressBar.ts +++ b/src/lib/utils/CanvasProgressBar.ts @@ -22,7 +22,7 @@ export class CanvasProgressBar { this.ctx = ctx; } - draw(): void { + public draw(): void { // ----------------- this.p = this.percentage * this.w; if (this.p <= this.h) { @@ -57,7 +57,7 @@ export class CanvasProgressBar { this.ctx.fill(); } - // showWholeProgressBar(){ + // public showWholeProgressBar(){ // this.ctx.beginPath(); // this.ctx.arc(this.h / 2 + this.x, this.h / 2 + this.y, this.h / 2, Math.PI / 2, 3 / 2 * Math.PI); // this.ctx.lineTo(this.w - this.h + this.x, 0 + this.y); @@ -68,11 +68,11 @@ export class CanvasProgressBar { // this.ctx.closePath(); // } - get PPercentage(): number { + public get PPercentage(): number { return this.percentage * 100; } - set PPercentage(x: number) { + public set PPercentage(x: number) { this.percentage = x / 100; } } diff --git a/src/listeners/commands/commandError.ts b/src/listeners/commands/commandError.ts index 6f1c097..ba27706 100644 --- a/src/listeners/commands/commandError.ts +++ b/src/listeners/commands/commandError.ts @@ -222,7 +222,7 @@ export default class CommandErrorListener extends BushListener { return ret; } - static async getErrorStack(error: Error | any): Promise { + public static async getErrorStack(error: Error | any): Promise { return await util.inspectCleanRedactCodeblock(error?.stack ?? error, 'js'); } } -- cgit