diff --git a/app/services/discord/modules/commands/developer/Ban.ts b/app/services/discord/modules/commands/developer/Ban.ts index 5b054cbd..c1e1b185 100644 --- a/app/services/discord/modules/commands/developer/Ban.ts +++ b/app/services/discord/modules/commands/developer/Ban.ts @@ -69,10 +69,13 @@ const Ban = async (nickname: string, ctx: Discord.ChatInputCommandInteraction, b const length = Math.round( Date.now() / 1000 + parseLength(ctx.options.getString("length", true)) ); + const gamemode = ctx.options.getString("gamemode"); const reason = ctx.options.getString("reason") ?? "no reason"; const code = `if not banni then return false end ` + - `local data = banni.Ban("${steamid}", "${plyName}", "Discord (${ctx.user.username}|${ctx.user.mention})", [[${reason}]], ${length}) ` + + `local data = banni.Ban("${steamid}", "${plyName}", "Discord (${ctx.user.username}|${ + ctx.user.mention + })", [[${reason}]], ${length}, false, ${gamemode ?? "nil"}) ` + `if istable(data) then return data.b else return data end`; try { const res = await server.sendLua(code, "sv", ctx.user.displayName); @@ -116,7 +119,11 @@ export const SlashBanCommand: SlashCommand = { type: Discord.ApplicationCommandOptionType.String, name: "reason", description: "The reason for the ban", - required: false, + }, + { + type: Discord.ApplicationCommandOptionType.String, + name: "gamemode", + description: "the gamemode to ban from (sandbox_modded by default)", }, { type: Discord.ApplicationCommandOptionType.Integer, @@ -164,9 +171,18 @@ export const SlashBanCommand: SlashCommand = { async autocomplete(ctx, bot) { const focused = ctx.options.getFocused(true); switch (focused.name) { + case "gamemode": { + const gamemodes = bot.bridge?.servers[ + ctx.options.getInteger("server") ?? 2 + ]?.gamemodes.map(name => { + return { name: name, value: name }; + }); + await ctx.respond(gamemodes ?? []); + break; + } case "steamid": { const players = - bot.bridge?.servers[ctx.options.getInteger("server") ?? 2].status.players; + bot.bridge?.servers[ctx.options.getInteger("server") ?? 2]?.status.players; if (!players) { await ctx.respond([]); return; diff --git a/app/services/gamebridge/GameServer.ts b/app/services/gamebridge/GameServer.ts index f526b1b8..a6e04467 100644 --- a/app/services/gamebridge/GameServer.ts +++ b/app/services/gamebridge/GameServer.ts @@ -51,6 +51,7 @@ export default class GameServer { folderName: string; name: string; }; + gamemodes: string[]; playerListImage: Buffer; serverUptime: number; status: { diff --git a/app/services/gamebridge/payloads/StatusPayload.ts b/app/services/gamebridge/payloads/StatusPayload.ts index 83b2372a..0d020fce 100644 --- a/app/services/gamebridge/payloads/StatusPayload.ts +++ b/app/services/gamebridge/payloads/StatusPayload.ts @@ -81,6 +81,7 @@ export default class StatusPayload extends Payload { gamemode, serverUptime, mapUptime, + gamemodes, } = payload.data; const { bridge, discord } = server; const webApp = bridge.container.getService("WebApp"); @@ -97,6 +98,7 @@ export default class StatusPayload extends Payload { const current_map = mapName ?? server.mapName ?? "unknown map"; const current_gamemode = gamemode ?? server.gamemode ?? { folderName: "???", name: "unknown gamemode" }; + const current_gamemodes = gamemodes ?? server.gamemodes ?? []; const current_serverUptime = serverUptime ?? server.serverUptime ?? 0; const current_mapUptime = mapUptime ?? server.mapUptime ?? 0; const current_workshopMap = workshopMap ?? server.workshopMap; @@ -252,14 +254,15 @@ export default class StatusPayload extends Payload { } // Server status metadata - server.status.mapThumbnail = mapThumbnail; - server.status.image = embed.data.image?.url ?? null; - server.status.players = current_players; server.defcon = current_defcon; server.gamemode = current_gamemode; + server.gamemodes = current_gamemodes; server.mapName = current_map; server.mapUptime = current_mapUptime; server.serverUptime = current_serverUptime; + server.status.image = embed.data.image?.url ?? null; + server.status.mapThumbnail = mapThumbnail; + server.status.players = current_players; server.workshopMap = current_workshopMap; for (const [, player] of Object.entries(server.status.players)) { diff --git a/app/services/gamebridge/payloads/structures/StatusRequest.ts b/app/services/gamebridge/payloads/structures/StatusRequest.ts index f75df18b..463dead4 100644 --- a/app/services/gamebridge/payloads/structures/StatusRequest.ts +++ b/app/services/gamebridge/payloads/structures/StatusRequest.ts @@ -39,5 +39,6 @@ export default interface StatusRequest extends PayloadRequest { folderName: string; name: string; }; + gamemodes?: string[]; }; }