6.11.0 unlink gamertag feature

This commit is contained in:
SowinskiBraeden committed 2023-06-07 10:28:00 -07:00
1 parent 9f33a198f8
commit 9e701cbaee
3 files changed
+208 -1

No files matched your search

+111
View File
@@ -0,0 +1,111 @@
const { EmbedBuilder } = require('discord.js');
const bitfieldCalculator = require('discord-bitfield-calculator');
module.exports = {
name: "admin-gamertag-link",
debug: false,
global: false,
description: "Disconnect a users gamertag for them",
usage: "[cmd] [opt]",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
options: [{
name: "user",
description: "User to link gamertag to",
value: "user",
type: 6,
required: true,
}],
SlashCommand: {
/**
*
* @param {require("../structures/QuarksBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
const permissions = bitfieldCalculator.permissions(interaction.member.permissions);
let canUseCommand = false;
if (permissions.includes("MANAGE_GUILD")) canUseCommand = true;
if (GuildDB.hasBotAdmin && interaction.member.roles.filter(e => GuildDB.botAdminRoles.indexOf(e) !== -1).length > 0) canUseCommand = true;
if (!canUseCommand) return interaction.send({ content: 'You don\'t have the permissions to use this command.' });
if (!client.exists(GuildDB.playerstats)) {
GuildDB.playerstats = [{}];
client.dbo.collection("guilds").updateOne({ "server.serverID": GuildDB.serverID }, {
$set: {
"server.playerstats": []
}
}, function (err, res) {
if (err) return client.sendInternalError(interaction, err);
});
}
let playerStat = GuildDB.playerstats.find(stat => stat.discordID == args[0].value );
if (playerStat == undefined) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Yellow).setDescription(`**Not Found** <@${args[0].value}> has no gamertag linked.`)] });
const warnGTOverwrite = new EmbedBuilder()
.setColor(client.config.Colors.Yellow)
.setDescription(`**Notice:**\n> This action will unlink the gamertag \` ${playerStat.gamertag} \` from the user <@${playerStat.discordID}>. Are you sure you would like to continue?`)
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`AdminUnlinkGamertag-yes-${args[0].value}-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Success),
new ButtonBuilder()
.setCustomId(`AdminUnlinkGamertag-no-${args[0].value}-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Secondary)
)
return interaction.send({ embeds: [warnGTOverwrite], components: [opt] });
},
},
Interactions: {
AdminUnlinkGamertag: {
run: async(client, interaction, GuildDB) => {
if (!interaction.customId.endsWith(interaction.member.user.id))
return interaction.reply({ content: 'This interaction is not for you', flags: (1 << 6) });
if (interaction.customId.split('-')[1]=='yes') {
let playerStat = GuildDB.playerstats.find(stat => stat.gamertag == interaction.customId.split('-')[2]);
playerStat.discordID = "";
let playerStatIndex = GuildDB.playerstats.indexOf(playerStat);
GuildDB.playerstats[playerStatIndex] = playerStat;
client.dbo.collection("guilds").updateOne({ 'server.serverID': GuildDB.serverID }, {
$set: {
'server.playerstats': GuildDB.playerstats,
}
});
let connectedEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setDescription(`Successfully unlinked \` ${playerStat.gamertag} \` from <@${interaction.customId.split('-')[2]}>.`);
return interaction.update({ embeds: [connectedEmbed], components: [] });
} else {
const cancel = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setDescription('**Canceled**\n> The gamertag unlink will not processed.');
return interaction.update({ embeds: [cancel], components: [] });
}
}
}
}
}
+96
View File
@@ -0,0 +1,96 @@
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: "gamertag-unlink",
debug: false,
global: false,
description: "Disconnect gamertag",
usage: "[cmd] [opt]",
permissions: {
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
member: [],
},
SlashCommand: {
/**
*
* @param {require("../structures/QuarksBot")} client
* @param {import("discord.js").Message} message
* @param {string[]} args
* @param {*} param3
*/
run: async (client, interaction, args, { GuildDB }) => {
if (!client.exists(GuildDB.playerstats)) {
GuildDB.playerstats = [{}];
client.dbo.collection("guilds").updateOne({ "server.serverID": GuildDB.serverID }, {
$set: {
"server.playerstats": []
}
}, function (err, res) {
if (err) return client.sendInternalError(interaction, err);
});
}
let playerStat = GuildDB.playerstats.find(stat => stat.discordID == interaction.user.member.id);
if (playerStat == undefined) return interaction.send({ embeds: [new EmbedBuilder().setColor(client.config.Colors.Yellow).setDescription(`**No Gamertag Linked** It Appears your don't have a gamertag linked to your account.`)] });
const warnGTOverwrite = new EmbedBuilder()
.setColor(client.config.Colors.Yellow)
.setDescription(`**Notice:**\n> Are you sure you want to unlink your gamertag? This will limit some automatic features.`);
const opt = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId(`UnlinkGamertag-yes-${interaction.member.user.id}`)
.setLabel("Yes")
.setStyle(ButtonStyle.Success),
new ButtonBuilder()
.setCustomId(`UnlinkGamertag-no-${interaction.member.user.id}`)
.setLabel("No")
.setStyle(ButtonStyle.Secondary)
)
return interaction.send({ embeds: [warnGTOverwrite], components: [opt] });
}
},
},
Interactions: {
UnlinkGamertag: {
run: async(client, interaction, GuildDB) => {
if (!interaction.customId.endsWith(interaction.member.user.id))
return interaction.reply({ content: 'This interaction is not for you', flags: (1 << 6) });
if (interaction.customId.split('-')[1]=='yes') {
let playerStat = GuildDB.playerstats.find(stat => stat.discordID == interaction.member.user.id);
playerStat.discordID = "";
let playerStatIndex = GuildDB.playerstats.indexOf(playerStat);
GuildDB.playerstats[playerStatIndex] = playerStat;
client.dbo.collection("guilds").updateOne({ 'server.serverID': GuildDB.serverID }, {
$set: {
'server.playerstats': GuildDB.playerstats,
}
});
let connectedEmbed = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setDescription(`Successfully unlinked \` ${playerStat.gamertag} \` as your gamertag.`);
return interaction.update({ embeds: [connectedEmbed], components: [] });
} else {
const cancel = new EmbedBuilder()
.setColor(client.config.Colors.Default)
.setDescription('**Canceled**\n> The gamertag unlink will not processed.');
return interaction.update({ embeds: [cancel], components: [] });
}
}
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "dayz-armbands",
"version": "6.10.3",
"version": "6.11.0",
"description": "A General Purpose Discord Bot for DayZ Servers.",
"main": "index.js",
"nodemonConfig": {