71 lines
No EOL
2.3 KiB
JavaScript
71 lines
No EOL
2.3 KiB
JavaScript
require('dotenv').config();
|
|
|
|
const { crypto } = require('crypto');
|
|
const { Client, GatewayIntentBits } = require('discord.js');
|
|
const token = process.env.TOKEN;
|
|
|
|
const client = new Client({
|
|
intents: [GatewayIntentBits.Guilds]
|
|
})
|
|
|
|
client.once('ready', () => {
|
|
console.log('Bot is Ready!');
|
|
});
|
|
|
|
client.on('interactionCreate', async interaction => {
|
|
if (!interaction.isCommand()) return;
|
|
console.log(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;
|
|
|
|
case "extended":
|
|
let dicepool = interaction.options.getNumber("dicepool");
|
|
let difficulty = interaction.options.getNumber("difficulty");
|
|
let interval = interaction.options.getNumber("interval") ?? 1;
|
|
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); |