counter help command
This commit is contained in:
parent
b0ea73febc
commit
9a3f30bf65
|
@ -17,6 +17,7 @@
|
|||
"discord.js": "^14.13.0",
|
||||
"got": "^11.8.6",
|
||||
"knex": "^3.0.1",
|
||||
"outdent": "^0.8.0",
|
||||
"parse-color": "^1.0.0",
|
||||
"pretty-bytes": "^5.6.0",
|
||||
"random-seed": "^0.3.0",
|
||||
|
|
|
@ -20,6 +20,9 @@ dependencies:
|
|||
knex:
|
||||
specifier: ^3.0.1
|
||||
version: 3.0.1(sqlite3@5.1.6)
|
||||
outdent:
|
||||
specifier: ^0.8.0
|
||||
version: 0.8.0
|
||||
parse-color:
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0
|
||||
|
@ -1664,6 +1667,10 @@ packages:
|
|||
type-check: 0.4.0
|
||||
dev: true
|
||||
|
||||
/outdent@0.8.0:
|
||||
resolution: {integrity: sha512-KiOAIsdpUTcAXuykya5fnVVT+/5uS0Q1mrkRHcF89tpieSmY33O/tmc54CqwA+bfhbtEfZUNLHaPUiB9X3jt1A==}
|
||||
dev: false
|
||||
|
||||
/p-cancelable@2.1.1:
|
||||
resolution: {integrity: sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==}
|
||||
engines: {node: '>=8'}
|
||||
|
|
|
@ -1,11 +1,32 @@
|
|||
import { AutocompleteInteraction, Interaction, SlashCommandBuilder } from 'discord.js';
|
||||
import { Counter, CounterUserLink, db } from '../lib/db';
|
||||
import { counterAutocomplete, counterConfigs, findCounter, getCounterConfigRaw, getOptions, parseConfig, setCounterConfig, toStringConfig, updateCounter } from '../lib/counter';
|
||||
import { outdent } from 'outdent';
|
||||
|
||||
function extendOption(t: string) {
|
||||
return {name: t, value: t};
|
||||
}
|
||||
|
||||
const help = new Map([
|
||||
['message templates', outdent`
|
||||
When using \`messageTemplate\`, \`messageTemplateIncrease\` or \`messageTemplateDecrease\`, you are providing a **template string**.
|
||||
A template string is a **specially-formatted** string with placeholder values. For instance, a template string like so:
|
||||
|
||||
> **%user** has %action the counter by **%amt**.
|
||||
|
||||
Could be formatted as such:
|
||||
|
||||
> **@oatmealine** has incremented the counter by **1**.
|
||||
|
||||
Here are the keys you can use as special replacement values:
|
||||
|
||||
- \`%user\` - The user that changed the counter
|
||||
- \`%action\` - "decremented" or "incremented"
|
||||
- \`%amt\` - Amount by which the counter has changed
|
||||
- \`%total\` - The new counter value
|
||||
`]
|
||||
]);
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('counter')
|
||||
|
@ -182,6 +203,18 @@ module.exports = {
|
|||
.setName('list')
|
||||
.setDescription('[ADMIN] List every counter in this server')
|
||||
)
|
||||
.addSubcommand(sub =>
|
||||
sub
|
||||
.setName('help')
|
||||
.setDescription('Help guides for working with counters')
|
||||
.addStringOption(opt =>
|
||||
opt
|
||||
.setName('topic')
|
||||
.setDescription('The topic to get help on')
|
||||
.setRequired(true)
|
||||
.setChoices(...[...help.keys()].map(extendOption))
|
||||
)
|
||||
)
|
||||
.setDefaultMemberPermissions('0')
|
||||
.setDMPermission(false),
|
||||
|
||||
|
@ -365,6 +398,8 @@ module.exports = {
|
|||
.where('guild', interaction.guildId!);
|
||||
|
||||
await interaction.followUp(counters.map(c => `${c.emoji} **${c.value}** <#${c.channel}>`).join('\n'));
|
||||
} else if (subcommand === 'help') {
|
||||
await interaction.followUp(help.get(interaction.options.getString('topic', true))!);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue