debug button/menu interactions

This commit is contained in:
SowinskiBraeden committed 2022-08-29 21:26:22 -07:00
1 parent eebda1c209
commit 70d3858baf
12 files changed
+806 -796

No files matched your search

+4 -55
View File
@@ -82,73 +82,22 @@ module.exports = {
} }
const ID = Math.floor(100000 + Math.random() * 900000); const ID = Math.floor(100000 + Math.random() * 900000);
let status = 'Open'; let Description = `**Call ID** ${ID}\n\n**Caller** ${args[0].value}\n**Service** ${args[1].value}\n**Location** ${args[2].value}\n**Nature** ${args[0].value}`
let Description = `**Call ID** ${ID}\n\n**Caller** ${args[0].value}\n**Service** ${args[1].value}\n**Location** ${args[2].value}\n**Nature** ${args[0].value}\n\n**Status**\n\`\`\`diff\n${status=='Open'?'+':'-'} ${status}\`\`\``
let embed311 = new EmbedBuilder() const embed311 = new EmbedBuilder()
.setColor(client.config.Colors.Default) .setColor(client.config.Colors.Default)
.setTitle('311 Call Alert') .setTitle('311 Call Alert')
.setTimestamp() .setTimestamp()
.setDescription(Description) .setDescription(Description)
let opt = new ActionRowBuilder() const opt = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`close-${GuildDB.dispatcherRole}`) .setCustomId(`311-delete`)
.setLabel("Close")
.setStyle(ButtonStyle.Primary),
)
.addComponents(
new ButtonBuilder()
.setCustomId(`delete-${GuildDB.dispatcherRole}`)
.setLabel("Delete") .setLabel("Delete")
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
) )
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!ButtonInteraction.member._roles.includes(GuildDB.dispatcherRole)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
if (queryString.startsWith('close')) {
status = 'Closed';
Description = `**Call ID** ${ID}\n\n**Caller** ${args[0].value}\n**Service** ${args[1].value}\n**Location** ${args[2].value}\n**Nature** ${args[0].value}\n\n**Status**\n\`\`\`diff\n${status=='Open'?'+':'-'} ${status}\`\`\``
} else if (queryString.startsWith('open')) {
status = 'Open';
Description = `**Call ID** ${ID}\n\n**Caller** ${args[0].value}\n**Service** ${args[1].value}\n**Location** ${args[2].value}\n**Nature** ${args[0].value}\n\n**Status**\n\`\`\`diff\n${status=='Open'?'+':'-'} ${status}\`\`\``
} else if (queryString.startsWith('delete')) {
const closedEmbed = new EmbedBuilder().setTitle('Deleted Call').setColor(client.config.Colors.Default);
return ButtonInteraction.update({ embeds: [closedEmbed], components: [] });
}
embed311 = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setTitle('311 Call Alert')
.setTimestamp()
.setDescription(Description)
opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`${queryString.startsWith('close')?'Open':'Close'}-${GuildDB.dispatcherRole}`)
.setLabel(queryString.startsWith('close')?'Open':'Close')
.setStyle(ButtonStyle.Primary),
)
.addComponents(
new ButtonBuilder()
.setCustomId(`delete-${GuildDB.dispatcherRole}`)
.setLabel("Delete")
.setStyle(ButtonStyle.Danger),
)
return ButtonInteraction.update({ embeds: [embed311], components: [opt] });
})
const channel = interaction.guild.channels.cache.find(channel => channel.id === GuildDB.dispatchChannel); const channel = interaction.guild.channels.cache.find(channel => channel.id === GuildDB.dispatchChannel);
if (!channel) { if (!channel) {
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
+4 -55
View File
@@ -82,73 +82,22 @@ module.exports = {
} }
const ID = Math.floor(100000 + Math.random() * 900000); const ID = Math.floor(100000 + Math.random() * 900000);
let status = 'Open'; let Description = `**Call ID** ${ID}\n\n**Caller** ${args[0].value}\n**Service** ${args[1].value}\n**Location** ${args[2].value}\n**Nature** ${args[0].value}`
let Description = `**Call ID** ${ID}\n\n**Caller** ${args[0].value}\n**Service** ${args[1].value}\n**Location** ${args[2].value}\n**Nature** ${args[0].value}\n\n**Status**\n\`\`\`diff\n${status=='Open'?'+':'-'} ${status}\`\`\``
let embed911 = new EmbedBuilder() const embed911 = new EmbedBuilder()
.setColor(client.config.Colors.Default) .setColor(client.config.Colors.Default)
.setTitle('911 Call Alert') .setTitle('911 Call Alert')
.setTimestamp() .setTimestamp()
.setDescription(Description) .setDescription(Description)
let opt = new ActionRowBuilder() const opt = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`close-${GuildDB.dispatcherRole}`) .setCustomId(`911-delete`)
.setLabel("Close")
.setStyle(ButtonStyle.Primary),
)
.addComponents(
new ButtonBuilder()
.setCustomId(`delete-${GuildDB.dispatcherRole}`)
.setLabel("Delete") .setLabel("Delete")
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
) )
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!ButtonInteraction.member._roles.includes(GuildDB.dispatcherRole)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
if (queryString.startsWith('close')) {
status = 'Closed';
Description = `**Call ID** ${ID}\n\n**Caller** ${args[0].value}\n**Service** ${args[1].value}\n**Location** ${args[2].value}\n**Nature** ${args[0].value}\n\n**Status**\n\`\`\`diff\n${status=='Open'?'+':'-'} ${status}\`\`\``
} else if (queryString.startsWith('open')) {
status = 'Open';
Description = `**Call ID** ${ID}\n\n**Caller** ${args[0].value}\n**Service** ${args[1].value}\n**Location** ${args[2].value}\n**Nature** ${args[0].value}\n\n**Status**\n\`\`\`diff\n${status=='Open'?'+':'-'} ${status}\`\`\``
} else if (queryString.startsWith('delete')) {
const closedEmbed = new EmbedBuilder().setTitle('Deleted Call').setColor(client.config.Colors.Default);
return ButtonInteraction.update({ embeds: [closedEmbed], components: [] });
}
embed911 = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setTitle('911 Call Alert')
.setTimestamp()
.setDescription(Description)
opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`${queryString.startsWith('close')?'Open':'Close'}-${GuildDB.dispatcherRole}`)
.setLabel(queryString.startsWith('close')?'Open':'Close')
.setStyle(ButtonStyle.Primary),
)
.addComponents(
new ButtonBuilder()
.setCustomId(`delete-${GuildDB.dispatcherRole}`)
.setLabel("Delete")
.setStyle(ButtonStyle.Danger),
)
return ButtonInteraction.update({ embeds: [embed911], components: [opt] });
})
const channel = interaction.guild.channels.cache.find(channel => channel.id === GuildDB.dispatchChannel); const channel = interaction.guild.channels.cache.find(channel => channel.id === GuildDB.dispatchChannel);
if (!channel) { if (!channel) {
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
+98 -37
View File
@@ -113,7 +113,7 @@ module.exports = {
return interaction.send(`You are not allowed to use the bot in this channel.`); return interaction.send(`You are not allowed to use the bot in this channel.`);
} }
let banking = await client.dbo.collection("banks").findOne({"account.userID": interaction.member.user.id}).then(banking => banking); let banking = await client.dbo.collection("banks").findOne({"banking.userID": interaction.member.user.id}).then(banking => banking);
if (!banking) { if (!banking) {
banking = { banking = {
@@ -160,6 +160,26 @@ module.exports = {
let inventory = await client.dbo.collection("inventories").findOne({"inventory.userID": interaction.member.user.id}).then(inventory => inventory); let inventory = await client.dbo.collection("inventories").findOne({"inventory.userID": interaction.member.user.id}).then(inventory => inventory);
if (!inventory) { if (!inventory) {
inventory = {
userID: interaction.member.user.id,
guilds: {
[GuildDB.serverID]: {
items: [{
name: 'Wallet',
type: 'wallet',
description: '`/inventory wallet` to view wallet',
cash: 0.00,
ID: {
firstname: '',
lastname: '',
dob: '',
addr: '',
}
}]
}
}
}
// Register inventory for user // Register inventory for user
let newInventory = new Inventory(); let newInventory = new Inventory();
newInventory.createInventory(interaction.member.user.id, GuildDB.serverID); newInventory.createInventory(interaction.member.user.id, GuildDB.serverID);
@@ -174,7 +194,7 @@ module.exports = {
return interaction.send({ embeds: [embed] }); return interaction.send({ embeds: [embed] });
} }
}); });
} } else inventory = inventory.inventory;
if (!client.exists(inventory.guilds[GuildDB.serverID])) { if (!client.exists(inventory.guilds[GuildDB.serverID])) {
const success = addInventory(inventory.guilds, GuildDB.serverID, interaction.member.user.id, client); const success = addInventory(inventory.guilds, GuildDB.serverID, interaction.member.user.id, client);
@@ -197,10 +217,10 @@ module.exports = {
return interaction.send({ embeds: [nsf] }); return interaction.send({ embeds: [nsf] });
} }
newBalance = banking.guilds[GuildDB.serverID].account.balance + args[0].options[0].value; const newBalance = banking.guilds[GuildDB.serverID].account.balance + args[0].options[0].value;
newCash = Math.abs(banking.guilds[GuildDB.serverID].account.cash.toFixed(2) - args[0].options[0].value); const newCash = Math.abs(banking.guilds[GuildDB.serverID].account.cash.toFixed(2) - args[0].options[0].value);
client.dbo.collection("banks").updateOne({"account.userID":interaction.member.user.id},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance,[`banking.guilds.${GuildDB.serverID}.account.cash`]:newCash}}, function(err, res) { client.dbo.collection("banks").updateOne({"banking.userID":interaction.member.user.id},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance,[`banking.guilds.${GuildDB.serverID}.account.cash`]:newCash}}, function(err, res) {
if (err) { if (err) {
client.error(err); client.error(err);
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
@@ -238,10 +258,10 @@ module.exports = {
return interaction.send({ embeds: [nsf] }); return interaction.send({ embeds: [nsf] });
} }
newBalance = banking.guilds[GuildDB.serverID].account.balance - args[0].options[0].value; const newBalance = banking.guilds[GuildDB.serverID].account.balance - args[0].options[0].value;
newCash = banking.guilds[GuildDB.serverID].account.cash + args[0].options[0].value; const newCash = banking.guilds[GuildDB.serverID].account.cash + args[0].options[0].value;
client.dbo.collection("banks").updateOne({"account.userID":interaction.member.user.id},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance,[`banking.guilds.${GuildDB.serverID}.account.cash`]:newCash}}, function(err, res) { client.dbo.collection("banks").updateOne({"banking.userID":interaction.member.user.id},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance,[`banking.guilds.${GuildDB.serverID}.account.cash`]:newCash}}, function(err, res) {
if (err) { if (err) {
client.error(err); client.error(err);
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
@@ -278,11 +298,11 @@ module.exports = {
// Show target users balance // Show target users balance
let targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', ''); let targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', '');
let targetUserBanking = await client.dbo.collection("banks").findOne({"account.userID": targetUserID}).then(banking => banking); let targetUserBanking = await client.dbo.collection("banks").findOne({"banking.userID": targetUserID}).then(banking => banking);
if (!targetUserBanking) { if (!targetUserBanking) {
banking = { targetUserBanking = {
userID: interaction.member.user.id, userID: targetUserID,
guidls: { guidls: {
[guildID]: { [guildID]: {
account: { account: {
@@ -308,7 +328,7 @@ module.exports = {
} }
}); });
} else banking = banking.banking; } else targetUserBanking = targetUserBanking.banking;
if (!client.exists(targetUserBanking.guilds[GuildDB.serverID])) { if (!client.exists(targetUserBanking.guilds[GuildDB.serverID])) {
const success = addBank(targetUserBanking.guilds, GuildDB.serverID, targetUserID, client, GuildDB.startingBalance); const success = addBank(targetUserBanking.guilds, GuildDB.serverID, targetUserID, client, GuildDB.startingBalance);
@@ -327,8 +347,8 @@ module.exports = {
balanceEmbed.setTitle(`${User.tag}'s Bank Records`); balanceEmbed.setTitle(`${User.tag}'s Bank Records`);
balanceEmbed.addFields( balanceEmbed.addFields(
{ name: '**Bank**', value: `$${targetUserBanking.account.balance}`, inline: true }, { name: '**Bank**', value: `$${targetUserBanking.guilds[GuildDB.serverID].account.balance}`, inline: true },
{ name: '**Cash**', value: `$${targetUserBanking.account.cash}`, inline: true }); { name: '**Cash**', value: `$${targetUserBanking.guilds[GuildDB.serverID].account.cash}`, inline: true });
} else { } else {
// Show command authors balance // Show command authors balance
@@ -353,9 +373,9 @@ module.exports = {
return interaction.send({ embeds: [embed] }); return interaction.send({ embeds: [embed] });
} }
newCash = banking.guilds[GuildDB.serverID].account.cash - args[0].options[1].value; const newCash = banking.guilds[GuildDB.serverID].account.cash - args[0].options[1].value;
client.dbo.collection("banks").updateOne({"account.userID":interaction.member.user.id},{$set:{[`banking.guilds.${GuildDB.serverID}.account.cash`]:newCash}}, function(err, res) { client.dbo.collection("banks").updateOne({"banking.userID":interaction.member.user.id},{$set:{[`banking.guilds.${GuildDB.serverID}.account.cash`]:newCash}}, function(err, res) {
if (err) { if (err) {
client.error(err); client.error(err);
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
@@ -378,10 +398,30 @@ module.exports = {
} }
}); });
let targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', ''); const targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', '');
let targetUserInventory = await client.dbo.collection("inventories").findOne({"inventory.userID":targetUserID}).then(inventory => inventory); let targetUserInventory = await client.dbo.collection("inventories").findOne({"inventory.userID":targetUserID}).then(inventory => inventory);
if (!targetUserInventory) { if (!targetUserInventory) {
targetUserBanking = {
userID: targetUserID,
guilds: {
[GuildDB.serverID]: {
items: [{
name: 'Wallet',
type: 'wallet',
description: '`/inventory wallet` to view wallet',
cash: 0.00,
ID: {
firstname: '',
lastname: '',
dob: '',
addr: '',
}
}]
}
}
}
// Register inventory for user // Register inventory for user
let newInventory = new Inventory(); let newInventory = new Inventory();
newInventory.createInventory(targetUserID, GuildDB.serverID); newInventory.createInventory(targetUserID, GuildDB.serverID);
@@ -397,7 +437,7 @@ module.exports = {
return interaction.send({ embeds: [embed] }); return interaction.send({ embeds: [embed] });
} }
}); });
} } else targetUserInventory = targetUserInventory.inventory;
if (!client.exists(targetUserInventory.guilds[GuildDB.serverID])) { if (!client.exists(targetUserInventory.guilds[GuildDB.serverID])) {
const success = addInventory(targetUserInventory.guilds, GuildDB.serverID, targetUserID, client); const success = addInventory(targetUserInventory.guilds, GuildDB.serverID, targetUserID, client);
@@ -411,7 +451,7 @@ module.exports = {
} }
} }
let newTargetCash = targetUserInventory.inventory.guilds[GuildDB.serverID].items[0].cash + args[0].options[1].value; const newTargetCash = targetUserInventory.inventory.guilds[GuildDB.serverID].items[0].cash + args[0].options[1].value;
client.dbo.collection("inventories").updateOne({"inventory.userID":targetUserID, [`inventory.guilds.${GuildDB.serverID}.items.type`]:"wallet"}, client.dbo.collection("inventories").updateOne({"inventory.userID":targetUserID, [`inventory.guilds.${GuildDB.serverID}.items.type`]:"wallet"},
{$set:{[`inventory.guilds.${GuildDB.serverID}.items.$.cash`]:newTargetCash}}, function(err, res) { {$set:{[`inventory.guilds.${GuildDB.serverID}.items.$.cash`]:newTargetCash}}, function(err, res) {
if (err) { if (err) {
@@ -424,19 +464,26 @@ module.exports = {
} }
}); });
let targetUserBanking = await client.dbo.collection("banks").findOne({"banking.userID": targetUserID}).then(banking => banking);
let targetUserBanking = await client.dbo.collection("banks").findOne({"account.userID": targetUserID}).then(banking => banking);
if (!targetUserBanking) { if (!targetUserBanking) {
targetUserBanking = { targetUserBanking = {
account: {
userID: targetUserID, userID: targetUserID,
guidls: {
[GuildDB.serverID]: {
account: {
balance: GuildDB.startingBalance, balance: GuildDB.startingBalance,
cash: args[0].options[1].value, cash: 0.00,
}
}
} }
} }
client.dbo.collection("banks").insertOne(targetUserBanking, function(err, res) { // Register inventory for user
let newBank = new Bank();
newBank.createBank(targetUserID, GuildDB.serverID, GuildDB.startingBalance);
newBank.save()
.catch(err => {
if (err) { if (err) {
client.error(err); client.error(err);
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
@@ -446,10 +493,21 @@ module.exports = {
return interaction.send({ embeds: [embed] }); return interaction.send({ embeds: [embed] });
} }
}); });
} else { } else targetUserBanking = targetUserBanking.banking;
let newTargetCash = targetUserBanking.account.cash + args[0].options[1].value;
client.dbo.collection("banks").updateOne({"account.userID": targetUserID}, {$set: {[`banking.guilds.${GuildDB.serverID}.account.cash`]: newTargetCash}}, function(err, res) { if (!client.exists(targetUserBanking.guilds[GuildDB.serverID])) {
const success = addBank(targetUserBanking.guilds, GuildDB.serverID, targetUserID, client, GuildDB.startingBalance);
if (!success) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.send({ embeds: [embed] });
}
}
client.dbo.collection("banks").updateOne({"banking.userID": targetUserID}, {$set: {[`banking.guilds.${GuildDB.serverID}.account.cash`]: newTargetCash}}, function(err, res) {
if (err) { if (err) {
client.error(err); client.error(err);
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
@@ -459,7 +517,6 @@ module.exports = {
return interaction.send({ embeds: [embed] }); return interaction.send({ embeds: [embed] });
} }
}); });
}
const successEmbed = new EmbedBuilder() const successEmbed = new EmbedBuilder()
.setTitle('Success') .setTitle('Success')
@@ -479,9 +536,9 @@ module.exports = {
return interaction.send({ embeds: [embed] }); return interaction.send({ embeds: [embed] });
} }
newBalance = banking.guilds[GuildDB.serverID].account.balance - args[0].options[1].value; const newBalance = banking.guilds[GuildDB.serverID].account.balance - args[0].options[1].value;
client.dbo.collection("banks").updateOne({"account.userID":interaction.member.user.id},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance}}, function(err, res) { client.dbo.collection("banks").updateOne({"banking.userID":interaction.member.user.id},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance}}, function(err, res) {
if (err) { if (err) {
client.error(err); client.error(err);
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
@@ -492,17 +549,21 @@ module.exports = {
} }
}); });
let targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', ''); const targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', '');
let targetUserBanking = await client.dbo.collection("banks").findOne({"account.userID": targetUserID}).then(banking => banking); let targetUserBanking = await client.dbo.collection("banks").findOne({"banking.userID": targetUserID}).then(banking => banking);
if (!targetUserBanking) { if (!targetUserBanking) {
targetUserBanking = { targetUserBanking = {
account: {
userID: targetUserID, userID: targetUserID,
guilds: {
[GuildDB.serverID]: {
account: {
balance: (GuildDB.startingBalance + args[0].options[1].value), balance: (GuildDB.startingBalance + args[0].options[1].value),
cash: 0.00, cash: 0.00,
} }
} }
}
}
client.dbo.collection("banks").insertOne(targetUserBanking, function(err, res) { client.dbo.collection("banks").insertOne(targetUserBanking, function(err, res) {
if (err) { if (err) {
@@ -514,10 +575,11 @@ module.exports = {
return interaction.send({ embeds: [embed] }); return interaction.send({ embeds: [embed] });
} }
}); });
} else { } else targetUserBanking = targetUserBanking.banking;
let newTargetBalance = targetUserBanking.account.balance + args[0].options[1].value;
client.dbo.collection("banks").updateOne({"account.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newTargetBalance}}, function(err, res) { const newTargetBalance = targetUserBanking.guilds[GuildDB.serverID].account.balance + args[0].options[1].value;
client.dbo.collection("banks").updateOne({"banking.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newTargetBalance}}, function(err, res) {
if (err) { if (err) {
client.error(err); client.error(err);
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
@@ -527,7 +589,6 @@ module.exports = {
return interaction.send({ embeds: [embed] }); return interaction.send({ embeds: [embed] });
} }
}); });
}
const successEmbed = new EmbedBuilder() const successEmbed = new EmbedBuilder()
.setTitle('Bank Notice:') .setTitle('Bank Notice:')
+2 -2
View File
@@ -57,7 +57,7 @@ module.exports = {
} }
const targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', ''); const targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', '');
let banking = await client.dbo.collection("banks").findOne({"account.userID": targetUserID}).then(banking => banking); let banking = await client.dbo.collection("banks").findOne({"banking.userID": targetUserID}).then(banking => banking);
if (!banking) { if (!banking) {
banking = { banking = {
@@ -103,7 +103,7 @@ module.exports = {
const newTargetBalance = banking.guilds[GuildDB.serverID].account.balance - args[0].options[1].value; const newTargetBalance = banking.guilds[GuildDB.serverID].account.balance - args[0].options[1].value;
client.dbo.collection("banks").updateOne({"account.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newTargetBalance}}, function(err, res) { client.dbo.collection("banks").updateOne({"banking.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newTargetBalance}}, function(err, res) {
if (err) { if (err) {
client.error(err); client.error(err);
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
-18
View File
@@ -126,24 +126,6 @@ module.exports = {
interaction.send({ components: [SelectSettings], flags: (1 << 6) }); interaction.send({ components: [SelectSettings], flags: (1 << 6) });
client.on("interactionCreate", MenuInteraction => {
if(!MenuInteraction.isSelectMenu()) return;
if (!MenuInteraction.customId.endsWith(MenuInteraction.member.user.id)) {
return MenuInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
const setting = settings.settings.find(setting => setting.name === MenuInteraction.values[0]);
const settingEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setTitle(setting.name)
.setDescription(setting.description)
return MenuInteraction.update({ embeds: [settingEmbed], components: [] });
});
} else if (args[0].name == 'support') { } else if (args[0].name == 'support') {
const supportEmbed = new EmbedBuilder() const supportEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Default) .setColor(client.config.Colors.Default)
+35 -209
View File
@@ -1,7 +1,7 @@
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, SelectMenuBuilder } = require('discord.js'); const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, SelectMenuBuilder } = require('discord.js');
const { Inventory, addInventory } = require('../structures/inventory'); const { Inventory, addInventory } = require('../structures/inventory');
const action = ['ditch', 'drop', 'forget', 'throw out', 'leave', 'set down', 'let go of']; const getActions = ['pick up', 'grab', 'get', 'aquire', 'obtain', 'gain', 'take possesssion of'];
module.exports = { module.exports = {
name: "inventory", name: "inventory",
@@ -235,67 +235,6 @@ module.exports = {
interaction.send({ components: [opt], flags: (1 << 6) }) interaction.send({ components: [opt], flags: (1 << 6) })
client.on("interactionCreate", MenuInteraction => {
if(!MenuInteraction.isSelectMenu()) return;
if (!MenuInteraction.customId.endsWith(MenuInteraction.member.user.id)) {
return MenuInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
if (MenuInteraction.values[0] == 'all') {
let inventoryEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setTitle('Your Inventory')
let description = `To see detials on an Item use \`/inventory view\` and select the item to view\n\n\`\`\``
for (let i = 0; i < inventory.guilds[GuildDB.serverID].items.length; i++) {
if (inventory.guilds[GuildDB.serverID].items[i].type == 'firearm') description += `${i+1}. ${inventory.guilds[GuildDB.serverID].items[i].weaponType} - ${inventory.guilds[GuildDB.serverID].items[i].description}\n`;
else description += `${i+1}. ${inventory.guilds[GuildDB.serverID].items[i].name} - ${inventory.guilds[GuildDB.serverID].items[i].description}\n`
}
description += "```"
inventoryEmbed.setDescription(description);
return MenuInteraction.update({ embeds: [inventoryEmbed], components: [], flags: (1 << 6) });
} else {
let item = inventory.guilds[GuildDB.serverID].items[MenuInteraction.values[0]];
let itemEmbed = new EmbedBuilder().setColor(client.config.Colors.Default);
if (item.type == 'wallet') {
// Display wallet
let ID = `${client.exists(item.ID.firstname) ? item.ID.firstname : '...'} ${client.exists(item.ID.lastname) ? item.ID.lastname : '...'} | ${client.exists(item.ID.dob) ? item.ID.dob : 'N/A'} | ${client.exists(item.ID.addr) ? item.ID.addr : 'N/A'}`
itemEmbed.setTitle(`Your Wallet`);
itemEmbed.addFields(
{ name: '**Cash**', value: `$${item.cash.toFixed(2)}`, inline: true },
{ name: '**ID**', value: ID, inline: true });
} else if (item.type == 'firearm') {
// Display firearm
itemEmbed.setTitle('Firearm');
itemEmbed.addFields(
{ name: 'Serial #', value: item.serial, inline: true },
{ name: 'Type', value: item.weaponType, inline: true },
{ name: 'Description', value: item.description, inline: true },
{ name: 'Owner', value: item.ownerName, inline: true }
);
} else {
// Display generic item here
itemEmbed.setTitle(`Item information`);
itemEmbed.addFields({ name: item.name, value: item.description, inline: false });
}
return MenuInteraction.update({ embeds: [itemEmbed], components: [], flags: (1 << 6) });
}
});
} else if (args[0].name == 'wallet') { } else if (args[0].name == 'wallet') {
// Display wallet // Display wallet
@@ -336,7 +275,7 @@ module.exports = {
}); });
let message = new EmbedBuilder() let message = new EmbedBuilder()
.setTitle(`You ${actions[Math.floor(Math.random() * actions.length)]} a ${firearm.weaponType}`) .setTitle(`You ${getActions[Math.floor(Math.random() * actions.length)]} a ${firearm.weaponType}`)
.setColor(client.config.Colors.Default); .setColor(client.config.Colors.Default);
return interaction.send({ embeds: [message] }); return interaction.send({ embeds: [message] });
@@ -372,40 +311,37 @@ module.exports = {
} else if (args[0].name == 'drop') { } else if (args[0].name == 'drop') {
// Remove Item from inventory // Remove Item from inventory
if (args[0].options[0].value < 1 || args[0].options[0].value > inventory.guilds[GuildDB.serverID].items.length) { if (inventory.guilds[GuildDB.serverID].items.length == 1) {
let embed = new EmbedBuilder() const nsi = new EmbedBuilder()
.setTitle("Please provide a valid item number") .setDescription('**Notice:** No items to drop')
.setColor(client.config.Colors.Red) .setColor(client.config.Colors.Yellow);
return interaction.send({ embeds: [embed] }); return interaction.send({ embeds: [nsi] });
} }
if (args[0].options[0].value == 1) { let items = new SelectMenuBuilder()
let embed = new EmbedBuilder() .setCustomId(`dropSelect-${interaction.member.user.id}`)
.setTitle("Cannot Drop Wallet") .setPlaceholder('Select item to drop')
.setColor(client.config.Colors.Default);
return interaction.send({ embeds: [embed] }); for (let i = 1; i < inventory.guilds[GuildDB.serverID].items.length; i++) {
if (inventory.guilds[GuildDB.serverID].items[i].type == 'firearm') {
items.addOptions({
label: inventory.guilds[GuildDB.serverID].items[i].weaponType,
description: 'Drop this item',
value: `${i}`
})
} else {
items.addOptions({
label: inventory.guilds[GuildDB.serverID].items[i].name,
description: 'Drop this item',
value: `${i}`
})
}
} }
let item = inventory.guilds[GuildDB.serverID].items[args[0].options[0].value-1]; const opt = new ActionRowBuilder().addComponents(items);
client.dbo.collection('inventories').updateOne({'inventory.userID': interaction.member.user.id}, {$pull: {[`inventory.guilds.${GuildDB.serverID}.items`]: item}}, function(err, res) { interaction.send({ components: [opt], flags: (1 << 6) })
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.send({ embeds: [embed] });
}
let message = new EmbedBuilder()
.setTitle(`You ${action[Math.floor(Math.random() * actions.length)]} your ${item.name}`)
.setColor(client.config.Colors.Default);
return interaction.send({ embeds: [message] });
});
} else if (args[0].name == 'give') { } else if (args[0].name == 'give') {
if (inventory.guilds[GuildDB.serverID].items.length == 1) { if (inventory.guilds[GuildDB.serverID].items.length == 1) {
@@ -416,28 +352,23 @@ module.exports = {
return interaction.send({ embeds: [nsi] }); return interaction.send({ embeds: [nsi] });
} }
const targetUserID = args[0].options[0].value.replace('<@!', '').replace('>', '');
let items = new SelectMenuBuilder() let items = new SelectMenuBuilder()
.setCustomId(`inventorySelect-${interaction.member.user.id}`) .setCustomId(`giveSelect-${targetUserID}-${interaction.member.user.id}`)
.setPlaceholder('Select Item to view') .setPlaceholder('Select Item to give')
.addOptions(
{
label: 'View All',
description: 'View a list of all your inventory items',
value: 'all',
}
)
for (let i = 1; i < inventory.guilds[GuildDB.serverID].items.length; i++) { for (let i = 1; i < inventory.guilds[GuildDB.serverID].items.length; i++) {
if (inventory.guilds[GuildDB.serverID].items[i].type == 'firearm') { if (inventory.guilds[GuildDB.serverID].items[i].type == 'firearm') {
items.addOptions({ items.addOptions({
label: inventory.guilds[GuildDB.serverID].items[i].weaponType, label: inventory.guilds[GuildDB.serverID].items[i].weaponType,
description: 'View this items description', description: 'Give this item',
value: `${i}` value: `${i}`
}) })
} else { } else {
items.addOptions({ items.addOptions({
label: inventory.guilds[GuildDB.serverID].items[i].name, label: inventory.guilds[GuildDB.serverID].items[i].name,
description: 'View this items description', description: 'Give this item',
value: `${i}` value: `${i}`
}) })
} }
@@ -447,79 +378,6 @@ module.exports = {
interaction.send({ components: [opt], flags: (1 << 6) }) interaction.send({ components: [opt], flags: (1 << 6) })
client.on("interactionCreate", MenuInteraction => {
if(!MenuInteraction.isSelectMenu()) return;
if (!MenuInteraction.customId.endsWith(MenuInteraction.member.user.id)) {
return MenuInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let item = inventory.guilds[GuildDB.serverID].items[MenuInteraction.values[0]];
let targetUserID = args[0].options[1].value.replace('<@!', '').replace('>', '');
let targetUserInventory = await client.dbo.collection("inventories").findOne({"inventory.userID":targetUserID}).then(inventory => inventory);
if (!targetUserInventory) {
// Register inventory for user with item givn
let newInventory = new Inventory();
newInventory.createInventory(targetUserID, GuildDB.serverID);
newInventory.addItem(item);
newInventory.save()
.catch(err => {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return MenuInteraction.update({ embeds: [embed], components: [] });
}
});
} else {
if (!client.exists(targetUserInventory.guilds[GuildDB.serverID])) {
const success = addInventory(inventory.guilds, GuildDB.serverID, targetUserID, client);
if (!success) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return MenuInteraction.update({ embeds: [embed], components: [] });
}
}
client.dbo.collection('inventories').updateOne({'inventory.userID': interaction.member.user.id}, {$pull: {[`inventory.guilds.${GuildDB.serverID}.items`]: item}}, function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return MenuInteraction.update({ embeds: [embed], components: [] });
}
});
client.dbo.collection('inventories').updateOne({'inventory.userID': targetUserID}, {$push: {[`inventory.guilds.${GuildDB.serverID}.items`]: item}}, function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return MenuInteraction.update({ embeds: [embed], components: [] });
}
});
}
let successEmbed = new EmbedBuilder()
.setTitle('Success')
.setDescription(`Successfully gave <@${targetUserID}> ${item.name}`)
.setColor('GREEN');
return MenuInteraction.update({ embeds: [successEmbed], components: [] });
});
} else if (args[0].name == 'clear') { } else if (args[0].name == 'clear') {
const prompt = new EmbedBuilder() const prompt = new EmbedBuilder()
.setTitle(`Are you sure you want to clear your inventory?`) .setTitle(`Are you sure you want to clear your inventory?`)
@@ -529,48 +387,16 @@ module.exports = {
const opt = new ActionRowBuilder() const opt = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`yes-${interaction.member.user.id}`) .setCustomId(`inventoryClear-yes-${interaction.member.user.id}`)
.setLabel("Yes") .setLabel("Yes")
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`no-${interaction.member.user.id}`) .setCustomId(`inventoryClear-no-${interaction.member.user.id}`)
.setLabel("No") .setLabel("No")
.setStyle(ButtonStyle.Success) .setStyle(ButtonStyle.Success)
) )
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = ''
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'cleared';
const tempWallet = inventory.guilds[GuildDB.serverID].items[0];
client.dbo.collection("inventories").updateOne({"inventory.userID":inventory.userID},{$set:{[`inventory.guilds.${GuildDB.serverID}.items`]: [tempWallet]}},function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} your inventory.`)
return ButtonInteraction.update({ embeds: [successEmbed], components: [] });
});
} }
}, },
+2 -2
View File
@@ -54,7 +54,7 @@ module.exports = {
if (!canUseCommand) return interaction.send('You don\'t have the permissions to use this command.'); if (!canUseCommand) return interaction.send('You don\'t have the permissions to use this command.');
const targetUserID = args[2].value.replace('<@!', '').replace('>', ''); const targetUserID = args[2].value.replace('<@!', '').replace('>', '');
let banking = await client.dbo.collection("banks").findOne({"account.userID": targetUserID}).then(banking => banking); let banking = await client.dbo.collection("banks").findOne({"banking.userID": targetUserID}).then(banking => banking);
if (!banking) { if (!banking) {
banking = { banking = {
@@ -102,7 +102,7 @@ module.exports = {
? banking.guilds[GuildDB.serverID].account.balance + args[1].value ? banking.guilds[GuildDB.serverID].account.balance + args[1].value
: banking.guilds[GuildDB.serverID].account.balance - args[1].value; : banking.guilds[GuildDB.serverID].account.balance - args[1].value;
client.dbo.collection("banks").updateOne({"account.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance}}, function(err, res) { client.dbo.collection("banks").updateOne({"banking.userID":targetUserID},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance}}, function(err, res) {
if (err) { if (err) {
client.error(err); client.error(err);
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
+3 -64
View File
@@ -44,77 +44,16 @@ module.exports = {
const opt = new ActionRowBuilder() const opt = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`yes-${interaction.member.user.id}`) .setCustomId(`reset-yes-${targetUserID}-${interaction.member.user.id}`)
.setLabel("Yes") .setLabel("Yes")
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`no-${interaction.member.user.id}`) .setCustomId(`reset-no-${targetUserID}-${interaction.member.user.id}`)
.setLabel("No") .setLabel("No")
.setStyle(ButtonStyle.Success) .setStyle(ButtonStyle.Success)
) )
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
if (queryString==`yes-${interaction.member.user.id}`) {
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle('Successfully reset user\'s data')
let inventory = await client.dbo.collection("inventories").findOne({"inventory.userID": interaction.member.user.id}).then(inventory => inventory);
let banking = await client.dbo.collection("banks").findOne({"account.userID": interaction.member.user.id}).then(banking => banking);
let inventoryReset = false;
let bankingReset = false;
if (!inventory) inventoryReset = true
else inventory = inventory.inventory
if (!banking) bankingReset = true
else banking = banking.banking
if (inventoryReset && bankingReset) return ButtonInteraction.update({ embeds: [successEmbed], components: [] });
if (!inventoryReset) {
const success = addInventory(inventory.guilds, GuildDB.serverID, targetUserID, client);
if (!success) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return ButtonInteraction.update({ embeds: [embed], components: [] });
}
}
if (!bankingReset) {
const success = addBank(banking.guilds, GuildDB.serverID, targetUserID, client);
if (!success) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return ButtonInteraction.update({ embeds: [embed], components: [] });
}
}
return ButtonInteraction.update({ embeds: [successEmbed], components: [] });
} else if (queryString==`no-${interaction.member.user.id}`) {
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`The User was not reset`);
return ButtonInteraction.update({ embeds: [successEmbed], components: [] });
}
});
}, },
}, },
+28 -345
View File
@@ -398,47 +398,16 @@ module.exports = {
const opt = new ActionRowBuilder() const opt = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`yes-${interaction.member.user.id}`) .setCustomId(`allowedChannels-yes-${interaction.member.user.id}`)
.setLabel("Yes") .setLabel("Yes")
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`no-${interaction.member.user.id}`) .setCustomId(`allowedChannels-no-${interaction.member.user.id}`)
.setLabel("No") .setLabel("No")
.setStyle(ButtonStyle.Success) .setStyle(ButtonStyle.Success)
) )
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = ''
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull:{"server.allowedChannels": channelid}}, function (err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Success: You ${action} the channel.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
} else console.log('exception?'); } else console.log('exception?');
@@ -476,48 +445,16 @@ module.exports = {
const opt = new ActionRowBuilder() const opt = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`yes-${interaction.member.user.id}`) .setCustomId(`actionChannel-yes-${interaction.member.user.id}`)
.setLabel("Yes") .setLabel("Yes")
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`no-${interaction.member.user.id}`) .setCustomId(`actionChannel-no-${interaction.member.user.id}`)
.setLabel("No") .setLabel("No")
.setStyle(ButtonStyle.Success) .setStyle(ButtonStyle.Success)
) )
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = ''
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":ButtonInteraction.guild.id},{$set:{"server.actionChannel": null}},function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Success: You ${action} the channel.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
} }
} else if (args[0].name == 'tweet_channel') { } else if (args[0].name == 'tweet_channel') {
@@ -563,39 +500,7 @@ module.exports = {
.setStyle(ButtonStyle.Success) .setStyle(ButtonStyle.Success)
) )
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = ''
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":ButtonInteraction.guild.id},{$set:{"server.tweetChannel": null}},function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Success: You ${action} the channel.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
} }
} else if (args[0].name == 'adverts_channel') { } else if (args[0].name == 'adverts_channel') {
@@ -632,48 +537,16 @@ module.exports = {
const opt = new ActionRowBuilder() const opt = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`yes-${interaction.member.user.id}`) .setCustomId(`advertsChannel-yes-${interaction.member.user.id}`)
.setLabel("Yes") .setLabel("Yes")
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`no-${interaction.member.user.id}`) .setCustomId(`advertsChannel-no-${interaction.member.user.id}`)
.setLabel("No") .setLabel("No")
.setStyle(ButtonStyle.Success) .setStyle(ButtonStyle.Success)
) )
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":ButtonInteraction.guild.id},{$set:{"server.advertsChannel": null}},function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Success: You ${action} the channel.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
} }
} else if (args[0].name == 'dispatcher_channel') { } else if (args[0].name == 'dispatcher_channel') {
@@ -711,48 +584,16 @@ module.exports = {
const opt = new ActionRowBuilder() const opt = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`yes-${interaction.member.user.id}`) .setCustomId(`dispatchChannel-yes-${interaction.member.user.id}`)
.setLabel("Yes") .setLabel("Yes")
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`no-${interaction.member.user.id}`) .setCustomId(`dispatchChannel-no-${interaction.member.user.id}`)
.setLabel("No") .setLabel("No")
.setStyle(ButtonStyle.Success) .setStyle(ButtonStyle.Success)
) )
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":ButtonInteraction.guild.id},{$set:{"server.dispatchChannel": null}},function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Success: You ${action} the channel.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
} }
} else if (args[0].name == 'starting_balance') { } else if (args[0].name == 'starting_balance') {
@@ -839,48 +680,16 @@ module.exports = {
const opt = new ActionRowBuilder() const opt = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`yes-${interaction.member.user.id}`) .setCustomId(`incomeRole-yes-${interaction.member.user.id}`)
.setLabel("Yes") .setLabel("Yes")
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`no-${interaction.member.user.id}`) .setCustomId(`incomeRole-no-${interaction.member.user.id}`)
.setLabel("No") .setLabel("No")
.setStyle(ButtonStyle.Success) .setStyle(ButtonStyle.Success)
) )
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull: {"server.incomeRoles": roleId}}, function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} <@&${roleId}> from income roles.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
} }
} }
@@ -913,48 +722,16 @@ module.exports = {
const opt = new ActionRowBuilder() const opt = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`yes-${interaction.member.user.id}`) .setCustomId(`commercialRole-yes-${interaction.member.user.id}`)
.setLabel("Yes") .setLabel("Yes")
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`no-${interaction.member.user.id}`) .setCustomId(`commercialRole-no-${interaction.member.user.id}`)
.setLabel("No") .setLabel("No")
.setStyle(ButtonStyle.Success) .setStyle(ButtonStyle.Success)
) )
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.commercialRole": null}}, function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} <@&${roleId}> as commercial role.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
} }
} else if (args[0].name == 'officer_role') { } else if (args[0].name == 'officer_role') {
@@ -987,48 +764,16 @@ module.exports = {
const opt = new ActionRowBuilder() const opt = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`yes-${interaction.member.user.id}`) .setCustomId(`officerRole-yes-${interaction.member.user.id}`)
.setLabel("Yes") .setLabel("Yes")
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`no-${interaction.member.user.id}`) .setCustomId(`officerRole-no-${interaction.member.user.id}`)
.setLabel("No") .setLabel("No")
.setStyle(ButtonStyle.Success) .setStyle(ButtonStyle.Success)
) )
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.officerRole": null}}, function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} <@&${roleId}> as officer role.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
} }
} else if (args[0].name == 'dispatcher_role') { } else if (args[0].name == 'dispatcher_role') {
@@ -1061,47 +806,16 @@ module.exports = {
const opt = new ActionRowBuilder() const opt = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`yes-${interaction.member.user.id}`) .setCustomId(`dispatchRole-yes-${interaction.member.user.id}`)
.setLabel("Yes") .setLabel("Yes")
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`no-${interaction.member.user.id}`) .setCustomId(`dispatchRole-no-${interaction.member.user.id}`)
.setLabel("No") .setLabel("No")
.setStyle(ButtonStyle.Success) .setStyle(ButtonStyle.Success)
) )
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.dispatcherRole": null}}, function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} <@&${roleId}> as dispatcher role.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
} }
@@ -1135,47 +849,16 @@ module.exports = {
const opt = new ActionRowBuilder() const opt = new ActionRowBuilder()
.addComponents( .addComponents(
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`yes-${interaction.member.user.id}`) .setCustomId(`botAdmin-yes-${interaction.member.user.id}`)
.setLabel("Yes") .setLabel("Yes")
.setStyle(ButtonStyle.Danger), .setStyle(ButtonStyle.Danger),
new ButtonBuilder() new ButtonBuilder()
.setCustomId(`no-${interaction.member.user.id}`) .setCustomId(`botAdmin-no-${interaction.member.user.id}`)
.setLabel("No") .setLabel("No")
.setStyle(ButtonStyle.Success) .setStyle(ButtonStyle.Success)
) )
interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) }); return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
client.on("interactionCreate", ButtonInteraction => {
if(!ButtonInteraction.isButton()) return;
const queryString = ButtonInteraction.customId;
if (!queryString.endsWith(ButtonInteraction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (queryString==`yes-${interaction.member.user.id}`) {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.botAdmin": null}}, function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.send({ embeds: [embed] });
}
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} <@&${roleId}> as dispatcher role.`)
return ButtonInteraction.update({ content: '', embeds: [successEmbed], components: [] });
});
} }
} else if (args[0].name == 'only_officers_search') { } else if (args[0].name == 'only_officers_search') {
+2 -2
View File
@@ -87,7 +87,7 @@ module.exports = {
} }
} }
let banking = await client.dbo.collection("banks").findOne({"account.userID": interaction.member.user.id}).then(banking => banking); let banking = await client.dbo.collection("banks").findOne({"banking.userID": interaction.member.user.id}).then(banking => banking);
if (!banking) { if (!banking) {
banking = { banking = {
@@ -140,7 +140,7 @@ module.exports = {
earned = workPays[highestPayIndex] earned = workPays[highestPayIndex]
newBalance = banking.guilds[GuildDB.serverID].account.balance + earned newBalance = banking.guilds[GuildDB.serverID].account.balance + earned
client.dbo.collection("banks").updateOne({"account.userID":interaction.member.user.id},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance}}, function(err, res) { client.dbo.collection("banks").updateOne({"banking.userID":interaction.member.user.id},{$set:{[`banking.guilds.${GuildDB.serverID}.account.balance`]:newBalance}}, function(err, res) {
if (err) { if (err) {
client.error(err); client.error(err);
const embed = new EmbedBuilder() const embed = new EmbedBuilder()
+620
View File
@@ -0,0 +1,620 @@
const { EmbedBuilder } = require("discord.js");
const settings = require('../config/settingsHelp');
const dropActions = ['ditch', 'drop', 'forget', 'throw out', 'leave', 'set down', 'let go of'];
module.exports = async (client, interaction) => {
if (interaction.isCommand()) return;
/*
This file handles all menu and button interactions
from any command
*/
const GuildDB = await client.GetGuild(interaction.guildId);
// Handler for '/311'
if (interaction.customId.startsWith('911')) {
if (!interaction.member._roles.includes(GuildDB.dispatcherRole)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully Deleted 311 Report.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
// Handler for '/911'
if (interaction.customId.startsWith('911')) {
if (!interaction.member._roles.includes(GuildDB.dispatcherRole)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully Deleted 911 Call.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
// Handler for '/help settings'
if (interaction.customId.startsWith('settingSelect')) {
const setting = settings.settings.find(setting => setting.name === interaction.values[0]);
const settingEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setTitle(setting.name)
.setDescription(setting.description)
return interaction.update({ embeds: [settingEmbed], components: [] });
}
// Handler for '/inventory view'
if (interaction.customId.startsWith('inventorySelect')) {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let inventory = await client.dbo.collection("inventories").findOne({"inventory.userID": interaction.member.user.id}).then(inventory => inventory);
inventory.inventory;
if (interaction.values[0] == 'all') {
let inventoryEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setTitle('Your Inventory')
let description = `To see detials on an Item use \`/inventory view\` and select the item to view\n\n\`\`\``
for (let i = 0; i < inventory.guilds[GuildDB.serverID].items.length; i++) {
if (inventory.guilds[GuildDB.serverID].items[i].type == 'firearm') description += `${i+1}. ${inventory.guilds[GuildDB.serverID].items[i].weaponType} - ${inventory.guilds[GuildDB.serverID].items[i].description}\n`;
else description += `${i+1}. ${inventory.guilds[GuildDB.serverID].items[i].name} - ${inventory.guilds[GuildDB.serverID].items[i].description}\n`
}
description += "```"
inventoryEmbed.setDescription(description);
return interaction.update({ embeds: [inventoryEmbed], components: [], flags: (1 << 6) });
} else {
let item = inventory.guilds[GuildDB.serverID].items[interaction.values[0]];
let itemEmbed = new EmbedBuilder().setColor(client.config.Colors.Default);
if (item.type == 'wallet') {
// Display wallet
let ID = `${client.exists(item.ID.firstname) ? item.ID.firstname : '...'} ${client.exists(item.ID.lastname) ? item.ID.lastname : '...'} | ${client.exists(item.ID.dob) ? item.ID.dob : 'N/A'} | ${client.exists(item.ID.addr) ? item.ID.addr : 'N/A'}`
itemEmbed.setTitle(`Your Wallet`);
itemEmbed.addFields(
{ name: '**Cash**', value: `$${item.cash.toFixed(2)}`, inline: true },
{ name: '**ID**', value: ID, inline: true });
} else if (item.type == 'firearm') {
// Display firearm
itemEmbed.setTitle('Firearm');
itemEmbed.addFields(
{ name: 'Serial #', value: item.serial, inline: true },
{ name: 'Type', value: item.weaponType, inline: true },
{ name: 'Description', value: item.description, inline: true },
{ name: 'Owner', value: item.ownerName, inline: true }
);
} else {
// Display generic item here
itemEmbed.setTitle(`Item information`);
itemEmbed.addFields({ name: item.name, value: item.description, inline: false });
}
return interaction.update({ embeds: [itemEmbed], components: [], flags: (1 << 6) });
}
}
// Handler for '/invenvotry drop'
if (interaction.customId.startsWith('dropSelect')) {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let inventory = await client.dbo.collection("inventories").findOne({"inventory.userID": interaction.member.user.id}).then(inventory => inventory);
inventory.inventory;
let item = inventory.guilds[GuildDB.serverID].items[args[0].options[0].value-1];
client.dbo.collection('inventories').updateOne({'inventory.userID': interaction.member.user.id}, {$pull: {[`inventory.guilds.${GuildDB.serverID}.items`]: item}}, function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.update({ embeds: [embed], components: [] });
}
let message = new EmbedBuilder()
.setTitle(`You ${dropActions[Math.floor(Math.random() * dropActions.length)]} your ${item.name}`)
.setColor(client.config.Colors.Default);
return interaction.update({ embeds: [message], components: [] });
});
}
// Handler for '/inventory give'
if (interaction.customId.startsWith('giveSelect')) {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let inventory = await client.dbo.collection("inventories").findOne({"inventory.userID": interaction.member.user.id}).then(inventory => inventory);
inventory = inventory.inventory;
let item = inventory.guilds[GuildDB.serverID].items[interaction.values[0]];
let targetUserID = interaction.customId.split('-')[1].replace('<@!', '').replace('>', '');
let targetUserInventory = await client.dbo.collection("inventories").findOne({"inventory.userID":targetUserID}).then(inventory => inventory);
if (!targetUserInventory) {
// Register inventory for user with item givn
let newInventory = new Inventory();
newInventory.createInventory(targetUserID, GuildDB.serverID);
newInventory.addItem(item);
newInventory.save()
.catch(err => {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.update({ embeds: [embed], components: [] });
}
});
} else {
targetUserInventory = targetUserIventory.inventory;
if (!client.exists(targetUserInventory.guilds[GuildDB.serverID])) {
const success = addInventory(inventory.guilds, GuildDB.serverID, targetUserID, client);
if (!success) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.update({ embeds: [embed], components: [] });
}
}
client.dbo.collection('inventories').updateOne({'inventory.userID': interaction.member.user.id}, {$pull: {[`inventory.guilds.${GuildDB.serverID}.items`]: item}}, function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.update({ embeds: [embed], components: [] });
}
});
client.dbo.collection('inventories').updateOne({'inventory.userID': targetUserID}, {$push: {[`inventory.guilds.${GuildDB.serverID}.items`]: item}}, function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.update({ embeds: [embed], components: [] });
}
});
}
let successEmbed = new EmbedBuilder()
.setTitle('Success')
.setDescription(`Successfully gave <@${targetUserID}> ${item.name}`)
.setColor('GREEN');
return interaction.update({ embeds: [successEmbed], components: [] });
}
// Handler for '/inventory clear'
if (interaction.customId.startsWith('inventoryClear')) {
const queryString = interaction.customId;
if (!queryString.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = ''
if (queryString==`inventoryClear-yes-${interaction.member.user.id}`) {
action = 'cleared';
const tempWallet = inventory.guilds[GuildDB.serverID].items[0];
client.dbo.collection("inventories").updateOne({"inventory.userID":interaction.member.user.id},{$set:{[`inventory.guilds.${GuildDB.serverID}.items`]: [tempWallet]}},function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.update({ embeds: [embed], components: [] });
}
});
} else if (queryString==`inventoryClear-no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} your inventory.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
// Handler for '/reset'
if (interaction.customId.startsWith('reset')) {
const choice = interaction.customId.split('-')[1];
const targetUserID = interaction.customId.split('-')[2];
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
if (choice=='yes') {
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle('Successfully reset user\'s data')
let inventory = await client.dbo.collection("inventories").findOne({"inventory.userID": interaction.member.user.id}).then(inventory => inventory);
let banking = await client.dbo.collection("banks").findOne({"banking.userID": interaction.member.user.id}).then(banking => banking);
let inventoryReset = false;
let bankingReset = false;
if (!inventory) inventoryReset = true
else inventory = inventory.inventory
if (!banking) bankingReset = true
else banking = banking.banking
if (inventoryReset && bankingReset) return interaction.update({ embeds: [successEmbed], components: [] });
if (!inventoryReset) {
const success = addInventory(inventory.guilds, GuildDB.serverID, targetUserID, client);
if (!success) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.update({ embeds: [embed], components: [] });
}
}
if (!bankingReset) {
const success = addBank(banking.guilds, GuildDB.serverID, targetUserID, client);
if (!success) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.update({ embeds: [embed], components: [] });
}
}
return interaction.update({ embeds: [successEmbed], components: [] });
} else if (choice=='no') {
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`The User was not reset`);
return interaction.update({ embeds: [successEmbed], components: [] });
}
}
// Handler for '/settings allowed_channels remove'
if (interaction.customId.startsWith('allowedChannels')) {
if (!queryString.endsWith(interaction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = ''
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull:{"server.allowedChannels": channelid}}, function (err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.update({ embeds: [embed], components: [] });
}
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Success: You ${action} the channel.`)
return interactino.update({ embeds: [successEmbed], components: [] });
}
// Handler for '/settings action_channel remove'
if (interaction.customId.startsWith('actionChannel')) {
if (!queryString.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = ''
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.actionChannel": null}},function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.update({ embeds: [embed], components: [] });
}
});
} else if (queryString==`no-${interaction.member.user.id}`) action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Success: You ${action} the channel.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
// Handler for '/settings tweet_channel remove'
if (interaction.customId.startsWith('tweetChannel')) {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = ''
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.tweetChannel": null}},function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.update({ embeds: [embed], components: [] });
}
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Success: You ${action} the channel.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
// Handler for '/settings adverts_channel remove'
if (interaction.customId.startsWith('advertsChannel')) {
if (!interaction.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.advertsChannel": null}},function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.update({ embeds: [embed], components: [] });
}
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Success: You ${action} the channel.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
// Handler for '/settings dispatcher_channel remove'
if(interaction.customId.startsWith('dispatchChannel')) {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID},{$set:{"server.dispatchChannel": null}},function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.update({ embeds: [embed], components: [] });
}
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Success: You ${action} the channel.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
// Handler for '/settings income_role remove'
if (interaction.customId.startsWith('incomeRole')) {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$pull: {"server.incomeRoles": roleId}}, function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.update({ embeds: [embed], components: [] });
}
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} <@&${roleId}> from income roles.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
// Handler for '/settings commercial_role remove'
if (interaction.customId.startsWith('commercialRole')) {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.commercialRole": null}}, function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.update({ embeds: [embed], components: [] });
}
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} <@&${roleId}> as commercial role.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
// Handler for '/settings officer_role remove'
if (interaction.customId.startsWith('officerRole')) {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='no') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.officerRole": null}}, function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.update({ embeds: [embed], components: [] });
}
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} <@&${roleId}> as officer role.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
// Handler for '/settings dispatcher_role remove'
if (interaction.customId.startsWith('dispatchRole')) {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return interaction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.dispatcherRole": null}}, function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.update({ embeds: [embed], components: [] });
}
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} <@&${roleId}> as dispatcher role.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
// Handler for '/settings bot_admin_role remove'
if (interaction.customId.startsWith('botAdmin')) {
if (!interaction.customId.endsWith(interaction.member.user.id)) {
return ButtonInteraction.reply({
content: "This button is not for you",
flags: (1 << 6)
})
}
let action = '';
if (interaction.customId.split('-')[1]=='yes') {
action = 'removed';
client.dbo.collection("guilds").updateOne({"server.serverID":GuildDB.serverID}, {$set: {"server.botAdmin": null}}, function(err, res) {
if (err) {
client.error(err);
const embed = new EmbedBuilder()
.setDescription(`**Internal Error:**\nUh Oh D: Its not you, its me.\nThis command has crashed\nContact the Developers\nhttps://discord.gg/YCXhvy9uZw`)
.setColor(client.config.Colors.Red)
return interaction.update({ embeds: [embed], components: [] });
}
});
} else if (interaction.customId.split('-')[1]=='no') action = 'kept';
const successEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Green)
.setTitle(`Successfully ${action} <@&${roleId}> as dispatcher role.`)
return interaction.update({ embeds: [successEmbed], components: [] });
}
}
+8 -7
View File
@@ -94,15 +94,15 @@ class QuarksBot extends Client {
LoadCommands() { LoadCommands() {
let CommandsDir = path.join(__dirname, '..', 'commands'); let CommandsDir = path.join(__dirname, '..', 'commands');
fs.readdir(CommandsDir, (err, files) => { fs.readdir(CommandsDir, (err, files) => {
if (err) this.log(err); if (err) this.error(err);
else else
files.forEach((file) => { files.forEach((file) => {
let cmd = require(CommandsDir + "/" + file); let cmd = require(CommandsDir + "/" + file);
if (!cmd.name || !cmd.description) if (!this.exists(cmd.name) || !this.exists(cmd.description))
return this.log( return this.error(
"Unable to load Command: " + "Unable to load Command: " +
file.split(".")[0] + file.split(".")[0] +
", Reason: File doesn't had run/name/desciption" ", Reason: File doesn't had name/desciption"
); );
this.commands.set(file.split(".")[0].toLowerCase(), cmd); this.commands.set(file.split(".")[0].toLowerCase(), cmd);
this.log("Command Loaded: " + file.split(".")[0]); this.log("Command Loaded: " + file.split(".")[0]);
@@ -113,11 +113,12 @@ class QuarksBot extends Client {
LoadEvents() { LoadEvents() {
let EventsDir = path.join(__dirname, '..', 'events'); let EventsDir = path.join(__dirname, '..', 'events');
fs.readdir(EventsDir, (err, files) => { fs.readdir(EventsDir, (err, files) => {
if (err) this.log(err); if (err) this.error(err);
else else
files.forEach((file) => { files.forEach((file) => {
const event = require(EventsDir + "/" + file); const event = require(EventsDir + "/" + file);;
this.on(file.split(".")[0], event.bind(null, this)); if (file.split(".")[0] == 'interactionCreate') this.on(file.split(".")[0], i => event(this, i));
else this.on(file.split(".")[0], event.bind(null, this));
this.logger.log("Event Loaded: " + file.split(".")[0]); this.logger.log("Event Loaded: " + file.split(".")[0]);
}); });
}); });