Skip to content

Commit

Permalink
Merge pull request #209 from mmerfort/updates
Browse files Browse the repository at this point in the history
Update all dependencies, switch module type to ESNext
  • Loading branch information
mmerfort authored Aug 2, 2024
2 parents 4a918b8 + 8bbd492 commit fcc98cb
Show file tree
Hide file tree
Showing 26 changed files with 2,915 additions and 322 deletions.
3,027 changes: 2,809 additions & 218 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 10 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,38 @@
"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": "^20.14.12",
"@types/node": "^20.14.10",
"@types/node-fetch": "^2.6.11",
"@typescript-eslint/eslint-plugin": "^7.17.0",
"@typescript-eslint/parser": "^7.17.0",
"@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",
"eslint-plugin-prettier": "^5.1.3",
"nodemon": "^3.1.4",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"ts-node": "^10.9.2",
"tslib": "^2.6.3",
"typescript": "^5.5.4"
"typescript": "^5.5.3"
},
"dependencies": {
"@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.17.0",
"@prisma/client": "^5.16.2",
"@twurple/api": "^7.1.0",
"@twurple/auth": "^7.1.0",
"@types/sharp": "^0.31.1",
"cron": "^3.1.7",
"discord-api-types": "^0.37.93",
"discord-api-types": "^0.37.92",
"discord.js": "^14.15.3",
"discordx": "^11.12.0",
"fs": "^0.0.1-security",
"hsl-rgb": "^1.0.0",
"localisetimemodule": "github:QOAL/localiseTimeModule#20230503",
"path": "^0.12.7",
"prisma": "^5.17.0",
"prisma": "^5.16.2",
"reflect-metadata": "^0.2.2",
"sharp": "^0.33.4",
"sponge-case": "^2.0.3"
Expand Down
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 @@ import {
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 @@ class NFD {
) {
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'
const avatar = owner ? (owner.user.avatarURL() ?? undefined) : undefined

// 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 @@ export class Character {

rng: () => number

public constructor(public user: User, public nickname: string, private seedPhrase?: string) {
public constructor(
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

0 comments on commit fcc98cb

Please sign in to comment.