Skip to content

Commit

Permalink
Last update before rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
SiebeBaree committed Nov 3, 2022
1 parent 591816d commit da02714
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 92 deletions.
23 changes: 19 additions & 4 deletions src/commands/economy/lucky-wheel.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class LuckyWheel extends Command {
description: "Spin the lucky wheel and get awesome rewards",
options: [
{
name: 'rewards',
name: 'info',
type: ApplicationCommandOptionType.Subcommand,
description: 'Get a list with the possible loot of a spin.',
description: 'Get more info about the possible loot or spin prices.',
options: []
},
{
Expand All @@ -22,10 +22,25 @@ class LuckyWheel extends Command {
{
name: 'amount',
type: ApplicationCommandOptionType.Integer,
description: 'How many spins you want to do in 1 command.',
description: 'How many spins you want to do in 1 command. | default: 1.',
required: false,
min_value: 1,
max_value: 15
max_value: 25
}
]
},
{
name: 'buy',
type: ApplicationCommandOptionType.Subcommand,
description: 'Buy more spins for the lucky wheel.',
options: [
{
name: 'amount',
type: ApplicationCommandOptionType.Integer,
description: 'How many spins you want to buy. | default: 1.',
required: false,
min_value: 1,
max_value: 25
}
]
}
Expand Down
37 changes: 13 additions & 24 deletions src/commands/misc/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,20 @@ class Info extends Command {
}

async run(interaction, data) {
const usedMemory = process.memoryUsage().heapUsed / 1024 / 1024;
const stats = require("../../assets/stats.json");

const promises = [
bot.shard.fetchClientValues('guilds.cache.size'),
bot.shard.broadcastEval(c => c.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0)),
];

Promise.all(promises)
.then(results => {
const totalGuilds = results[0].reduce((acc, guildCount) => acc + guildCount, 0);
const totalMembers = results[1].reduce((acc, memberCount) => acc + memberCount, 0);

const newEmbed = new EmbedBuilder()
.setAuthor({ name: `Bot Statistics`, iconURL: `${bot.user.avatarURL() || bot.config.embed.defaultIcon}` })
.setColor(bot.config.embed.color)
.setFooter({ text: bot.config.embed.footer })
.setTimestamp()
.setDescription('**If you like this bot, maybe consider [donating](https://coinzbot.xyz/donate).**')
.addFields(
{ name: 'Info', value: `:man_technologist: **Owner:** \`Siebe#0001\`\n:globe_with_meridians: **Website: [coinzbot.xyz](${bot.config.website})**\n:beginner: **Official Server: [discord.gg/asnZQwc6kW](https://discord.gg/asnZQwc6kW)**\n:books: **Library:** \`discord.js${dependencies["discord.js"]}\`\n:star: **Version:** \`${version}\``, inline: true },
{ name: 'Statistics', value: `:video_game: **Commands:** \`${bot.commands.size}\`\n:spider_web: **Shard:** \`${interaction.guild.shardId + 1}/${bot.shard.count}\`\n:white_check_mark: **Uptime:** \`${bot.tools.msToTime(bot.uptime)}\`\n:bust_in_silhouette: **Users:** \`${totalMembers}\`\n:printer: **Servers:** \`${totalGuilds}\``, inline: true },
{ name: 'Disclamer', value: `Icons from the shop are from [icons8](https://icons8.com).`, inline: false }
)
return interaction.editReply({ embeds: [newEmbed] });
}).catch();
const newEmbed = new EmbedBuilder()
.setAuthor({ name: `Bot Statistics`, iconURL: `${bot.user.avatarURL() || bot.config.embed.defaultIcon}` })
.setColor(bot.config.embed.color)
.setFooter({ text: bot.config.embed.footer })
.setTimestamp()
.setDescription('**If you like this bot, maybe consider [donating](https://coinzbot.xyz/donate).**')
.addFields(
{ name: 'Info', value: `:man_technologist: **Owner:** \`Siebe#0001\`\n:globe_with_meridians: **Website: [coinzbot.xyz](${bot.config.website})**\n:beginner: **Official Server: [discord.gg/asnZQwc6kW](https://discord.gg/asnZQwc6kW)**\n:books: **Library:** \`discord.js${dependencies["discord.js"]}\`\n:star: **Version:** \`${version}\``, inline: true },
{ name: 'Statistics', value: `:video_game: **Commands:** \`${bot.commands.size}\`\n:spider_web: **Shard:** \`${interaction.guild.shardId + 1}/${bot.shard.count}\`\n:white_check_mark: **Uptime:** \`${bot.tools.msToTime(bot.uptime)}\`\n:bust_in_silhouette: **Users:** \`${stats.members}\`\n:printer: **Servers:** \`${stats.guilds}\``, inline: true },
{ name: 'Disclamer', value: `Icons from the shop are from [icons8](https://icons8.com).`, inline: false }
)
return await interaction.editReply({ embeds: [newEmbed] });
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/events/interactionCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ module.exports = class extends Event {
//If it isn't a command then return
if (!cmd) return;

const ban = await this.database.fetchBan(interaction.guild.id, interaction.member.id);
if (ban.guild.isBanned) {
return await interaction.reply({ content: `This server is banned from using Coinz.\n**Reason:** ${ban.guild.reason}\n\nIf you are the owner of the server, please join our [**support server**](https://discord.gg/asnZQwc6kW) if you think this ban was a mistake.`, ephemeral: true });
} else if (ban.user.isBanned) {
return await interaction.reply({ content: `You are banned from using Coinz.\n**Reason:** ${ban.user.reason}\n\nPlease join our [**support server**](https://discord.gg/asnZQwc6kW) if you think this ban was a mistake.`, ephemeral: true });
}
// const ban = await this.database.fetchBan(interaction.member.id);
// if (ban.guild.isBanned) {
// return await interaction.reply({ content: `This server is banned from using Coinz.\n**Reason:** ${ban.guild.reason}\n\nIf you are the owner of the server, please join our [**support server**](https://discord.gg/asnZQwc6kW) if you think this ban was a mistake.`, ephemeral: true });
// } else if (ban.user.isBanned) {
// return await interaction.reply({ content: `You are banned from using Coinz.\n**Reason:** ${ban.user.reason}\n\nPlease join our [**support server**](https://discord.gg/asnZQwc6kW) if you think this ban was a mistake.`, ephemeral: true });
// }

if (await cmd.cool(cmd.info.name, interaction.member, cmd.info.cooldown)) {
return await interaction.reply({ content: `:x: You have to wait ${this.tools.msToTime(await this.cooldown.getCooldown(interaction.member.id, cmd.info.name) * 1000)} to use this command again.`, ephemeral: true });
Expand Down
3 changes: 2 additions & 1 deletion src/events/ready.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ module.exports = class extends Event {
}
});

await this.application?.commands.set(data); // Used to set slash commands globally [Can take several hours to update.]
// await this.application?.commands.set(data); // Used to set slash commands globally [Can take several hours to update.]
await this.guilds.cache.get(this.config.rootServerId)?.commands.set(data);
this.logger.ready(`Shard ${this.shard.ids[0]} loaded.`);
}
};
30 changes: 1 addition & 29 deletions src/lib/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ const MemberModel = require("../models/Member");
const CooldownModel = require("../models/Cooldown");
const CompanyModel = require("../models/Company");
const StatsModel = require("../models/Stats");
const GuildBanModel = require("../models/BannedGuild");
const UserBanModel = require("../models/BannedUser");

