Skip to content
Snippets Groups Projects
Commit 362484e2 authored by Levatax's avatar Levatax
Browse files

First release

parents
No related branches found
No related tags found
No related merge requests found
Pipeline #262 failed
A small bot to have fun with your friends.
\ No newline at end of file
bot.js 0 → 100644
const discord = require('discord.js');
const bot = new discord.Client();
const ready = require('./events/ready');
const message = require('./events/message');
const fs = require('fs');
const settings = require('./settings.json');
bot.commands = new discord.Collection();
bot.aliases = new discord.Collection();
ready.ready(bot);
message.message(bot, settings, discord);
fs.readdir("./commands/", (err, files) => {
if (err) console.error(err);
let jsfiles = files.filter(f => f.split(".").pop() === "js");
if (jsfiles.length <= 0) return console.log("There are no commands to load...");
console.log(`Loading ${jsfiles.length} commands...`);
jsfiles.forEach((f, i) => {
let props = require(`./commands/${f}`);
console.log(`${i + 1}: ${f} loaded!`);
bot.commands.set(props.help.name, props);
props.help.aliases.forEach(alias => {
bot.aliases.set(alias, props.help.name);
});
});
});
bot.loadCommand = (commandName) => {
try {
let props = require(`../commands/${commandName}`);
if (props.init) props.init(bot);
bot.commands.set(commandName, props);
props.help.aliases.forEach(alias => {
bot.aliases.set(alias, props.help.name);
});
return false;
} catch (err) {
return [console.error(err)];
}
};
bot.unloadCommand = async (commandName) => {
try {
if (!commandName) return `\`${commandName}\` I can't find this command!`;
if (commandName.shutdown) await commandName.shutdown(bot);
delete require.cache[require.resolve(`../commands/${commandName}.js`)];
return false;
} catch (err) {
return [console.error(err)];
}
};
\ No newline at end of file
const Settings = require('../settings');
const Discord = require('discord.js');
const ms = require('parse-ms');
const db = require('quick.db');
exports.run = async(bot, message, args) => {
function numberWithCommas(x) {
var parts = x.toString().split(".");
parts[0]=parts[0].replace(/\B(?=(\d{3})+(?!\d))/g,".");
return parts.join(",");
}
let balance = await db.get(`Balance_${message.author.id}`);
let balances = numberWithCommas(balance);
message.channel.send(`You balance is ${balances}$`);
};
module.exports.help = {
name: 'balance',
aliases: ['bakiye','bal']
};
\ No newline at end of file
const Discord = require('discord.js');
const db = require('quick.db');
exports.run = async(bot, message, args) => {
let number = args[0];
let bal = await db.get(`Balance_${message.author.id}`);
if (number > bal || bal == 0) return message.channel.send(`Your balance is under the value you entered.`)
let cfNumber;
if (!number) return message.channel.send('Please specify an amout to use.');
if (number > 50000 || number == "all") {
if (50000 > bal){
cfNumber = bal;
}else{
cfNumber=50000;
}
}
else{
cfNumber = number;
};
msg = await message.channel.send('<a:coinflip:792364681560981504> | Flipping...');
setTimeout( async function() {
if(Math.random() < 0.5 == true){
cfNumber = cfNumber;
await db.add(`Balance_${message.author.id}`, cfNumber);
cfNumber = numberWithCommas(cfNumber*2);
msg.edit(`<:coin:792364680931967006> | You won ${cfNumber} <:cash:792364680324448306>`);
}else{
await db.subtract(`Balance_${message.author.id}`, cfNumber);
cfNumber = numberWithCommas(cfNumber);
msg.edit(`<:coin:792364680931967006> | You lost ${cfNumber} <:cash:792364680324448306>`);
}
}, 2000);
function numberWithCommas(x) {
var parts = x.toString().split(".");
parts[0]=parts[0].replace(/\B(?=(\d{3})+(?!\d))/g,".");
return parts.join(",");
}
};
module.exports.help = {
name: 'cf',
aliases: ['yt','yazıtura','coinflip']
};
const Settings = require('../settings');
const Discord = require('discord.js');
const ms = require('parse-ms');
const db = require('quick.db');
exports.run = async(bot, message, args) => {
let cooldown = 8.64e+7,
amout = 500;
let daily = await db.fetch(`lastDaily_${message.author.id}`);
if (daily !== null && cooldown - (Date.now() - daily)> 0 ){
let time = ms(cooldown - (Date.now() - daily),{ long: true });
message.channel.send(`You already claimed today's daily. Please wait \`${time.hours}h ${time.minutes}m ${time.seconds}s\` to claim again.`);
} else{
message.channel.send(`Successfully claimed ${amout}$.`);
db.set(`lastDaily_${message.author.id}`, Date.now());
db.add(`Balance_${message.author.id}`, 500);
}
};
module.exports.help = {
name: 'daily',
aliases: ['günlük']
};
\ No newline at end of file
const Discord = require('discord.js');
exports.run = async(bot, message, args) => {
message.channel.send(+ bot.ws.ping + `ms `);
};
module.exports.help = {
name: 'ping',
aliases: ['latency']
};
\ No newline at end of file
module.exports = {
message: (bot, settings, discord) => {
bot.on('message', async message => {
let prefix = settings.prefix;
if (message.channel.type === "dm") return;
let args = message.content.slice(prefix.length).trim().split(' ');
let cmd = args.shift().toLowerCase();
let command;
if (!message.content.startsWith(prefix)) return;
if (bot.commands.has(cmd)) {
command = bot.commands.get(cmd);
} else if (bot.aliases.has(cmd)) {
command = bot.commands.get(bot.aliases.get(cmd));
}
try {
command.run(bot, message, args);
} catch (err) {
if (err) return undefined;
}
}
)}
};
\ No newline at end of file
const settings = require('../settings.json');
module.exports = {
ready : (bot) => {
bot.login(settings.token)
bot.on('ready', async () => {
bot.user.setActivity({
name: "Levatax's advices",
type: "LISTENING",
});
console.log(`${bot.user.tag} is ready!`);
});
}
};
\ No newline at end of file
{
"name": "leva-game",
"version": "1.0.0",
"description": "",
"main": "bot.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Levatax",
"license": "MIT",
"dependencies": {
"discord.js": "^12.5.1",
"fs": "0.0.1-security",
"moment": "^2.29.1",
"ms": "^2.1.3",
"parse-ms": "^2.1.0",
"quick.db": "^7.1.3"
}
}
\ No newline at end of file
{
"prefix" :"PREFIX",
"token" : "TOKEN",
"owner": "YOURID"
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment