q command working without descriptions

This commit is contained in:
Kalle
2022-06-16 21:45:15 +03:00
parent b22aef42a0
commit 8ced78193a
3 changed files with 117 additions and 120 deletions

View File

@@ -0,0 +1,81 @@
{
"sg": {
"seeking": [
"https://cdn.discordapp.com/attachments/865925063731445760/865925984065552404/SG_NT_Seeking.png",
"https://cdn.discordapp.com/attachments/865925063731445760/865926005776056360/SG_HT_Seeking.png"
],
"grillers": [
"https://cdn.discordapp.com/attachments/951441475034558484/951441708745388062/SG_NT_Grillers.png",
"https://cdn.discordapp.com/attachments/951441475034558484/951441742283018291/SG_HT_Grillers.png"
],
"rush": [
"https://cdn.discordapp.com/attachments/951442362775765022/951442493927485450/SG_NT_Rush.png",
"https://cdn.discordapp.com/attachments/951442362775765022/951442573971578880/SG_HT_Rush.png"
]
},
"mb": {
"seeking": [
"https://cdn.discordapp.com/attachments/865925063731445760/865926250963140628/MB_NT_Seeking.png",
"https://cdn.discordapp.com/attachments/865925063731445760/865926264409030696/MB_HT_Seeking.png"
],
"grillers": [
"https://cdn.discordapp.com/attachments/951441475034558484/951441787573141534/MB_NT_Grillers.png",
"https://cdn.discordapp.com/attachments/951441475034558484/951441828299817020/MB_HT_Grillers.png"
],
"rush": [
"https://cdn.discordapp.com/attachments/951442362775765022/951442753563291688/MB_NT_Rush.png",
"https://cdn.discordapp.com/attachments/951442362775765022/951442772345356288/MB_HT_Rush.png"
]
},
"lo": {
"seeking": [
"https://cdn.discordapp.com/attachments/865925063731445760/865926336199655424/LO_NT_Seeking.png",
"https://cdn.discordapp.com/attachments/865925063731445760/865926346545954836/LO_HT_Seeking.png"
],
"grillers": [
"https://cdn.discordapp.com/attachments/951441475034558484/951441880841854986/LO_NT_Grillers.png",
"https://cdn.discordapp.com/attachments/951441475034558484/951441897052864532/LO_HT_Grillers.png"
],
"rush": [
"https://cdn.discordapp.com/attachments/951442362775765022/951442800166174782/LO_NT_Rush.png",
"https://cdn.discordapp.com/attachments/951442362775765022/951442813596360714/LO_HT_Rush.png"
]
},
"ss": {
"seeking": [
"https://cdn.discordapp.com/attachments/865925063731445760/865926389223784468/SS_NT_Seeking.png",
"https://cdn.discordapp.com/attachments/865925063731445760/865926397561798656/SS_HT_Seeking.png"
],
"grillers": [
"https://cdn.discordapp.com/attachments/951441475034558484/951441959510233118/SS_NT_Grillers.png",
"https://cdn.discordapp.com/attachments/951441475034558484/951441974198698005/SS_HT_Grillers.png"
],
"rush": [
"https://cdn.discordapp.com/attachments/951442362775765022/951442852485935164/SS_NT_Rush.png",
"https://cdn.discordapp.com/attachments/951442362775765022/951442864305479710/SS_HT_Rush.png"
]
},
"ap": {
"seeking": [
"https://cdn.discordapp.com/attachments/865925063731445760/865926537629663242/AP_NT_Seeking.png",
"https://cdn.discordapp.com/attachments/865925063731445760/865926546635620382/AP_HT_Seeking.png"
],
"grillers": [
"https://cdn.discordapp.com/attachments/951441475034558484/951442012626878514/AP_NT_Grillers.png",
"https://cdn.discordapp.com/attachments/951441475034558484/951442021246201906/AP_HT_Grillers.png"
],
"rush": [
"https://cdn.discordapp.com/attachments/951442362775765022/951442890721206312/AP_NT_Rush.png",
"https://cdn.discordapp.com/attachments/951442362775765022/951442901219561472/AP_HT_Rush.png"
]
},
"fundamentals": "https://docs.google.com/document/d/1WTDiKSzV3SaD8Sn7wWlGreE2Y4Y7UrOv3SSv7qtzvcg/edit?usp=sharing",
"fundamentals2": "https://youtu.be/BvGbmLO94Po",
"advanced": "https://docs.google.com/document/d/16wcdlxqwqBvOnXIviB_ig0FS5_a96DKwYUIiGh6YHa8/edit?usp=sharing",
"spawns": "https://cdn.discordapp.com/attachments/836884751922757652/836886520250105886/SR_Time_Interval.png",
"ballpoint": "https://youtu.be/oSf39Yn0wOU",
"explo": "https://youtu.be/1qSW0_fA_L4",
"dynamo": "https://youtu.be/GrCCAI8giKc",
"bamboo": "https://youtu.be/yptwgqIoYiI",
"hydra": "https://youtu.be/_YduyOTVoLk"
}

