From ca046bd70944eef4ef1413d033baff8070419e24 Mon Sep 17 00:00:00 2001 From: DIVISIONSolar Date: Thu, 7 Sep 2023 14:32:03 -0400 Subject: [PATCH] Add map command --- config/bot-sites.example.json | 44 ++++++++++++++++++++ lang/lang.en-US.json | 16 +++++-- src/commands/args.ts | 7 ++++ src/commands/chat/index.ts | 1 + src/commands/chat/information/map-command.ts | 30 ++++++++++--- src/commands/metadata.ts | 15 +++++++ src/start-bot.ts | 2 + 7 files changed, 105 insertions(+), 10 deletions(-) create mode 100644 config/bot-sites.example.json diff --git a/config/bot-sites.example.json b/config/bot-sites.example.json new file mode 100644 index 0000000..9831d08 --- /dev/null +++ b/config/bot-sites.example.json @@ -0,0 +1,44 @@ +[ + { + "name": "top.gg", + "enabled": false, + "url": "https://top.gg/api/bots//stats", + "authorization": "", + "body": "{\"server_count\":{{SERVER_COUNT}}}" + }, + { + "name": "bots.ondiscord.xyz", + "enabled": false, + "url": "https://bots.ondiscord.xyz/bot-api/bots//guilds", + "authorization": "", + "body": "{\"guildCount\":{{SERVER_COUNT}}}" + }, + { + "name": "discord.bots.gg", + "enabled": false, + "url": "https://discord.bots.gg/api/v1/bots//stats", + "authorization": "", + "body": "{\"guildCount\":{{SERVER_COUNT}}}" + }, + { + "name": "discordbotlist.com", + "enabled": false, + "url": "https://discordbotlist.com/api/bots//stats", + "authorization": "Bot ", + "body": "{\"guilds\":{{SERVER_COUNT}}}" + }, + { + "name": "discords.com", + "enabled": false, + "url": "https://discords.com/bots/api/bot/", + "authorization": "", + "body": "{\"server_count\":{{SERVER_COUNT}}}" + }, + { + "name": "disforge.com", + "enabled": false, + "url": "https://disforge.com/api/botstats/", + "authorization": "", + "body": "{\"servers\":{{SERVER_COUNT}}}" + } +] diff --git a/lang/lang.en-US.json b/lang/lang.en-US.json index 1dddee6..2f5ff6a 100644 --- a/lang/lang.en-US.json +++ b/lang/lang.en-US.json @@ -33,6 +33,10 @@ "Sorry but we don't currently support Bedrock due to TCPShield charging $100/mo for geyser support.\n\n(They offer than just this for the plan).\n\n:( Maybe consider donating?" ] }, + "servermap": { + "title": "**Dynmap for {{SERVER}}**", + "description": ["{{LINK}}"] + }, "helpContactSupport": { "title": "Help - {{REF:helpOptions.contactSupport}}", "description": [ @@ -211,7 +215,8 @@ "help": "help", "info": "info", "test": "test", - "howtojoin": "howtojoin" + "howtojoin": "howtojoin", + "map": "map" }, "userCommands": { "viewDateJoined": "View Date Joined" @@ -222,20 +227,23 @@ "arguments": { "command": "command", "option": "option", - "platform": "platform" + "platform": "platform", + "server": "server" }, "commandDescs": { "dev": "Developer use only.", "help": "Find help or contact support.", "info": "View bot info.", "test": "Run the test command.", - "howtojoin": "How To Join" + "howtojoin": "How To Join.", + "map": "The dynmap for the server." }, "argDescs": { "devCommand": "Command.", "helpOption": "Option.", "infoOption": "Option.", - "platform": "Ex. PC, Xbox, Playstation, Mobile." + "platform": "Ex. PC, Xbox, Playstation, Mobile.", + "server": "The server's name" }, "fields": { "commands": "Commands", diff --git a/src/commands/args.ts b/src/commands/args.ts index fb6f326..9f279dc 100644 --- a/src/commands/args.ts +++ b/src/commands/args.ts @@ -64,4 +64,11 @@ export class Args { description_localizations: Lang.getRefLocalizationMap('argDescs.platform'), type: ApplicationCommandOptionType.String, }; + public static readonly server: APIApplicationCommandBasicOption = { + name: Lang.getRef('arguments.server', Language.Default), + name_localizations: Lang.getRefLocalizationMap('arguments.server'), + description: Lang.getRef('argDescs.server', Language.Default), + description_localizations: Lang.getRefLocalizationMap('argDescs.server'), + type: ApplicationCommandOptionType.String, + }; } diff --git a/src/commands/chat/index.ts b/src/commands/chat/index.ts index e281d32..c08c8f0 100644 --- a/src/commands/chat/index.ts +++ b/src/commands/chat/index.ts @@ -3,3 +3,4 @@ export { HelpCommand } from './help-command.js'; export { InfoCommand } from './info-command.js'; export { TestCommand } from './test-command.js'; export { HowToJoinCommand } from './information/howtojoin-command.js'; +export { MapCommand } from './information/map-command.js'; diff --git a/src/commands/chat/information/map-command.ts b/src/commands/chat/information/map-command.ts index 98e1f12..a3f8a57 100644 --- a/src/commands/chat/information/map-command.ts +++ b/src/commands/chat/information/map-command.ts @@ -19,18 +19,36 @@ export class MapCommand implements Command { }; // Check if the user entered "Survival" - if (args.Server.toLowerCase() === "survival") { - await intr.reply('Here is the link for Survival: https://map.pxlvrs.net/survival'); + if (args.Server.toLowerCase() === 'survival') { + await InteractionUtils.send( + intr, + Lang.getEmbed('displayEmbeds.servermap', data.lang, { + SERVER: 'Survival', + LINK: 'https://map.pxlvrs.net/survival', + }) + ); } // Check if the user entered "LifeSteal" - else if (args.Server.toLowerCase() === "lifesteal") { - await intr.reply('Here is the link for LifeSteal: https://map.pxlvrs.net/lifesteal'); + else if (args.Server.toLowerCase() === 'lifesteal') { + await InteractionUtils.send( + intr, + Lang.getEmbed('displayEmbeds.servermap', data.lang, { + SERVER: 'LifeSteal', + LINK: 'https://map.pxlvrs.net/lifesteal', + }) + ); } // If the input is not recognized, provide valid inputs else { - await intr.reply('Invalid input. Valid options are: Survival, LifeSteal'); + await InteractionUtils.send( + intr, + Lang.getEmbed('displayEmbeds.servermap', data.lang, { + SERVER: 'N/A', + LINK: 'Invalid input. Valid options are: Survival, LifeSteal', + }) + ); } } -} \ No newline at end of file +} diff --git a/src/commands/metadata.ts b/src/commands/metadata.ts index 0b1173e..e1550c1 100644 --- a/src/commands/metadata.ts +++ b/src/commands/metadata.ts @@ -84,6 +84,21 @@ export const ChatCommandMetadata: { }, ], }, + MAP: { + type: ApplicationCommandType.ChatInput, + name: Lang.getRef('chatCommands.map', Language.Default), + name_localizations: Lang.getRefLocalizationMap('chatCommands.map'), + description: Lang.getRef('commandDescs.map', Language.Default), + description_localizations: Lang.getRefLocalizationMap('commandDescs.map'), + dm_permission: true, + default_member_permissions: undefined, + options: [ + { + ...Args.server, + required: true, + }, + ], + }, }; export const MessageCommandMetadata: { diff --git a/src/start-bot.ts b/src/start-bot.ts index 42d67bd..a256b62 100644 --- a/src/start-bot.ts +++ b/src/start-bot.ts @@ -9,6 +9,7 @@ import { InfoCommand, TestCommand, HowToJoinCommand, + MapCommand } from './commands/chat/index.js'; import { ChatCommandMetadata, @@ -75,6 +76,7 @@ async function start(): Promise { // TODO: Add new commands here new HowToJoinCommand(), + new MapCommand(), ]; // Buttons