Add command for simulating extended dice roll and basic shell code
This commit is contained in:
parent
8fee5df53e
commit
f700c892ac
2 changed files with 128 additions and 8 deletions
|
@ -27,6 +27,84 @@ const commands = [
|
||||||
{ name: 'Framework', value: 'framework' },
|
{ name: 'Framework', value: 'framework' },
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
),
|
||||||
|
new SlashCommandBuilder()
|
||||||
|
.setName('simulate')
|
||||||
|
.setDescription('Simulate different type of dice rolls.')
|
||||||
|
.addSubcommand(subcommand =>
|
||||||
|
subcommand
|
||||||
|
.setName('simple')
|
||||||
|
.setDescription('Simulate a simple dice roll.')
|
||||||
|
)
|
||||||
|
.addSubcommand(subcommand =>
|
||||||
|
subcommand
|
||||||
|
.setName('extended')
|
||||||
|
.setDescription('Simulate an extended dice roll.')
|
||||||
|
.addNumberOption(option =>
|
||||||
|
option
|
||||||
|
.setName('dicepool')
|
||||||
|
.setDescription('The dicepool of the roll.')
|
||||||
|
.setRequired(true)
|
||||||
|
)
|
||||||
|
.addNumberOption(option =>
|
||||||
|
option
|
||||||
|
.setName('difficulty')
|
||||||
|
.setDescription('The difficulty of the roll.')
|
||||||
|
.setRequired(true)
|
||||||
|
)
|
||||||
|
.addNumberOption(option =>
|
||||||
|
option
|
||||||
|
.setName('interval')
|
||||||
|
.setDescription('The interval of the roll.')
|
||||||
|
.setRequired(false)
|
||||||
|
)
|
||||||
|
.addNumberOption(option =>
|
||||||
|
option
|
||||||
|
.setName('max-edge')
|
||||||
|
.setDescription('The maximum number of edge to use.')
|
||||||
|
.setRequired(false)
|
||||||
|
)
|
||||||
|
.addStringOption(option =>
|
||||||
|
option
|
||||||
|
.setName('edgetype')
|
||||||
|
.setDescription('What type of edgeing should be used ?')
|
||||||
|
.addChoices(
|
||||||
|
{ name: 'None', value: 'none' },
|
||||||
|
{ name: 'Turn Up', value: 'up' },
|
||||||
|
{ name: 'Reroll', value: 'reroll' },
|
||||||
|
{ name: 'Smart', value: 'smart' },
|
||||||
|
{ name: 'All', value: 'all' },
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.addStringOption(option =>
|
||||||
|
option
|
||||||
|
.setName('edgerefresh')
|
||||||
|
.setDescription('How often should the edge refresh ?')
|
||||||
|
.addChoices(
|
||||||
|
{ name: 'Never', value: 'none' },
|
||||||
|
{ name: 'Every Roll', value: 'fill' },
|
||||||
|
{ name: '1 Edge per Roll', value: 'once' },
|
||||||
|
{ name: '2 Edge per Roll', value: 'twice' },
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.addNumberOption(option =>
|
||||||
|
option
|
||||||
|
.setName('amount')
|
||||||
|
.setDescription('How many times should the roll be simulated ? WARNING this service is pricey !')
|
||||||
|
.setRequired(false)
|
||||||
|
)
|
||||||
|
.addBooleanOption(option =>
|
||||||
|
option
|
||||||
|
.setName('hidden')
|
||||||
|
.setDescription('Should the result be hidden ?')
|
||||||
|
.setRequired(false)
|
||||||
|
)
|
||||||
|
.addBooleanOption(option =>
|
||||||
|
option
|
||||||
|
.setName('true-random')
|
||||||
|
.setDescription('Should the dice be truly random ?')
|
||||||
|
.setRequired(false)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
.map(command => command.toJSON());
|
.map(command => command.toJSON());
|
||||||
|
|
58
index.js
58
index.js
|
@ -1,5 +1,6 @@
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
|
|
||||||
|
const { crypto } = require('crypto');
|
||||||
const { Client, GatewayIntentBits } = require('discord.js');
|
const { Client, GatewayIntentBits } = require('discord.js');
|
||||||
const token = process.env.TOKEN;
|
const token = process.env.TOKEN;
|
||||||
|
|
||||||
|
@ -15,15 +16,56 @@ client.on('interactionCreate', async interaction => {
|
||||||
if (!interaction.isCommand()) return;
|
if (!interaction.isCommand()) return;
|
||||||
console.log(interaction.commandName);
|
console.log(interaction.commandName);
|
||||||
|
|
||||||
let commandName = interaction.commandName;
|
switch (interaction.commandName) {
|
||||||
|
case "generate":
|
||||||
|
switch (interaction.options.getSubcommand()) {
|
||||||
|
case "host":
|
||||||
|
let rating = interaction.options.getNumber("rating");
|
||||||
|
let type = interaction.options.getString("type") ?? "foundation";
|
||||||
|
await interaction.reply({files: ["./france-in-pictures-beautiful-places-to-photograph-eiffel-tower.jpg"]});
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
await interaction.reply({ content: 'Invalid subcommand!', ephemeral: true });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "simulate":
|
||||||
|
await interaction.deferReply();
|
||||||
|
switch (interaction.options.getSubcommand()) {
|
||||||
|
case "simple":
|
||||||
|
await interaction.reply({ content: 'Simple dice roll!', ephemeral: true });
|
||||||
|
break;
|
||||||
|
|
||||||
if (commandName === "generate") {
|
case "extended":
|
||||||
if (interaction.options.getSubcommand() === "host") {
|
let dicepool = interaction.options.getNumber("dicepool");
|
||||||
let rating = interaction.options.getNumber("rating");
|
let difficulty = interaction.options.getNumber("difficulty");
|
||||||
let type = interaction.options.getString("type") ?? "foundation";
|
let interval = interaction.options.getNumber("interval") ?? 1;
|
||||||
await interaction.reply({files: ["./france-in-pictures-beautiful-places-to-photograph-eiffel-tower.jpg"]});
|
let simAmount = interaction.options.getNumber("amount") ?? 10000;
|
||||||
}
|
let hidden = interaction.options.getBoolean("hidden") ?? false;
|
||||||
|
let edgeType = interaction.options.getString("edge") ?? "none";
|
||||||
|
let edgeRefresh = interaction.options.getString("edgerefresh") ?? "none";
|
||||||
|
let maxEdge = interaction.options.getNumber("edge-max") ?? 6;
|
||||||
|
let useTrueRandom = interaction.options.getBoolean("true-random") ?? false;
|
||||||
|
let edge = maxEdge;
|
||||||
|
|
||||||
|
let warnings = [];
|
||||||
|
let calculatedResults = [];
|
||||||
|
let realResults = [];
|
||||||
|
|
||||||
|
await interaction.reply({ content: 'Extended dice roll!', ephemeral: hidden });
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
|
async function fillArrayWithRandomDice(arr) {
|
||||||
|
for (let i = 0; i < arr.length; i++) {
|
||||||
|
arr[i] = await crypto.randomInt(1, 7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
client.login(token);
|
client.login(token);
|
Loading…
Add table
Add a link
Reference in a new issue