Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Eslint #210

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 16
node-version: 22
- name: Install Node.js dependencies
run: npm ci
- name: Run linters
Expand Down
6,548 changes: 3,053 additions & 3,495 deletions package-lock.json

Large diffs are not rendered by default.

60 changes: 29 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,40 @@
"url": "https://github.com/Brexbot/DiscordBot/issues"
},
"homepage": "https://github.com/Brexbot/DiscordBot#readme",
"type": "commonjs",
"type": "module",
"devDependencies": {
"@types/cron": "^2.0.1",
"@types/node": "^18.15.10",
"@types/node-fetch": "^2.6.2",
"@typescript-eslint/eslint-plugin": "^5.57.0",
"@typescript-eslint/parser": "^5.57.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"nodemon": "^2.0.22",
"prettier": "^2.8.7",
"rimraf": "^4.4.1",
"ts-node": "^10.9.1",
"tslib": "^2.5.0",
"typescript": "^5.0.2"
"@types/node": "^20.14.10",
"@types/node-fetch": "^2.6.11",
"@types/sharp": "^0.31.1",
"@typescript-eslint/eslint-plugin": "^7.16.0",
"@typescript-eslint/parser": "^7.16.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"nodemon": "^3.1.4",
"prettier": "3.3.3",
"rimraf": "^6.0.1",
"ts-node": "^10.9.2",
"tslib": "^2.6.3",
"typescript": "^5.5.3"
},
"dependencies": {
"@dice-roller/rpg-dice-roller": "^5.2.1",
"@discordx/importer": "^1.2.1",
"@discordx/pagination": "^3.4.1",
"@discordx/utilities": "^5.2.1",
"@prisma/client": "^4.12.0",
"@twurple/api": "^6.0.9",
"@twurple/auth": "^6.0.9",
"@types/sharp": "^0.31.1",
"cron": "^2.3.0",
"discord-api-types": "^0.37.37",
"discord.js": "^14.8.0",
"discordx": "^11.7.4",
"fs": "^0.0.1-security",
"@dice-roller/rpg-dice-roller": "^5.5.0",
"@discordx/importer": "^1.3.1",
"@discordx/pagination": "^3.5.4",
"@discordx/utilities": "^7.0.1",
"@prisma/client": "^5.16.2",
"@twurple/api": "^7.1.0",
"@twurple/auth": "^7.1.0",
"cron": "^3.1.7",
"discord-api-types": "^0.37.92",
"discord.js": "^14.15.3",
"discordx": "^11.12.0",
"hsl-rgb": "^1.0.0",
"localisetimemodule": "github:QOAL/localiseTimeModule#20230503",
"path": "^0.12.7",
"prisma": "^4.12.0",
"reflect-metadata": "^0.1.13",
"sharp": "^0.32.0",
"sponge-case": "^1.0.1"
"prisma": "^5.16.2",
"reflect-metadata": "^0.2.2",
"sharp": "^0.33.4",
"sponge-case": "^2.0.3"
}
}
12 changes: 6 additions & 6 deletions src/commands/NFD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
userMention,
} from 'discord.js'
import { Discord, Guard, Slash, SlashChoice, SlashGroup, SlashOption } from 'discordx'
import { getCallerFromCommand, getNicknameFromUser } from '../utils/CommandUtils'
import { getCallerFromCommand, getNicknameFromUser } from '../utils/CommandUtils.js'
import { injectable } from 'tsyringe'
import { ORM } from '../persistence'
import { NFDItem } from '../../prisma/generated/prisma-client-js'
import { IsSuperUser } from '../guards/RoleChecks'
import { ORM } from '../persistence/ORM.js'
import { NFDItem } from '../../prisma/generated/prisma-client-js/index.js'
import { IsSuperUser } from '../guards/RoleChecks.js'
import sharp from 'sharp'