View File

@@ -1,103 +1,41 @@
import type { BotCommand } from "../types";
import ids from "../ids";
import { SlashCommandBuilder } from "@discordjs/builders";
const groupedLinks = {
sg: {
seeking: [
"https://cdn.discordapp.com/attachments/865925063731445760/865925984065552404/SG_NT_Seeking.png",
"https://cdn.discordapp.com/attachments/865925063731445760/865926005776056360/SG_HT_Seeking.png",
],
grillers: [
"https://cdn.discordapp.com/attachments/951441475034558484/951441708745388062/SG_NT_Grillers.png",
"https://cdn.discordapp.com/attachments/951441475034558484/951441742283018291/SG_HT_Grillers.png",
],
rush: [
"https://cdn.discordapp.com/attachments/951442362775765022/951442493927485450/SG_NT_Rush.png",
"https://cdn.discordapp.com/attachments/951442362775765022/951442573971578880/SG_HT_Rush.png",
],
},
mb: {
seeking: [
"https://cdn.discordapp.com/attachments/865925063731445760/865926250963140628/MB_NT_Seeking.png",
"https://cdn.discordapp.com/attachments/865925063731445760/865926264409030696/MB_HT_Seeking.png",
],
grillers: [
"https://cdn.discordapp.com/attachments/951441475034558484/951441787573141534/MB_NT_Grillers.png",
"https://cdn.discordapp.com/attachments/951441475034558484/951441828299817020/MB_HT_Grillers.png",
],
rush: [
"https://cdn.discordapp.com/attachments/951442362775765022/951442753563291688/MB_NT_Rush.png",
"https://cdn.discordapp.com/attachments/951442362775765022/951442772345356288/MB_HT_Rush.png",
],
},
lo: {
seeking: [
"https://cdn.discordapp.com/attachments/865925063731445760/865926336199655424/LO_NT_Seeking.png",
"https://cdn.discordapp.com/attachments/865925063731445760/865926346545954836/LO_HT_Seeking.png",
],
grillers: [
"https://cdn.discordapp.com/attachments/951441475034558484/951441880841854986/LO_NT_Grillers.png",
"https://cdn.discordapp.com/attachments/951441475034558484/951441897052864532/LO_HT_Grillers.png",
],
rush: [
"https://cdn.discordapp.com/attachments/951442362775765022/951442800166174782/LO_NT_Rush.png",
"https://cdn.discordapp.com/attachments/951442362775765022/951442813596360714/LO_HT_Rush.png",
],
},
ss: {
seeking: [
"https://cdn.discordapp.com/attachments/865925063731445760/865926389223784468/SS_NT_Seeking.png",
"https://cdn.discordapp.com/attachments/865925063731445760/865926397561798656/SS_HT_Seeking.png",
],
grillers: [
"https://cdn.discordapp.com/attachments/951441475034558484/951441959510233118/SS_NT_Grillers.png",
"https://cdn.discordapp.com/attachments/951441475034558484/951441974198698005/SS_HT_Grillers.png",
],
rush: [
"https://cdn.discordapp.com/attachments/951442362775765022/951442852485935164/SS_NT_Rush.png",
"https://cdn.discordapp.com/attachments/951442362775765022/951442864305479710/SS_HT_Rush.png",
],
},
ap: {
seeking: [
"https://cdn.discordapp.com/attachments/865925063731445760/865926537629663242/AP_NT_Seeking.png",
"https://cdn.discordapp.com/attachments/865925063731445760/865926546635620382/AP_HT_Seeking.png",
],
grillers: [
"https://cdn.discordapp.com/attachments/951441475034558484/951442012626878514/AP_NT_Grillers.png",
"https://cdn.discordapp.com/attachments/951441475034558484/951442021246201906/AP_HT_Grillers.png",
],
rush: [
"https://cdn.discordapp.com/attachments/951442362775765022/951442890721206312/AP_NT_Rush.png",
"https://cdn.discordapp.com/attachments/951442362775765022/951442901219561472/AP_HT_Rush.png",
],
},
fundamentals:
"https://docs.google.com/document/d/1WTDiKSzV3SaD8Sn7wWlGreE2Y4Y7UrOv3SSv7qtzvcg/edit?usp=sharing",
fundamentals2: "https://youtu.be/BvGbmLO94Po",
advanced:
"https://docs.google.com/document/d/16wcdlxqwqBvOnXIviB_ig0FS5_a96DKwYUIiGh6YHa8/edit?usp=sharing",
spawns:
"https://cdn.discordapp.com/attachments/836884751922757652/836886520250105886/SR_Time_Interval.png",
ballpoint: "https://youtu.be/oSf39Yn0wOU",
explo: "https://youtu.be/1qSW0_fA_L4",
dynamo: "https://youtu.be/GrCCAI8giKc",
bamboo: "https://youtu.be/yptwgqIoYiI",
hydra: "https://youtu.be/_YduyOTVoLk",
} as const;
import groupedLinks from "./q-data.json";
const COMMAND_NAME = "q";
const WAVE_ARG = "wave";
type Wave = "seeking" | "grillers" | "rush";
export const questionCommand: BotCommand = {
name: COMMAND_NAME,
guilds: [ids.guilds.sro],
builder: addSubcommands(
new SlashCommandBuilder()
.setName(COMMAND_NAME)
.setDescription("Find a link")
),
execute: async ({ interaction }) => {
return interaction.reply("Pong!");
let value: string | string[] | Record<Wave, string | string[]> =
groupedLinks[
interaction.options.getSubcommand() as keyof typeof groupedLinks
];
if (typeof value === "string") {
return interaction.reply({ content: toContent(value), ephemeral: true });
}
value = value[interaction.options.getString(WAVE_ARG) as Wave];
if (!value) {
throw new Error(
`Unknown combination: ${interaction.options.getSubcommand()} + ${value}`
);
}
return interaction.reply({
content: toContent(value as any),
ephemeral: true,
});
},
};
@@ -111,12 +49,12 @@ function addSubcommands(builder: SlashCommandBuilder) {
if (typeof value !== "string") {
result.addStringOption((option) =>
option
.setName("name")
.setDescription("TODO: subname desc")
.setName(WAVE_ARG)
.setDescription("TODO: wave desc")
.setRequired(true)
.addChoices(
...Object.keys(value).map((key) => ({
name: key.toUpperCase(),
name: capitalizeFirstLetter(key),
value: key,
}))
)
@@ -130,33 +68,12 @@ function addSubcommands(builder: SlashCommandBuilder) {
return builder;
}
// const questionCommand: BotCommand = {
// name: "add",
// description: "Gives you the specified role",
// validGuilds: [ids.guilds.sro],
// execute: async ({ interaction }) => {
// let result: any = groupedLinks;
// console.log("args", args);
// for (const arg of args) {
// console.log("result", result);
// if (typeof result === "string" || !result) break;
// if (result.hasOwnProperty(arg)) {
// const value = result[arg];
// result = value;
// }
// }
function capitalizeFirstLetter(value: string) {
return value.charAt(0).toUpperCase() + value.slice(1);
}
// if (Array.isArray(result)) {
// result = result.join("\n");
// }
function toContent(value: string | string[]) {
if (typeof value === "string") return value;
// if (typeof result !== "string") {
// await msg.channel.send(
// "Invalid parameters - use: `!q` to see the available parameters"
// );
// return;
// }
// await msg.channel.send(result);
// },
// };
return value.join("\n");
}

View File

@@ -6,9 +6,8 @@ import type { CommandInteraction } from "discord.js";
export interface BotCommand {
name: string;
// description: string;
// /** ID's of guilds where this command will be set */
// guilds: string[];
/** ID's of guilds where this command will be set */
guilds: string[];
builder: SlashCommandBuilder | SlashCommandSubcommandsOnlyBuilder;
execute: (commandParameters: {
interaction: CommandInteraction;