Skip to content

Commit

Permalink
Merge pull request #63 from starryzone/vli-token-rule-list
Browse files Browse the repository at this point in the history
✨ Add new tokenList command to list the token rules per guild
  • Loading branch information
mikedotexe authored Feb 15, 2022
2 parents f67502b + ae6ac04 commit 40d7c21
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/commands/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -21,6 +22,7 @@ const definedCommands = [
options: [
starryCommandTokenAdd,
// starryCommandTokenEdit,
starryCommandTokenList,
starryCommandTokenRemove
]
},
Expand Down
30 changes: 30 additions & 0 deletions src/commands/tokenList.js
Original file line number Diff line number Diff line change
@@ -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,
}
}

0 comments on commit 40d7c21

Please sign in to comment.