Skip to content

Commit 65f904e

Browse files
committed
refactor: Remove unneeded guild reference
Also fix a non i18n'ed string
1 parent aecf09c commit 65f904e

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

src/events/messageCreate.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Guild, GuildTextBasedChannel, Message } from "discord.js";
1+
import { GuildTextBasedChannel, Message } from "discord.js";
22

33
import runningGameMessage from "../components/runningGameMessage.js";
44
import { event } from "../typings/event.js";
@@ -14,7 +14,7 @@ export const e: event = async (client, message: Message) => {
1414
if (scrolledWeight > maxWeightBeforeResend) {
1515
const msg = message.channel.messages.cache.get(game.messageId);
1616
if (msg) await msg?.delete();
17-
const sent = await (msg?.channel as GuildTextBasedChannel).send(await runningGameMessage(client, game, message.guild as Guild));
17+
const sent = await (msg?.channel as GuildTextBasedChannel).send(await runningGameMessage(client, game));
1818
game.messageId = sent.id;
1919
}
2020
};

src/interactions/buttons/confirmLeaveGame.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
import { Guild, MessageFlags, TextChannel } from "discord.js";
2+
import { MessageFlags, TextChannel } from "discord.js";
33
import { t } from "i18next";
44

55
import runningGameMessage from "../../components/runningGameMessage.js";
@@ -40,7 +40,7 @@ export const b: button = {
4040
await interaction.channel?.messages.cache.get(game.messageId)?.delete();
4141
await (interaction.channel as TextChannel).send(t("strings:game.left", { name: await getUsername(client, game.guildId, interaction.user.id), lng }));
4242
if ((game._modified && game.players.length === 0) || (!game._modified && game.players.length === 1)) return endGame(game, interaction.client, "notEnoughPeople");
43-
const msg = await (interaction.channel as TextChannel).send(await runningGameMessage(client, game, interaction.guild as Guild));
43+
const msg = await (interaction.channel as TextChannel).send(await runningGameMessage(client, game));
4444
game.messageId = msg.id;
4545
}
4646
};

src/utils/game/endTurn.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ButtonInteraction, Client, StringSelectMenuInteraction, TextChannel } from "discord.js";
2+
import { t } from "i18next";
23

34
import runningGameMessage from "../../components/runningGameMessage.js";
45
import { runningUnoGame } from "../../typings/unoGame.js";
@@ -8,7 +9,6 @@ import { getUsername } from "../getUsername.js";
89
import timeouts from "../timeoutManager.js";
910
import endGame from "./endGame.js";
1011
import onTimeout from "./onTimeout.js";
11-
import toTitleCase from "./toTitleCase.js";
1212

1313
export default async (client: Client, game: runningUnoGame, interaction: StringSelectMenuInteraction | ButtonInteraction, previousPlayer: string, type: "played" | "skipped" | "misc", toAppend?: string, showPlayedCard: boolean = true) => {
1414
if (!interaction.inGuild()) return;
@@ -18,12 +18,12 @@ export default async (client: Client, game: runningUnoGame, interaction: StringS
1818
if (showPlayedCard || type !== "misc") game.log.push({ player: previousPlayer, card: game.currentCard, adminAbused: game.adminAbused });
1919
const isUnique = uniqueVariants.includes(game.currentCard.split("-")[1] as typeof uniqueVariants[number]);
2020
const currentCardEmote = isUnique ? config.emoteless ? colorEmotes.other : coloredUniqueCards[game.currentCard as keyof typeof coloredUniqueCards] : cardEmotes[game.currentCard];
21-
await (interaction.channel as TextChannel).send(`${showPlayedCard ? `**${await getUsername(client, game.guildId, previousPlayer)}** played ${currentCardEmote} ${toTitleCase(game.currentCard, lng)}\n` : ""}${toAppend ?? ""}`.trim());
21+
await (interaction.channel as TextChannel).send(`${showPlayedCard ? `${t("strings:game.played", { lng, name: await getUsername(client, game.guildId, game.currentPlayer), currentCardEmote, card: game.currentCard })}\n` : ""}${toAppend ?? ""}`.trim());
2222
await interaction.channel?.messages.cache.get(game.messageId)?.delete();
2323
await interaction.deleteReply();
2424
if ((game._modified && game.players.length === 0) || (!game._modified && game.players.length === 1)) return endGame(game, interaction.client, "notEnoughPeople");
2525
if (game.cards[previousPlayer] && game.cards[previousPlayer].length === 0) return endGame(game, interaction.client, "win", previousPlayer);
26-
const msg = await (interaction.channel as TextChannel).send(await runningGameMessage(client, game, interaction.guild!));
26+
const msg = await (interaction.channel as TextChannel).send(await runningGameMessage(client, game));
2727
game.messageId = msg.id;
2828
if (type !== "misc") {
2929
game.canSkip = false;

src/utils/game/onTimeout.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default async (client: Client, game: runningUnoGame, player: string) => {
6262
else if (game.players.length === 1) return endGame(game, client, "win", game.currentPlayer);
6363
}
6464
await (client.channels.cache.get(game.channelId) as GuildTextBasedChannel).messages.cache.get(game.messageId)?.delete();
65-
const msg = await (client.channels.cache.get(game.channelId) as GuildTextBasedChannel).send(await runningGameMessage(client, game, client.guilds.cache.get(game.guildId)!));
65+
const msg = await (client.channels.cache.get(game.channelId) as GuildTextBasedChannel).send(await runningGameMessage(client, game));
6666
game.messageId = msg.id;
6767
game.turnProgress = "chooseCard";
6868
game.log.push({ player: previousPlayer, card: game.currentCard, adminAbused: game.adminAbused });

src/utils/game/startGame.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default async (client: Client, game: unoGame, automatic: boolean, message
5454
await message.delete();
5555
game.startingDate = new Date(Date.now());
5656
await (message.channel as GuildTextBasedChannel).send(`${t("strings:game.started", { lng })}${game.settings.adminabusemode === true ? t("strings:game.startedAA", { lng }) : ""}`);
57-
const msg = await (message.channel as GuildTextBasedChannel).send(await runningGameMessage(client, game, message.guild));
57+
const msg = await (message.channel as GuildTextBasedChannel).send(await runningGameMessage(client, game));
5858
game.messageId = msg.id;
5959
timeouts.set(game.channelId, () => onTimeout(client, game, game.currentPlayer), game.settings.timeoutDuration * 1000);
6060
};

0 commit comments

Comments
 (0)