const fetchGuild = async function (guildId) {
let obj = await GuildModel.findOne({ id: guildId });
Expand Down Expand Up @@ -76,38 +74,12 @@ const fetchStats = async function (id) {
}
}

const fetchBan = async function (guildId, userId) {
let guildObj = await GuildBanModel.findOne({ id: guildId });
if (guildObj) {
return {
guild: {
isBanned: true,
reason: guildObj.reason || "No reason was given."
}
};
}

let userObj = await UserBanModel.findOne({ id: userId });
if (userObj) {
return {
guild: { isBanned: false },
user: {
isBanned: true,
reason: userObj.reason || "No reason was given."
}
};
}

return { guild: { isBanned: false }, user: { isBanned: false } };
}

module.exports = {
fetchGuild,
fetchMember,
fetchItem,
fetchStock,
fetchCooldown,
fetchCompany,
fetchStats,
fetchBan
fetchStats
};
10 changes: 0 additions & 10 deletions src/models/BannedGuild.js

This file was deleted.

7 changes: 6 additions & 1 deletion src/models/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ const { Schema, model } = require('mongoose');

const Guild = Schema({
id: { type: String, required: true, unique: true, index: true },
premium: { type: Boolean, default: false },
joinedAt: { type: Date, default: Date.now },
banned: { type: Boolean, default: false },
banReason: String,
airdropStatus: { type: Boolean, default: false },
airdropChannel: { type: String, default: "" },
airdropNext: { type: Number, default: 0 }
airdropNext: { type: Number, default: 0 },
airdropTries: { type: Number, default: 0 }
});

module.exports = model('Guild', Guild, 'guilds');
9 changes: 0 additions & 9 deletions src/models/PremiumGuild.js

This file was deleted.

8 changes: 0 additions & 8 deletions src/models/PremiumUser.js

This file was deleted.

0 comments on commit da02714

Please sign in to comment.