diff --git a/src/commands/index.js b/src/commands/index.js index c3b13a2..100dff2 100644 --- a/src/commands/index.js +++ b/src/commands/index.js @@ -3,6 +3,7 @@ const { SlashCommandBuilder } = require('@discordjs/builders'); const { starryCommandFarewell } = require('./farewell'); const { starryCommandJoin } = require('./join'); const { starryCommandTokenAdd } = require('./tokenAdd'); +const { starryCommandTokenList } = require('./tokenList'); // TODO: we'll add this in later // const { starryCommandTokenEdit } = require('./tokenEdit'); const { starryCommandTokenRemove } = require('./tokenRemove'); @@ -21,6 +22,7 @@ const definedCommands = [ options: [ starryCommandTokenAdd, // starryCommandTokenEdit, + starryCommandTokenList, starryCommandTokenRemove ] }, diff --git a/src/commands/tokenList.js b/src/commands/tokenList.js new file mode 100644 index 0000000..a2a771b --- /dev/null +++ b/src/commands/tokenList.js @@ -0,0 +1,30 @@ +const { rolesGet } = require("../db"); +const { createEmbed } = require("../utils/messages"); + +async function starryCommandTokenList(req, res, ctx, next) { + const { interaction } = req; + let roles = await rolesGet(interaction.guildId); + const title = `${roles.length} roles found`; + const description = roles.length > 0 ? + `${roles.map(role => { + const roleName = role.give_role; + const roleAmt = role.has_minimum_of; + return `-${roleName} (min: ${roleAmt})\n`; + }).join('')}` : + `This will be way more exciting when roles are added :)`; + + interaction.reply({ + embeds: [ + createEmbed({ title, description }) + ] + }) + res.done(); +} + +module.exports = { + starryCommandTokenList: { + name: 'list', + description: 'List all token rules for this guild', + execute: starryCommandTokenList, + } +}