type BodyParts = {
Expand Down Expand Up @@ -1223,8 +1223,8 @@
) {
const nfdName = nfd.name

const author = owner ? owner.nickname ?? owner.user.username : 'UNKNOWN'
const avatar = owner ? owner.user.avatarURL() ?? undefined : undefined
const author = owner ? (owner.nickname ?? owner.user.username) : 'UNKNOWN'

Check failure on line 1226 in src/commands/NFD.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/commands/NFD.ts#L1226

Replace `(owner.nickname·??·owner.user.username)` with `owner.nickname·??·owner.user.username` (prettier/prettier)
const avatar = owner ? (owner.user.avatarURL() ?? undefined) : undefined

Check failure on line 1227 in src/commands/NFD.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/commands/NFD.ts#L1227

Replace `(owner.user.avatarURL()·??·undefined)` with `owner.user.avatarURL()·??·undefined` (prettier/prettier)

// Check for the existence of the image in the cache, if it doesn't exist, make it.

Expand Down
10 changes: 7 additions & 3 deletions src/commands/RPG/Character.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { adjectives, nouns, CharacterClass, classes, CharacterSpecie, species } from './Data'
import { getSeededRandomElement, rollSeeded_dy_x_TimesPick_z, mulberry32, cyrb53 } from './util'
import { adjectives, nouns, CharacterClass, classes, CharacterSpecie, species } from './Data.js'
import { getSeededRandomElement, rollSeeded_dy_x_TimesPick_z, mulberry32, cyrb53 } from './util.js'
import { EmbedBuilder, User } from 'discord.js'

export class Character {
Expand All @@ -23,7 +23,11 @@

rng: () => number

public constructor(public user: User, public nickname: string, private seedPhrase?: string) {
public constructor(

Check failure on line 26 in src/commands/RPG/Character.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/commands/RPG/Character.ts#L26

Replace `⏎····public·user:·User,⏎····public·nickname:·string,⏎····private·seedPhrase?:·string⏎··` with `public·user:·User,·public·nickname:·string,·private·seedPhrase?:·string` (prettier/prettier)
public user: User,
public nickname: string,
private seedPhrase?: string
) {
// Maybe the screen name is better until folks can build their own character
if (this.seedPhrase) {
this.seed = cyrb53(this.seedPhrase)
Expand Down
8 changes: 4 additions & 4 deletions src/commands/RPG/RPG.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Character } from './Character'
import { getEloRankChange, getRandomElement as getRandomElement, roll_dy_x_TimesPick_z } from './util'
import { attackTexts, defenceFailureTexts, defenceSuccessTexts, ladderTexts, victoryTexts } from './Dialogue'
import { ELO_K } from './Data'
import { Character } from './Character.js'
import { getEloRankChange, getRandomElement as getRandomElement, roll_dy_x_TimesPick_z } from './util.js'
import { attackTexts, defenceFailureTexts, defenceSuccessTexts, ladderTexts, victoryTexts } from './Dialogue.js'
import { ELO_K } from './Data.js'

import {
ActionRowBuilder,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/RPG/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { classes } from './Data'
import { classes } from './Data.js'

export function cyrb53(str: string, seed = 0): number {
// Hash the input string to int
Expand Down
2 changes: 1 addition & 1 deletion src/commands/chatters/artemis.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Discord, SimpleCommand, SimpleCommandMessage, SimpleCommandOption, SimpleCommandOptionType } from 'discordx'
import { shuffleArray } from '../../utils/Helpers'
import { shuffleArray } from '../../utils/Helpers.js'

@Discord()
class Artemis {
Expand Down
16 changes: 8 additions & 8 deletions src/commands/duel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import {
ButtonStyle,
CommandInteraction,
EmbedBuilder,
Formatters,
GuildMember,
Message,
MessageActionRowComponentBuilder,
inlineCode,
} from 'discord.js'
import { Discord, Slash, SlashGroup } from 'discordx'
import { injectable } from 'tsyringe'
import { ORM } from '../persistence/ORM'
import { ORM } from '../persistence/ORM.js'

import { Duels } from '../../prisma/generated/prisma-client-js'
import { ColorRoles } from './roleCommands/changecolor'
import { getCallerFromCommand, getGuildAndCallerFromCommand } from '../utils/CommandUtils'
import { getGlobalDuelCDRemaining, getTimeLeftInReadableFormat } from '../utils/CooldownUtils'
import { shuffleArray } from '../utils/Helpers'
import { Duels } from '../../prisma/generated/prisma-client-js/index.js'
import { ColorRoles } from './roleCommands/changecolor.js'
import { getCallerFromCommand, getGuildAndCallerFromCommand } from '../utils/CommandUtils.js'
import { getGlobalDuelCDRemaining, getTimeLeftInReadableFormat } from '../utils/CooldownUtils.js'
import { shuffleArray } from '../utils/Helpers.js'

@Discord()
@SlashGroup({ name: 'duel', description: 'Duel minigame' })
Expand Down Expand Up @@ -143,7 +143,7 @@ export class Duel {

// Check if there is no current duel
await collectionInteraction.followUp({
content: `Someone beat you to the challenge! (or the duel expired... who knows!). You may issue a new challenge with ${Formatters.inlineCode(
content: `Someone beat you to the challenge! (or the duel expired... who knows!). You may issue a new challenge with ${inlineCode(
'/duel'
)}.`,
ephemeral: true,
Expand Down
6 changes: 3 additions & 3 deletions src/commands/minesweeper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApplicationCommandOptionType, CommandInteraction, Formatters } from 'discord.js'
import { ApplicationCommandOptionType, CommandInteraction, spoiler } from 'discord.js'
import {
Discord,
SimpleCommand,
Expand Down Expand Up @@ -116,13 +116,13 @@ class Board {

const tile = this.neighbors[i]
if (tile === -1) {
board += Formatters.spoiler(`:${this.randomBomb()}:`)
board += spoiler(`:${this.randomBomb()}:`)
} else {
if (tile === 0 && !startRevealed) {
board += `:${Board.neighborCounts[tile]}:`
startRevealed = true
} else {
board += Formatters.spoiler(`:${Board.neighborCounts[tile]}:`)
board += spoiler(`:${Board.neighborCounts[tile]}:`)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/commands/mixu.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { CommandInteraction, Guild } from 'discord.js'
import { Discord, SimpleCommand, SimpleCommandMessage, Slash } from 'discordx'
import { injectable } from 'tsyringe'
import { ORM } from '../persistence'
import { BestMixu } from '../../prisma/generated/prisma-client-js'
import { shuffleArray } from '../utils/Helpers'
import { ORM } from '../persistence/ORM.js'
import { BestMixu } from '../../prisma/generated/prisma-client-js/index.js'
import { shuffleArray } from '../utils/Helpers.js'

@Discord()
@injectable()
Expand Down
4 changes: 2 additions & 2 deletions src/commands/modCommands/Pardon.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Client, Discord, Guard, SimpleCommand, SimpleCommandMessage } from 'discordx'
import { GuildMember } from 'discord.js'
import { injectable } from 'tsyringe'
import { ORM } from '../../persistence'
import { IsSuperUser } from '../../guards/RoleChecks'
import { ORM } from '../../persistence/index.js'
import { IsSuperUser } from '../../guards/RoleChecks.js'

@Discord()
@injectable()
Expand Down
2 changes: 1 addition & 1 deletion src/commands/modCommands/releasetheeggplant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
SimpleCommandOption,
SimpleCommandOptionType,
} from 'discordx'
import { IsSuperUser, memberIsSU } from '../../guards/RoleChecks'
import { IsSuperUser, memberIsSU } from '../../guards/RoleChecks.js'

@Discord()
@Guard(IsSuperUser)
Expand Down
4 changes: 2 additions & 2 deletions src/commands/modCommands/setgamble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {
SimpleCommandOption,
SimpleCommandOptionType,
} from 'discordx'
import { Prisma } from '../../../prisma/generated/prisma-client-js'
import { Prisma } from '../../../prisma/generated/prisma-client-js/index.js'
import { injectable } from 'tsyringe'
import { ORM } from '../../persistence'
import { IsSuperUser } from '../../guards/RoleChecks'
import { IsSuperUser } from '../../guards/RoleChecks.js'

@Discord()
@injectable()
Expand Down
2 changes: 1 addition & 1 deletion src/commands/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Slash,
SlashOption,
} from 'discordx'
import { uwuify } from './uwu'
import { uwuify } from './uwu.js'

interface Quote {
id: number
Expand Down
14 changes: 7 additions & 7 deletions src/commands/roleCommands/changecolor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ import {
import {
ApplicationCommandOptionType,
CommandInteraction,
Formatters,
italic,
Guild,
GuildMember,
HexColorString,
} from 'discord.js'
import { injectable } from 'tsyringe'
import { ORM } from '../../persistence'
import { Prisma } from '../../../prisma/generated/prisma-client-js'
import { ORM } from '../../persistence/index.js'
import { Prisma } from '../../../prisma/generated/prisma-client-js/index.js'
import { IsSuperUser, superUserIds, superUserRoles } from '../../guards/RoleChecks'
import { getCallerFromCommand, getGuildAndCallerFromCommand, getGuildFromCommand } from '../../utils/CommandUtils'
import { Duel } from '../duel'
import { getTimeLeftInReadableFormat } from '../../utils/CooldownUtils'
import { getCallerFromCommand, getGuildAndCallerFromCommand, getGuildFromCommand } from '../../utils/CommandUtils.js'
import { Duel } from '../duel.js'
import { getTimeLeftInReadableFormat } from '../../utils/CooldownUtils.js'

@Discord()
@injectable()
Expand Down Expand Up @@ -293,7 +293,7 @@ export class ColorRoles {
const hexColor: HexColorString = color[0] !== '#' ? `#${color}` : (color as HexColorString)
let favoriteString = ' '
if (isFavorite || hexColor === userOptions.favColor?.toUpperCase()) {
favoriteString += Formatters.italic('favorite') + ' '
favoriteString += italic('favorite') + ' '
}

await ColorRoles.setColor(hexColor, member, guild)
Expand Down
4 changes: 2 additions & 2 deletions src/commands/roleCommands/embedpls.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Discord, SimpleCommand, SimpleCommandMessage, Slash, SlashOption } from 'discordx'
import { ApplicationCommandOptionType, CommandInteraction, GuildMember, GuildMemberRoleManager, User } from 'discord.js'
import { memberIsSU } from '../../guards/RoleChecks'
import { ApplicationCommandOptionType, CommandInteraction, GuildMember, GuildMemberRoleManager } from 'discord.js'
import { memberIsSU } from '../../guards/RoleChecks.js'

// Intentionally leaving out the slash command for this as it doesn't really make sense to
// clutter the slash menu with a command that most users will only ever use once
Expand Down
2 changes: 1 addition & 1 deletion src/commands/roleCommands/icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
SlashOption,
} from 'discordx'
import { ApplicationCommandOptionType, CommandInteraction, GuildMemberRoleManager, RoleManager } from 'discord.js'
import { IsSuperUser } from '../../guards/RoleChecks'
import { IsSuperUser } from '../../guards/RoleChecks.js'

@Discord()
class Icon {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/roleCommands/rolesub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
SlashOption,
} from 'discordx'
import { ApplicationCommandOptionType, CommandInteraction, GuildMemberRoleManager, RoleManager } from 'discord.js'
import { IsSuperUser } from '../../guards/RoleChecks'
import { IsSuperUser } from '../../guards/RoleChecks.js'

@Discord()
class Rolesub {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/roll.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DiceRoll } from '@dice-roller/rpg-dice-roller'
import { ApplicationCommandOptionType, CommandInteraction } from 'discord.js'
import { Discord, Slash, SlashGroup, SlashOption } from 'discordx'
import { getRandomElement } from './RPG/util'
import { getRandomElement } from './RPG/util.js'

@SlashGroup({ name: 'roll', description: 'Ask the dice for advice' })
@SlashGroup('roll')
Expand Down
2 changes: 1 addition & 1 deletion src/commands/rps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
MessageActionRowComponentBuilder,
} from 'discord.js'
import { Discord, Slash } from 'discordx'
import { getCallerFromCommand } from '../utils/CommandUtils'
import { getCallerFromCommand } from '../utils/CommandUtils.js'

type RPSChoice = 'rock' | 'paper' | 'scissors'

Expand Down
6 changes: 3 additions & 3 deletions src/commands/timeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ButtonBuilder,
ButtonStyle,
CommandInteraction,
Formatters,
quote,
Guild,
GuildMember,
GuildMemberRoleManager,
Expand All @@ -22,7 +22,7 @@ import {
Slash,
SlashOption,
} from 'discordx'
import { IsSuperUser, memberIsSU } from '../guards/RoleChecks'
import { IsSuperUser, memberIsSU } from '../guards/RoleChecks.js'

@Discord()
abstract class Timeout {
Expand Down Expand Up @@ -67,7 +67,7 @@ abstract class Timeout {
async sudoku(member: GuildMember | null, message?: string): Promise<string> {
const time = this.sudokuDuration()
await member?.timeout(time * 1000, "Sudoku'd").catch(console.error)
const msg = message && message.length < 150 ? `\n${Formatters.quote(message)}` : ''
const msg = message && message.length < 150 ? `\n${quote(message)}` : ''

// If the Sudoku-ee is a Super User send them a DM with a button to remove the timeout
if (memberIsSU(member)) {
Expand Down
Loading
Loading