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
 | 
			
		||||
  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);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -60,14 +60,14 @@ export const roll = async (message: DiscordenoMessage, args: string[], command:
 | 
			
		|||
      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
 | 
			
		||||
    if (!rollCmd.includes(config.prefix)) {
 | 
			
		||||
      rollCmd = `${config.prefix}${rollCmd}`;
 | 
			
		||||
    }
 | 
			
		||||
    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({
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,7 +32,12 @@ export const messageCreateHandler = (message: DiscordenoMessage) => {
 | 
			
		|||
    .slice(config.prefix.length)
 | 
			
		||||
    .trim()
 | 
			
		||||
    .split(/[ \n]+/g);
 | 
			
		||||
  const argSpaces = message.content
 | 
			
		||||
    .slice(config.prefix.length)
 | 
			
		||||
    .trim()
 | 
			
		||||
    .split(new RegExp(/([ \n]+)/, 'g'));
 | 
			
		||||
  const command = args.shift()?.toLowerCase();
 | 
			
		||||
  argSpaces.shift();
 | 
			
		||||
 | 
			
		||||
  // All commands below here
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -128,7 +133,7 @@ export const messageCreateHandler = (message: DiscordenoMessage) => {
 | 
			
		|||
    case 'r':
 | 
			
		||||
      // [[roll or [[r
 | 
			
		||||
      // Dice rolling commence!
 | 
			
		||||
      commands.roll(message, args, args.join(''));
 | 
			
		||||
      commands.roll(message, argSpaces, '');
 | 
			
		||||
      break;
 | 
			
		||||
    default:
 | 
			
		||||
      // Non-standard commands
 | 
			
		||||
| 
						 | 
				
			
			@ -139,7 +144,7 @@ export const messageCreateHandler = (message: DiscordenoMessage) => {
 | 
			
		|||
      } else if (command && `${command}${args.join('')}`.includes(config.postfix)) {
 | 
			
		||||
        // [[roll]]
 | 
			
		||||
        // Dice rolling commence!
 | 
			
		||||
        commands.roll(message, args, command);
 | 
			
		||||
        commands.roll(message, argSpaces, command);
 | 
			
		||||
      } else if (command) {
 | 
			
		||||
        // [[emoji or [[emoji-alias
 | 
			
		||||
        // Check if the unhandled command is an emoji request
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue