Compare commits

..

3 Commits

5 changed files with 77 additions and 96 deletions

31
commands/dice.js Normal file
View File

@ -0,0 +1,31 @@
function diceRoll(side) {
return Math.ceil(Math.random() * side);
}
module.exports = () => async (ctx) => {
const numDice = parseInt(ctx.match[1] || "1");
const diceSides = parseInt(ctx.match[2]);
const rolls = Array(numDice)
.fill(0)
.map(() => diceRoll(diceSides));
const total = rolls.reduce((acc, curr) => acc + curr, 0);
const message = rolls
.map((i) => `_You roll a_ *D${diceSides}* _and get a_ *${i}*`)
.join("\n");
let totalMessage = "";
if (numDice > 1 || ctx.match[3])
totalMessage = `*Total:* ${total}`;
if (ctx.match[3]) {
const modifier = parseInt(ctx.match[5]);
const sign = ctx.match[4];
if (sign === "+") totalMessage += ` + ${modifier} = ${total + modifier}`;
else totalMessage += ` - ${modifier} = ${total - modifier}`;
}
ctx.reply(message + "\n\n" + totalMessage, { parse_mode: "Markdown" });
};

View File

@ -10,6 +10,7 @@ const info = require("./info");
const expand = require("./expand"); const expand = require("./expand");
const roleplay = require("./roleplay"); const roleplay = require("./roleplay");
const suggest = require("./suggest"); const suggest = require("./suggest");
const dice = require("./dice");
module.exports = (bot, [ questions, kys, insults, commands_list, words, roleplay_data ], feedback_id, apiToken, ugokiRoot, axios) => { module.exports = (bot, [ questions, kys, insults, commands_list, words, roleplay_data ], feedback_id, apiToken, ugokiRoot, axios) => {
@ -67,6 +68,7 @@ module.exports = (bot, [ questions, kys, insults, commands_list, words, roleplay
bot.command("donate", (ctx) => ctx.reply("Thanks for considering to donate." bot.command("donate", (ctx) => ctx.reply("Thanks for considering to donate."
+ " To support the development and hosting of Quadnite Bot, you can " + " To support the development and hosting of Quadnite Bot, you can "
+ "donate here: https://liberapay.com/ceda_ei/")); + "donate here: https://liberapay.com/ceda_ei/"));
bot.hears(/(\d*)d(\d+)(\s*([-+])\s*(\d+))?/, dice());
function getGetGif(command) { function getGetGif(command) {

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "quadnite-bot", "name": "quadnite-bot",
"version": "1.0.0", "version": "2.0.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "quadnite-bot", "name": "quadnite-bot",
"version": "1.0.0", "version": "2.0.0",
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"axios": "^0.21.0", "axios": "^0.21.0",

View File

@ -59,3 +59,15 @@ yes
help - Need help? Go here help - Need help? Go here
feedback - Send feedback, suggestion for kys, insult text feedback - Send feedback, suggestion for kys, insult text
rate - Rate me on TGDR rate - Rate me on TGDR
<b>Dice</b>
Simply mentioning a dice in a message will send the results
<code>[num]d[sides] [modifier]</code>
<i>num</i> is the number of the dices to roll. (Optional)
<i>sides</i> is the number of sides of the dice. (Required)
<i>modifier</i> is in the form of + or - followed by a number. (Optional)
<i>Examples</i>: 1d6, 2d10 + 5, 3d20 - 2, 2d20

View File

@ -605,32 +605,32 @@ On a scale of 1-10 how bitchy would you say you are?
On a scale of 1-10 how polite would you say you are? On a scale of 1-10 how polite would you say you are?
On a scale of 1-10 how attractive would you say you are? On a scale of 1-10 how attractive would you say you are?
If you could be any famous person who would you be and why? If you could be any famous person who would you be and why?
Whats your favourite animal beginning with the letter A? Whats your favourite animal?
Whats your favourite item of clothing beginning with the letter B? Whats your favourite item of clothing?
Whats your favourite expleitive beginning with the letter C? Whats your favourite expleitive?
Whats your favourite boys name beginning with the letter D? Whats your favourite boys name?
Whats your favourite girls name beginning with the letter E? Whats your favourite girls name?
Whats your favourite book beginning with the letter F? Whats your favourite book?
Whats your favourite bodypart beginning with the letter G? Whats your favourite bodypart?
Whats your favourite musical instrument beginning with the letter H? Whats your favourite musical instrument?
Whats your favourite song beginning with the letter I? Whats your favourite song?
Whats your favourite actress beginning with the letter J? Whats your favourite actress?
Whats your favourite actor beginning with the letter K? Whats your favourite actor?
Whats your favourite film beginning with the letter L? Whats your favourite film?
Whats your favourite tv show beginning with the letter M? Whats your favourite tv show?
Whats your favourite game beginning with the letter N? Whats your favourite game?
Whats your favourite non alcoholic drink beginning with the letter O? Whats your favourite non alcoholic drink?
Whats your favourite food beginning with the letter P? Whats your favourite food?
Whats your favourite band beginning with the letter Q? Whats your favourite band?
Whats your favourite author beginning with the letter R? Whats your favourite author?
Whats your favourite sport beginning with the letter S? Whats your favourite sport?
Whats your favourite job beginning with the letter T? Whats your favourite job?
Whats your favourite mythical creature beginning with the letter U? Whats your favourite mythical creature?
Whats your favourite alcoholic drink beginning with the letter V? Whats your favourite alcoholic drink?
Whats your favourite cartoon character beginning with the letter W? Whats your favourite cartoon character?
Whats your favourite word beginning with the letter X? Whats your favourite word?
Whats your favourite city beginning with the letter Y? Whats your favourite city?
Whats your favourite country beginning with the letter Z? Whats your favourite country?
Do you get seasick? Do you get seasick?
If you discovered a new species of dinosaur what would you call it? If you discovered a new species of dinosaur what would you call it?
Do you own a paddling pool? Do you own a paddling pool?
@ -1232,28 +1232,7 @@ If you were to remake a movie, what actors would you cast?
If you were to replace a character in your favourite movie, who would you replace with who? If you were to replace a character in your favourite movie, who would you replace with who?
Under rated actor who deserves to be famous in your opinion? Under rated actor who deserves to be famous in your opinion?
Whos your favourite celebrity with the same birthday or name as you? Whos your favourite celebrity with the same birthday or name as you?
Whats your favorite movie beginning with the letter A? Whats your favorite movie?
Whats your fav movie beginning with the letter B?
Whats your fav movie beginning with the letter C?
Whats your fav movie beginning with the letter D?
Whats your fav movie beginning with the letter E?
Whats your fav movie beginning with the letter F?
Whats your fav movie beginning with the letter G?
Whats your fav movie beginning with the letter H?
Whats your fav movie beginning with the letter I?
Whats your fav movie beginning with the letter J?
Whats your fav movie beginning with the letter K?
Whats your fav movie beginning with the letter L?
Whats your fav movie beginning with the letter M?
Whats your fav movie beginning with the letter N?
Whats your fav movie beginning with the letter O?
Whats your fav movie beginning with the letter P?
Whats your fav movie beginning with the letter S?
Whats your fav movie beginning with the letter Q?
Whats your fav movie beginning with the letter V?
Whats your fav movie beginning with the letter X?
Whats your fav movie beginning with the letter Y?
Whats your fav movie beginning with the letter Z?
What movie would you wish to come to life? What movie would you wish to come to life?
Movies you think one should watch before dying? Movies you think one should watch before dying?
Favourite actor who has not won a oscar yet? Favourite actor who has not won a oscar yet?
@ -1575,28 +1554,7 @@ What is your favourite cheat in GTA?
What car do you prefer to drive in GTA? What car do you prefer to drive in GTA?
Hardest mission youve done in GTA? Hardest mission youve done in GTA?
Easiest mission youve done in GTA? Easiest mission youve done in GTA?
Whats your favourite game beginning with the letter A? Whats your favourite game?
Whats your favourite game beginning with the letter B?
Whats your favourite game beginning with the letter C?
Whats your favourite game beginning with the letter D?
Whats your favourite game beginning with the letter E?
Whats your favourite game beginning with the letter F?
Whats your favourite game beginning with the letter G?
Whats your favourite game beginning with the letter H?
Whats your favourite game beginning with the letter I?
Whats your favourite game beginning with the letter J?
Whats your favourite game beginning with the letter K?
Whats your favourite game beginning with the letter L?
Whats your favourite game beginning with the letter M?
Whats your favourite game beginning with the letter N?
Whats your favourite game beginning with the letter O?
Whats your favourite game beginning with the letter P?
Whats your favourite game beginning with the letter S?
Whats your favourite game beginning with the letter Q?
Whats your favourite game beginning with the letter V?
Whats your favourite game beginning with the letter X?
Whats your favourite game beginning with the letter Y?
Whats your favourite game beginning with the letter Z?
Do you usually win or lose when playing against friends? Do you usually win or lose when playing against friends?
What are your parents inputs on you gaming? What are your parents inputs on you gaming?
What type of games do you like to play with your partner? What type of games do you like to play with your partner?
@ -1631,8 +1589,7 @@ What impact do you think phones have had on the world?
Life without smartphone be like? Life without smartphone be like?
Have you ever did a prank call on anyone? If so, who and how did you prank them? Have you ever did a prank call on anyone? If so, who and how did you prank them?
What was their reaction? What was their reaction?
Have you ever been prank called? Have you ever been prank called? What was your reaction?
What was your reaction?
Favourite smartphone logo? Favourite smartphone logo?
Your favourite iphone? Your favourite iphone?
Your favourite samsung phone? Your favourite samsung phone?
@ -1650,28 +1607,7 @@ Worst app youve installed?
Do you prefer free or paid apps? Do you prefer free or paid apps?
Have you bought any paid apps? If so which? Have you bought any paid apps? If so which?
Most expensive paid app you bought and were you satisfied with it? Most expensive paid app you bought and were you satisfied with it?
Whats your favourite mobile app beginning with the letter A? Whats your favourite mobile app?
Whats your favourite mobile app beginning with the letter B?
Whats your favourite mobile app beginning with the letter C?
Whats your favourite mobile app beginning with the letter D?
Whats your favourite mobile appbeginning with the letter E?
Whats your favourite mobile app beginning with the letter F?
Whats your favourite mobile app beginning with the letter G?
Whats your favourite mobile app beginning with the letter H?
Whats your favourite mobile app beginning with the letter I?
Whats your favourite mobile app beginning with the letter J?
Whats your favourite mobile app beginning with the letter K?
Whats your favourite mobile app beginning with the letter L?
Whats your favourite mobile app beginning with the letter M?
Whats your favourite mobile app beginning with the letter N?
Whats your favourite mobile app beginning with the letter O?
Whats your favourite mobile app beginning with the letter P?
Whats your favourite mobile app beginning with the letter S?
Whats your favourite mobile app beginning with the letter Q?
Whats your favourite mobile app beginning with the letter V?
Whats your favourite mobile app beginning with the letter X?
Whats your favourite mobile app beginning with the letter Y?
Whats your favourite mobile app beginning with the letter Z?
How do you usually take your photos? (With camera, phone? etc) How do you usually take your photos? (With camera, phone? etc)
What software do you use to backup your photos? What software do you use to backup your photos?
Total number of photos youve in your gallery? Total number of photos youve in your gallery?