Compare commits
4 Commits
f97cb67f4a
...
0916912adf
Author | SHA1 | Date |
---|---|---|
Santiago Forero | 0916912adf | |
Santiago Forero | e1d2d00791 | |
Santiago Forero | 4a55c2ebe3 | |
Santiago Forero | dd95984723 |
|
@ -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.")
|
||||
},
|
||||
};
|
|
@ -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/')
|
||||
},
|
||||
};
|
|
@ -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)
|
||||
},
|
||||
};
|
29
index.js
29
index.js
|
@ -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')
|
||||
})
|
Loading…
Reference in New Issue