misc.roll: interaction command per request
This commit is contained in:
		
							parent
							
								
									cb503762a7
								
							
						
					
					
						commit
						d56f8b56f7
					
				
					 1 changed files with 18 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -1,4 +1,6 @@
 | 
			
		|||
const Command = require("#lib/command.js");
 | 
			
		||||
const InteractionCommand = require("#lib/interactionCommand.js");
 | 
			
		||||
const {ApplicationCommandOptionTypes} = require("#util/dconstants.js");
 | 
			
		||||
 | 
			
		||||
const roll = new Command("roll");
 | 
			
		||||
roll.category = "misc";
 | 
			
		||||
| 
						 | 
				
			
			@ -22,3 +24,19 @@ roll.callback = function (msg, line) {
 | 
			
		|||
  return `:game_die: (d${line}): ${1 + res}`;
 | 
			
		||||
};
 | 
			
		||||
hf.registerCommand(roll);
 | 
			
		||||
 | 
			
		||||
const rollInteraction = new InteractionCommand("roll");
 | 
			
		||||
rollInteraction.helpText = "Roll a dice";
 | 
			
		||||
rollInteraction.options.input = {
 | 
			
		||||
  name: "sides",
 | 
			
		||||
  type: ApplicationCommandOptionTypes.NUMBER,
 | 
			
		||||
  description: "How many sides to pick from",
 | 
			
		||||
  required: false,
 | 
			
		||||
  default: 6,
 | 
			
		||||
};
 | 
			
		||||
rollInteraction.callback = async function (interaction) {
 | 
			
		||||
  const sides = this.getOption(interaction, "sides");
 | 
			
		||||
 | 
			
		||||
  return roll.callback(interaction, sides);
 | 
			
		||||
};
 | 
			
		||||
hf.registerCommand(rollInteraction);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue