Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add new tokenList command to list the token rules per guild #63

Merged
merged 1 commit into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
}
}