Compare commits

...

4 Commits

Author SHA1 Message Date
Santiago Forero 0916912adf make shorter botlist command 2021-09-16 15:37:57 -05:00
Santiago Forero e1d2d00791 make shorter help menu 2021-09-16 15:36:39 -05:00
Santiago Forero 4a55c2ebe3 make working leaderboard command 2021-09-16 15:33:03 -05:00
Santiago Forero dd95984723 make grow command response in only one line 2021-09-16 12:37:40 -05:00
4 changed files with 36 additions and 39 deletions

View File

@ -4,23 +4,16 @@ module.exports = {
name: 'grow',
description: 'Grow your cactus.',
execute(event, args, bot) {
let grow_rate = Math.random() * (db.get(event.nick + '_score') / 10)
grow_rate = parseFloat(grow_rate.toFixed(3))
if(grow_rate == 0) {
grow_rate = 0.1
}
if(db.get(event.nick + '_score') == null) {
db.set(event.nick + '_score', 1.000)
}
db.set(event.nick + '_score', parseFloat(db.get(event.nick + '_score') + parseFloat(grow_rate.toFixed(3))))
bot.say(event.target, "You grew " + grow_rate + " cm")
bot.say(event.target, "You are now " + db.get(event.nick + '_score').toFixed(3) + " cm")
bot.say(event.target, event.nick + ": You grew " + grow_rate + " cm, you are now " + db.get(event.nick + '_score').toFixed(3) + " cm.")
},
};

View File

@ -2,12 +2,12 @@ module.exports = {
name: 'help',
description: 'Get info and help about this bot.',
execute(event, args, bot) {
bot.say(event.target, 'Hi, I\'m Cactus, you can live the life of a cactus and grow to become the tallest! My maintainer is forero, my prefix is \'=\' and my commands are: ')
text = ""
bot.commands.forEach((value, key, map) => {
bot.say(event.target, value.name + ": " + value.description)
text += value.name + ": " + value.description + ' | '
})
bot.say(event.target, 'Source: https://tildegit.org/forero/cactus-irc/')
bot.say(event.target, 'Hi, I\'m Cactus, you can grow a cactus to become the tallest! My maintainer is forero, my prefix is \'=\' and my commands are:')
bot.say(event.target, text + 'Source: https://tildegit.org/forero/cactus-irc/')
},
};

25
commands/leaderboard.js Normal file
View File

@ -0,0 +1,25 @@
const db = require('quick.db')
module.exports = {
name: 'leaderboard',
description: 'List of tallests cactuses.',
execute(event, args, bot) {
data = db.all()
data.map(score => {
score.ID = score.ID.replace('_score','')
score.data = parseFloat(parseFloat(score.data).toFixed(3))
})
data.sort(function (a, b) {
return b.data - a.data
});
console.log(data)
let text = ""
for(let i = 0; i < 5; i++) {
text += `${i + 1}. ${data[i].ID} (${data[i].data} cm) `
}
bot.say(event.target, 'Cactus Leaderboard: ' + text)
},
};

View File

@ -10,7 +10,7 @@ bot.connect({
tls: true
});
const prefix = "-"
const prefix = "="
bot.commands = new Map();
@ -26,7 +26,7 @@ bot.on('message', event => {
const args = event.message.slice(prefix.length).trim().split(/ +/);
if(event.message == '!botlist') {
bot.commands.get('help').execute(event, args, bot);
bot.say(event.target, `Hello, I'm Cactus, my maintainer is forero and my prefix is '${prefix}'. For more information type: ${prefix}help, join #cactus for help`);
}
if (!event.message.startsWith(prefix)) return;
@ -44,30 +44,9 @@ bot.on('message', event => {
}
})
bot.on('registered', event => {
console.log(event)
bot.join('#bots')
bot.join('#cactus')
bot.say('NickServ', 'identify 1021513305')
})
bot.join('#cactus-spam')
})