Add macro limit
This commit is contained in:
parent
c8ae0f291f
commit
e0c6c9c5c3
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dicedicedice",
|
"name": "dicedicedice",
|
||||||
"version": "1.3.1",
|
"version": "1.3.2",
|
||||||
"description": "Dice bot",
|
"description": "Dice bot",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
12
src/index.js
12
src/index.js
@ -133,7 +133,7 @@ const rollDice = (dice, respond) => {
|
|||||||
let operationSymbol = dice.operation
|
let operationSymbol = dice.operation
|
||||||
let response = ''
|
let response = ''
|
||||||
|
|
||||||
switch(dice.mode) {
|
switch(dice.mode.toLowerCase()) {
|
||||||
case 'd':
|
case 'd':
|
||||||
result = rolls.reduce((a, v) => a + v, 0)
|
result = rolls.reduce((a, v) => a + v, 0)
|
||||||
break
|
break
|
||||||
@ -269,6 +269,7 @@ const reloadMacros = async guildId => {
|
|||||||
Routes.applicationGuildCommands(process.env.DISCORD_ID, guildId),
|
Routes.applicationGuildCommands(process.env.DISCORD_ID, guildId),
|
||||||
{ body: commands }
|
{ body: commands }
|
||||||
)
|
)
|
||||||
|
.catch(err => console.error('Failed to reload macros:', err) )
|
||||||
}
|
}
|
||||||
|
|
||||||
const elipsify = (string, maxLength) =>
|
const elipsify = (string, maxLength) =>
|
||||||
@ -360,15 +361,20 @@ addSubcommands({
|
|||||||
]
|
]
|
||||||
}, {
|
}, {
|
||||||
add: async interaction => {
|
add: async interaction => {
|
||||||
let name = interaction.options.get('name').value.toLowerCase()
|
|
||||||
let respond = openResponses(interaction, true)
|
let respond = openResponses(interaction, true)
|
||||||
|
let name = interaction.options.get('name').value.toLowerCase()
|
||||||
|
|
||||||
if(!constants.macroNameRegex.test(name))
|
if(!constants.macroNameRegex.test(name))
|
||||||
return respond("Please provide a macro name that consists of only alphanumeric characters.")
|
return respond("Please provide a macro name that consists of only alphanumeric characters.")
|
||||||
|
|
||||||
if(commands.has(name))
|
if(commands.has(name))
|
||||||
return respond("Uhh,, I think that macro name is already taken by my own commands, sorry.")
|
return respond("Uhh,, I think that macro name is already taken by my own commands, sorry.")
|
||||||
|
|
||||||
|
let macros = macroCache.get(interaction.guild.id)
|
||||||
|
|
||||||
|
if(macros && !macros[name] && Object.keys(macros).length >= 100)
|
||||||
|
return respond("I can't keep track of that many macros,, ;-;")
|
||||||
|
|
||||||
let dice = interaction.options.get('dice').value
|
let dice = interaction.options.get('dice').value
|
||||||
|
|
||||||
if(!constants.rollRegex.test(dice) )
|
if(!constants.rollRegex.test(dice) )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user