Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
alephtwo committed Sep 14, 2024
1 parent b9bf1b9 commit f4d9a3f
Show file tree
Hide file tree
Showing 9 changed files with 1,038 additions and 997 deletions.
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,29 @@
"@discordjs/opus": "0.9.0",
"@discordjs/voice": "0.17.0",
"bufferutil": "4.0.8",
"discord.js": "14.15.3",
"discord.js": "14.16.2",
"glob": "11.0.0",
"sodium-native": "4.1.1",
"utf-8-validate": "6.0.4",
"zlib-sync": "0.1.9"
},
"devDependencies": {
"@stryker-mutator/core": "8.2.6",
"@stryker-mutator/mocha-runner": "8.2.6",
"@types/chai": "4.3.16",
"@types/mocha": "10.0.7",
"@types/node": "22.0.0",
"@types/ws": "8.5.11",
"@stryker-mutator/core": "8.5.0",
"@stryker-mutator/mocha-runner": "8.5.0",
"@types/chai": "4.3.19",
"@types/mocha": "10.0.8",
"@types/node": "22.5.4",
"@types/ws": "8.5.12",
"chai": "5.1.1",
"eslint": "9.8.0",
"globals": "15.8.0",
"markdownlint": "0.34.0",
"eslint": "9.10.0",
"globals": "15.9.0",
"markdownlint": "0.35.0",
"markdownlint-cli": "0.41.0",
"mocha": "10.7.0",
"mocha": "10.7.3",
"prettier": "3.3.3",
"strong-mock": "9.0.0",
"tsx": "4.16.2",
"typescript": "5.4.5",
"typescript-eslint": "8.0.0-alpha.55"
"tsx": "4.19.1",
"typescript": "5.6.2",
"typescript-eslint": "8.5.0"
}
}
1,961 changes: 998 additions & 963 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/command/commands/HelpCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ export default class HelpCommand implements Command {
.map((c) => `\`!${c}\``);

void this.#msg.author.send(unorderedList(help)).catch();
return Promise.resolve();
}
}
1 change: 0 additions & 1 deletion src/command/commands/InvalidCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ export class InvalidCommand implements Command {

run() {
console.error(`Invalid command: ${this.#command}`);
return Promise.resolve();
}
}
18 changes: 12 additions & 6 deletions src/command/commands/PlaySoundCommand.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Message, AttachmentBuilder } from "discord.js";
import { Message, AttachmentBuilder, ChannelType } from "discord.js";
import { playSound } from "../../sound/playSound";
import Command from "./Command";

Expand All @@ -14,15 +14,21 @@ export default abstract class PlaySoundCommand implements Command {
run() {
const sound = this.pickSound();

// If the user isn't in a voice channel let's send them the file.
const channel = this.#msg.member?.voice.channel;
// If the user is in a voice channel, play it!
if (channel !== null && channel !== undefined) {
void playSound(channel, sound);
return;
}

if (!channel) {
const attachment = new AttachmentBuilder(sound);
void this.#msg.channel.send({ files: [attachment] }).catch();
// fall back on the text channel
const messageChannel = this.#msg.channel;
if (messageChannel.type !== ChannelType.GuildText) {
console.error("Couldn't play sound, no channel");
return;
}

void playSound(channel, sound);
const attachment = new AttachmentBuilder(sound);
void messageChannel.send({ files: [attachment] }).catch();
}
}
14 changes: 8 additions & 6 deletions src/command/commands/StatsCommand.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Message, bold } from "discord.js";
import { ChannelType, Message, bold } from "discord.js";
import Command from "./Command";
import { globSync } from "glob";
import { SOUND_DIR } from "../../sound/soundUtils";
Expand All @@ -18,11 +18,13 @@ export default class StatsCommand implements Command {
count: this.countSounds(dir),
}));

this.#msg.channel
.send({
content: this.buildMessage(counts),
})
.catch(console.error);
const channel = this.#msg.channel;
if (channel.type !== ChannelType.GuildText) {
console.error("Couldn't send stats, no channel");
return;
}

channel.send({ content: this.buildMessage(counts) }).catch(console.error);
}

private countSounds(dir: string): number {
Expand Down
2 changes: 1 addition & 1 deletion src/command/parseBangCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function parseBangCommand(msg: Message): {
// Find if there is any string that might be a command
const commands = msg.content.split(" ").filter((c) => c.startsWith("!"));

// If there aren't any commands, just bail out
// If there aren't any commands, just bail outa
if (commands.length === 0) {
return {};
}
Expand Down
2 changes: 1 addition & 1 deletion src/events/onMessageCreate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Message } from "discord.js";
import { parseBangCommand } from "../command/parseBangCommand";
import { Message } from "discord.js";

export function onMessageCreate(msg: Message) {
// If it's not from a guild, don't bother doing anything.
Expand Down
8 changes: 4 additions & 4 deletions src/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Discord from "discord.js";
import { GatewayIntentBits } from "discord.js";
import { Events, GatewayIntentBits } from "discord.js";
import { onMessageCreate } from "./events/onMessageCreate";
import { onReady } from "./events/onReady";
import { playSound } from "./sound/playSound";
Expand All @@ -14,13 +14,13 @@ const client = new Discord.Client({
],
});

client.on("ready", onReady(client));
client.on("messageCreate", onMessageCreate);
client.on(Events.ClientReady, onReady(client));
client.on(Events.MessageCreate, onMessageCreate);

// This code is extremely cursed.
// It is cursed code.
// Remove it or keep it at your own peril.
client.on("voiceStateUpdate", (prev, next) => {
client.on(Events.VoiceStateUpdate, (prev, next) => {
// Ignore when the bot itself joins the channel to prevent duplicates.
if (next.member?.id === client.user?.id) {
return;
Expand Down

0 comments on commit f4d9a3f

Please sign in to comment.