Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { Client, Collection, Intents } = require("discord.js");
- const fs = require("fs");
- const Discord = require('discord.js')
- const client = new Client({
- intents: [
- Intents.FLAGS.GUILDS,
- Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS,
- Intents.FLAGS.GUILD_INTEGRATIONS,
- Intents.FLAGS.GUILD_MESSAGES,
- Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
- ],
- });
- // run a command to see
- // removed some intents since they were useless and it was crashing the bot even though i enabled them in discord developers
- let discord = require("discord.js");
- let path = require("path");
- let mongoose = require("mongoose");
- let commands = new Collection();
- let slashcommands = new Collection();
- const { Database } = require("quickmongo");
- const dbquick = new Database("mongodb+srv://#@cluster0.#.mongodb.#/Data?#=#&w=majority");
- let timeouts = dbquick;
- let ms = require("ms");
- let config = {
- prefix: ["<@933927497697984573>", "<@!933927497697984573>"],
- };
- let schema = mongoose.model(
- `economy`,
- new mongoose.Schema({
- User: String,
- Bobux: Number,
- Bix: Number,
- CreatedAt: Number,
- TotalEarned: Number,
- TotalSpent: Number,
- BasicBoxes: Number,
- HighTierBoxes: Number,
- GodBoxes: Number,
- VoteBoxes: Number,
- })
- );
- const prefixschema = require("./commands/prefixes");
- let prefix = async function (message) {
- let custom;
- if (!message.guild) {
- return (custom = "<@!933927497697984573>");
- }
- const data = await prefixschema
- .findOne({ GuildId: message.guild.id })
- .catch((err) => console.log(err));
- if (data) {
- custom = data.Prefix;
- } else {
- custom = "<@!933927497697984573>";
- }
- return custom;
- };
- const economy = {
- async getUsers() {
- let thing = await schema.find()
- return thing
- },
- async getBal(User) {
- return await schema
- .findOne({
- User,
- })
- .then((d) => (d ? d.Bobux : 0));
- },
- async getBix(User) {
- return await schema
- .findOne({
- User,
- })
- .then((d) => (d ? d.Bix : 0));
- },
- async addBal(User, Bobux) {
- return await schema.findOne({ User }, async (err, data) => {
- if (err) throw err;
- if (data) {
- data.Bobux += Number(Bobux);
- } else {
- data = new schema({ User, Bobux });
- }
- data.save();
- });
- },
- async AddBix(User, Bix) {
- return await schema.findOne({ User }, async (err, data) => {
- if (err) throw err;
- if (data) {
- data.Bix += Number(Bix);
- } else {
- data = new schema({ User, Bix });
- }
- data.save();
- });
- },
- async subBal(User, Bobux) {
- return await schema.findOne({ User }, async (err, data) => {
- if (err) throw err;
- if (data) {
- data.Bobux -= Number(Bobux);
- } else {
- data = new schema({ User, Bobux });
- }
- data.save();
- });
- },
- async killUser(User) {
- return await schema.findOne({ User }, async (err, data) => {
- let amount = 0
- if (err) throw err;
- if (data) {
- var randombal = Math.floor(Math.random() * 19) + 1;
- var num = 1-(randombal / 100)
- var amountlost = (randombal / 100)
- var amountlost2 = amountlost * (data.Bobux).toFixed(0)
- var newbal = (data.Bobux) * num
- data.Bobux = newbal.toFixed(0)
- amount = amountlost2
- } else {
- data = new schema({ User, Bobux });
- }
- data.save();
- return amount
- });
- },
- };
- function commandHandler(epath) {
- fs.readdirSync(path.normalize(epath)).map((f) => {
- const File = require(path.join(__dirname, `.`, epath, f));
- commands.set(File.name, File);
- });
- }
- function slashcommandHandler(slashpath) {
- fs.readdirSync(path.normalize(slashpath)).map((f) => {
- const File = require(path.join(__dirname, `.`, slashpath, f));
- slashcommands.set(File.data.name, File);
- });
- }
- function getCommand(cmd) {
- return commands.has(cmd) ? commands.get(cmd) : false;
- }
- commandHandler("./commands");
- slashcommandHandler("./slashcommands");
- client.on("ready", async () => {
- console.log("bot on");
- client.user.setActivity(`$help || $donatehelp `);
- await mongoose.connect(
- `mongodb+srv://##&w=majority
- `,
- {
- useNewUrlParser: true,
- useUnifiedTopology: true,
- }
- );
- });
- client.on("guildMemberAdd", async (member) => {
- if (Date.now() - member.user.createdAt < 600 * 60 * 60 * 24 * 10) {
- if (member.guild.id !== "803403643868414024") {
- return;
- }
- let role = member.guild.roles.cache.get("896438105379328011");
- await member.roles.add(role).then(console.log(`Done`));
- client.channels.cache
- .get("896564381205270559")
- .send(
- `New sus member maybe! Be alert. Sus User id: ${member.id}, tag: ${member.user.tag}. He has been muted for now. `
- );
- } else {
- return;
- }
- });
- client.on("messageCreate", async (message) => {
- if(message.author.bot) {
- return
- }
- if(message.author.id == '622442733294059526' || message.author.id === '482345661736681472' || message.author.id == '649755456927170601' || message.author.id == '758887378520768544' || message.author.id == '836361597701193748' ) {
- const p = await prefix(message);
- if (
- message.author.bot ||
- !message.guild ||
- !message.content.toLocaleLowerCase().startsWith(p)
- )
- return;
- const args = message.content.slice(p.length).trim().split(" ");
- const cmd = args.shift().toLocaleLowerCase();
- message.guild.commands.fetch()
- .catch({
- //noperms
- })
- const command =
- getCommand(cmd) ||
- commands.find((a) => a.aliases && a.aliases.includes(cmd));
- if (!command) return;
- if (command.timeout) {
- if (timeouts.has(`${command.name}${message.author.id}`)) {
- let embed = new Discord.MessageEmbed().setDescription(
- `You can't use this commmand for another ${ms(
- timeouts.get(`${command.name}${message.author.id}`) - Date.now(),
- { long: true }
- )}`
- );
- message.channel.send({ embeds: [embed] });
- return;
- }
- command.run(client, message, args).catch(console.error);
- timeouts.push(
- `${command.name}${message.author.id}`,
- Date.now() + command.timeout
- );
- setTimeout(() => {
- timeouts.delete(`${command.name}${message.author.id}`);
- }, command.timeout);
- } else return command.run(client, message, args).catch(console.error);
- } else {
- return message.reply(`You do not have permission to use this bot`);
- }
- });
- client.on("guildMemberUpdate", function (oldMember, newMember) {
- const wc = new Discord.WebhookClient(
- "#', '#-#-bWkb_9"
- );
- if (oldMember.roles.cache.size !== newMember.roles.cache.size) {
- //donator role
- if (
- !oldMember.roles.cache.has("851156630748921927") &&
- newMember.roles.cache.has("851156630748921927")
- ) {
- client.channels.cache
- .get("863119973384061008")
- .send(`<@${newMember.id}> has just donated!`);
- }
- if (
- oldMember.roles.cache.has("851156630748921927") &&
- !newMember.roles.cache.has("851156630748921927")
- ) {
- client.channels.cache
- .get("863119973384061008")
- .send(
- `<@${newMember.id}> has just cancelled their subscription (test)!`
- );
- }
- }
- });
- client.on("guildCreate", async (guild, message) => {
- const Embed = new Discord.MessageEmbed()
- .setTitle("Boblox Help!")
- .addFields(
- { name: "💰 How to earn Bobux", value: "`$earnhelp`" },
- {
- name: "💸How to create and earn bobux off a game",
- value: "`$gamehelp`",
- },
- {
- name: "💹 Complete Guide on how to use boblox and become the richest",
- value: "`$guide`",
- },
- {
- name: "🧧 Donate to support us and recieve many Benefits",
- value: "`$donatehelp`",
- },
- {
- name: "💹 How to trade in the Boblox Stonk Market",
- value: "`$stonkhelp`",
- },
- { name: "💱 View all the leaderboards", value: "`$lbhelp`" },
- {
- name:
- "🏛 Join or Create A Group And Become The Biggest Group With Your Fellow Members ",
- value: "`$grouphelp`",
- }
- );
- const owner = await guild.members.fetch(guild.ownerId);
- owner
- .send("Support/community server: https://discord.gg/BcNx4SUq54")
- .catch(async (err) => {
- console.log(err);
- });
- owner.send(Embed).catch(async (err) => {
- console.log(err);
- });
- owner
- .send(
- "Voting for boblox will give you a huge headstart on the bot \n https://top.gg/bot/809483262710775817/vote"
- )
- .catch(async (err) => {
- console.log(err);
- });
- });
- client.on("interactionCreate", async (interaction) => {
- if (!interaction.isCommand()) return;
- if(interaction.user.id == '622442733294059526' || interaction.user.id === '482345661736681472' || interaction.user.id == '649755456927170601' || interaction.user.id == '758887378520768544' || interaction.user.id == '836361597701193748') {
- const command = slashcommands.get(interaction.commandName);
- if (!command) console.log(slashcommands);
- if (command.timeout) {
- if (timeouts.has(`${command.name}${interaction.user.id}`)) {
- let embed = new Discord.MessageEmbed().setDescription(
- `You can't use this commmand for another ${ms(
- timeouts.get(`${command.name}${interaction.user.id}`) - Date.now(),
- { long: true }
- )}`
- );
- await interaction.reply({ embeds: [embed] });
- return;
- }
- }
- try {
- await command.execute(interaction, interaction.client);
- timeouts.push(
- `${command.name}${interaction.user.id}`,
- Date.now() + command.timeout
- );
- }
- catch (error) {
- console.log(`${error}`);
- await interaction.reply({
- content: "There was an error executing this command.",
- ephemeral: true,
- });
- }
- } else {
- await interaction.reply({ content: 'You do not have permission to use this bot', ephemeral: true });
- }
- });
- client.login('###')
- module.exports = { economy }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement