seperate settings for increasing and decreasing templates
This commit is contained in:
parent
8d66d125b8
commit
db7b52d66e
|
@ -165,6 +165,14 @@ export const counterConfigs = new Map([
|
|||
type: ConfigType.String,
|
||||
default: '**%user** has %action the counter by **%amt**.'
|
||||
}],
|
||||
['messageTemplateIncrease', {
|
||||
type: ConfigType.String,
|
||||
default: ''
|
||||
}],
|
||||
['messageTemplateDecrease', {
|
||||
type: ConfigType.String,
|
||||
default: ''
|
||||
}],
|
||||
|
||||
// these ones are fake and are just stand-ins for values defined inside the actual counters table
|
||||
['emoji', {
|
||||
|
@ -204,7 +212,12 @@ export async function updateCounter(bot: Client, counter: Counter, value: number
|
|||
export async function announceCounterUpdate(bot: Client, member: GuildMember, delta: number, counter: Counter, value: number) {
|
||||
const channel = await bot.channels.fetch(counter.channel) as TextChannel;
|
||||
|
||||
const template = await getCounterConfig(counter.id, 'messageTemplate') as string;
|
||||
let template = await getCounterConfig(counter.id, 'messageTemplate') as string;
|
||||
const templateIncrease = await getCounterConfig(counter.id, 'messageTemplateIncrease') as string;
|
||||
if (templateIncrease !== '' && delta > 0) template = templateIncrease;
|
||||
const templateDecrease = await getCounterConfig(counter.id, 'messageTemplateDecrease') as string;
|
||||
if (templateDecrease !== '' && delta < 0) template = templateDecrease;
|
||||
|
||||
const anonymous = await getCounterConfig(counter.id, 'anonymous') as boolean;
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
|
@ -214,6 +227,7 @@ export async function announceCounterUpdate(bot: Client, member: GuildMember, de
|
|||
.replaceAll('%user', anonymous ? 'someone' : member.toString())
|
||||
.replaceAll('%action', delta > 0 ? 'increased' : 'decreased')
|
||||
.replaceAll('%amt', Math.abs(delta).toString())
|
||||
.replaceAll('%total', value.toString())
|
||||
)
|
||||
.setTimestamp()
|
||||
.setFooter({
|
||||
|
|
Loading…
Reference in a new issue