fix newlines not being respected in roll command, fix some followup issues in the [[r or [[roll command variants
This commit is contained in:
parent
fcae60cb69
commit
41fbb1bd50
|
@ -40,7 +40,7 @@ export const roll = async (message: DiscordenoMessage, args: string[], command:
|
||||||
|
|
||||||
// Rest of this command is in a try-catch to protect all sends/edits from erroring out
|
// Rest of this command is in a try-catch to protect all sends/edits from erroring out
|
||||||
try {
|
try {
|
||||||
const originalCommand = `${config.prefix}${command} ${args.join(' ')}`;
|
const originalCommand = `${config.prefix}${command}${command.length === 0 ? args.join('').trim() : args.join('')}`;
|
||||||
|
|
||||||
const m = await message.reply(rollingEmbed);
|
const m = await message.reply(rollingEmbed);
|
||||||
|
|
||||||
|
@ -60,14 +60,14 @@ export const roll = async (message: DiscordenoMessage, args: string[], command:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let rollCmd = message.content.startsWith(`${config.prefix}r`) ? remainingArgs.join(' ') : `${config.prefix}${command} ${remainingArgs.join(' ')}`;
|
let rollCmd = message.content.startsWith(`${config.prefix}r`) ? remainingArgs.join('') : `${config.prefix}${command}${remainingArgs.join('')}`;
|
||||||
|
|
||||||
// Try to ensure the roll is wrapped
|
// Try to ensure the roll is wrapped
|
||||||
if (!rollCmd.includes(config.prefix)) {
|
|
||||||
rollCmd = `${config.prefix}${rollCmd}`;
|
|
||||||
}
|
|
||||||
if (!rollCmd.includes(config.postfix)) {
|
if (!rollCmd.includes(config.postfix)) {
|
||||||
rollCmd = `${rollCmd}${config.postfix}`;
|
rollCmd = `${rollCmd.trim()}${config.postfix}`;
|
||||||
|
}
|
||||||
|
if (!rollCmd.includes(config.prefix) || rollCmd.indexOf(config.prefix) > rollCmd.indexOf(config.postfix)) {
|
||||||
|
rollCmd = `${config.prefix}${rollCmd.trim()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendRollRequest({
|
sendRollRequest({
|
||||||
|
|
|
@ -32,7 +32,12 @@ export const messageCreateHandler = (message: DiscordenoMessage) => {
|
||||||
.slice(config.prefix.length)
|
.slice(config.prefix.length)
|
||||||
.trim()
|
.trim()
|
||||||
.split(/[ \n]+/g);
|
.split(/[ \n]+/g);
|
||||||
|
const argSpaces = message.content
|
||||||
|
.slice(config.prefix.length)
|
||||||
|
.trim()
|
||||||
|
.split(new RegExp(/([ \n]+)/, 'g'));
|
||||||
const command = args.shift()?.toLowerCase();
|
const command = args.shift()?.toLowerCase();
|
||||||
|
argSpaces.shift();
|
||||||
|
|
||||||
// All commands below here
|
// All commands below here
|
||||||
|
|
||||||
|
@ -128,7 +133,7 @@ export const messageCreateHandler = (message: DiscordenoMessage) => {
|
||||||
case 'r':
|
case 'r':
|
||||||
// [[roll or [[r
|
// [[roll or [[r
|
||||||
// Dice rolling commence!
|
// Dice rolling commence!
|
||||||
commands.roll(message, args, args.join(''));
|
commands.roll(message, argSpaces, '');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Non-standard commands
|
// Non-standard commands
|
||||||
|
@ -139,7 +144,7 @@ export const messageCreateHandler = (message: DiscordenoMessage) => {
|
||||||
} else if (command && `${command}${args.join('')}`.includes(config.postfix)) {
|
} else if (command && `${command}${args.join('')}`.includes(config.postfix)) {
|
||||||
// [[roll]]
|
// [[roll]]
|
||||||
// Dice rolling commence!
|
// Dice rolling commence!
|
||||||
commands.roll(message, args, command);
|
commands.roll(message, argSpaces, command);
|
||||||
} else if (command) {
|
} else if (command) {
|
||||||
// [[emoji or [[emoji-alias
|
// [[emoji or [[emoji-alias
|
||||||
// Check if the unhandled command is an emoji request
|
// Check if the unhandled command is an emoji request
|
||||||
|
|
Loading…
Reference in New Issue