diff --git a/package.json b/package.json index bbcc2c8a4..02accf2bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bastion", - "version": "10.15.0", + "version": "10.15.1", "description": "Get an enhanced Discord experience!", "type": "module", "homepage": "https://bastion.traction.one", @@ -20,37 +20,37 @@ "devDependencies": { "@types/discord-rpc": "^4.0.8", "@types/express": "^4.17.21", - "@types/gamedig": "^4.0.5", + "@types/gamedig": "^5.0.2", "@types/http-errors": "^2.0.4", "@types/jsdom": "^21.1.6", - "@types/node": "^20.10.2", - "@typescript-eslint/eslint-plugin": "^7.5.0", - "@typescript-eslint/parser": "^7.5.0", - "eslint": "^8.55.0", - "typescript": "^5.3.2" + "@types/node": "^20.12.12", + "@typescript-eslint/eslint-plugin": "^7.9.0", + "@typescript-eslint/parser": "^7.9.0", + "eslint": "^8.57.0", + "typescript": "^5.4.5" }, "dependencies": { - "@bastion/tesseract": "^5.1.0", + "@bastion/tesseract": "^5.2.0", "@discordjs/opus": "^0.9.0", "@iamtraction/google-translate": "^2.0.1", + "@iamtraction/play-dl": "^1.9.8", "discord-rpc": "^4.0.1", "dotenv": "^16.3.1", "emoji-regex": "^10.3.0", - "gamedig": "^4.2.0", + "gamedig": "^5.0.0", "jsdom": "^24.0.0", "libsodium-wrappers": "^0.7.13", - "mathjs": "^12.1.0", - "openai": "^4.20.1", - "play-dl": "^1.9.7", + "mathjs": "^13.0.0", + "openai": "^4.47.1", "r6api.js": "^4.4.1", - "undici": "^6.11.1", + "undici": "^6.18.0", "ytdl-core": "^4.11.5", "ytpl": "^2.3.0" }, "optionalDependencies": { "bufferutil": "^4.0.8", "erlpack": "github:discord/erlpack", - "utf-8-validate": "^6.0.3", + "utf-8-validate": "^6.0.4", "zlib-sync": "^0.1.9" } } diff --git a/src/commands/gameserver.ts b/src/commands/gameserver.ts index 9cc17a3be..1e525e84a 100644 --- a/src/commands/gameserver.ts +++ b/src/commands/gameserver.ts @@ -4,18 +4,10 @@ */ import { ApplicationCommandOptionType, ChatInputCommandInteraction } from "discord.js"; import { Command } from "@bastion/tesseract"; -import gamedig from "gamedig"; +import { GameDig } from "gamedig"; import { COLORS } from "../utils/constants.js"; -interface Player extends gamedig.Player { - time?: number; - raw?: { - frags?: number; - ping?: number; - }; -} - class GameServerCommand extends Command { constructor() { super({ @@ -52,8 +44,8 @@ class GameServerCommand extends Command { const port = interaction.options.getInteger("port"); // fetch data from the game server - const server = await gamedig.query({ - type: game as gamedig.Type, + const server = await GameDig.query({ + type: game, host: hostname, port: port, }); @@ -87,12 +79,10 @@ class GameServerCommand extends Command { server.players ? server.players .filter(player => player.name) - .sort((a: Player, b: Player) => b.time - a.time) .sort((a, b) => b.score - a.score) - .sort((a: Player, b: Player) => b.raw?.frags - a.raw?.frags) - .map((player: Player) => ({ + .map(player => ({ name: (player.team ? "[" + player.team + "]" : "") + player.name, - value: "```\nSCORE " + (player.score || player.raw?.frags || 0) + ((player.ping || player.raw?.ping) ? "\tPING " + (player.ping || player.raw?.ping) + "ms" : "") + (player.time ? "\t" + (player.time / 60).toFixed(2) + " minutes" : "") + "```", + value: "```\nSCORE " + (player.score || 0) + (player.team ? "\tTEAM " + player.team : "") + (player.ping ? "\tPING " + player.ping + "ms" : "") + "```", inline: false, })) .slice(0, 5) diff --git a/src/commands/music/play.ts b/src/commands/music/play.ts index 251f6932c..1d3140a9b 100644 --- a/src/commands/music/play.ts +++ b/src/commands/music/play.ts @@ -6,7 +6,7 @@ import { ApplicationCommandOptionType, ChatInputCommandInteraction } from "disco import { AudioPlayerStatus, AudioResource, createAudioPlayer, createAudioResource, entersState, getVoiceConnection, joinVoiceChannel, NoSubscriberBehavior, VoiceConnection, VoiceConnectionStatus } from "@discordjs/voice"; import { Client, Command, Logger } from "@bastion/tesseract"; import { music } from "@bastion/tesseract/typings/types.js"; -import playDL from "play-dl"; +import playDL from "@iamtraction/play-dl"; import ytpl from "ytpl"; import GuildModel from "../../models/Guild.js"; diff --git a/src/listeners/messageCreate.ts b/src/listeners/messageCreate.ts index 3b126a95e..da4863bd8 100644 --- a/src/listeners/messageCreate.ts +++ b/src/listeners/messageCreate.ts @@ -297,7 +297,12 @@ class MessageCreateListener extends Listener<"messageCreate"> { if (message.author.bot) return; if (message.inGuild()) { - const guildDocument = await GuildModel.findById(message.guildId); + let guildDocument = await GuildModel.findById(message.guildId); + + // create guild document if it wasn't found + if (!guildDocument) { + guildDocument = await GuildModel.findByIdAndUpdate(message.guildId, {}, { upsert: true }); + } // gamification this.handleGamification(message, guildDocument).catch(Logger.error);