dev test v 4
This commit is contained in:
3 files changed
+139
-11
No files matched your search
@@ -0,0 +1,111 @@
|
||||
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
|
||||
const { addInventory } = require('../structures/inventory');
|
||||
const { addBank } = require('../structures/bank');
|
||||
const bitfieldCalculator = require('discord-bitfield-calculator');
|
||||
|
||||
module.exports = {
|
||||
name: "reset",
|
||||
debug: false,
|
||||
global: false,
|
||||
description: "Reset a users data",
|
||||
usage: "[user]",
|
||||
permissions: {
|
||||
channel: ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS"],
|
||||
member: ["MANAGE_GUILD"],
|
||||
},
|
||||
options: [{
|
||||
name: "user",
|
||||
description: "User to reset",
|
||||
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 (client.exists(GuildDB.botAdmin) && interaction.member.roles.includes(GuildDB.botAdmin)) canUseCommand = true;
|
||||
if (!canUseCommand) return interaction.send({ content: 'You don\'t have the permissions to use this command.' });
|
||||
|
||||
const targetUserID = args[0].value.replace('<@!', '').replace('>', '');
|
||||
|
||||
const prompt = new EmbedBuilder()
|
||||
.setTitle(`Are you sure you want to reset this user?`)
|
||||
.setDescription('**Notice:** This will reset this users cash and balance.')
|
||||
.setColor(client.config.Colors.Yellow)
|
||||
|
||||
const opt = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`Reset-yes-${targetUserID}-${interaction.member.user.id}`)
|
||||
.setLabel("Yes")
|
||||
.setStyle(ButtonStyle.Danger),
|
||||
new ButtonBuilder()
|
||||
.setCustomId(`Reset-no-${targetUserID}-${interaction.member.user.id}`)
|
||||
.setLabel("No")
|
||||
.setStyle(ButtonStyle.Success)
|
||||
)
|
||||
|
||||
return interaction.send({ embeds: [prompt], components: [opt], flags: (1 << 6) });
|
||||
|
||||
},
|
||||
},
|
||||
|
||||
Interactions: {
|
||||
|
||||
Reset: {
|
||||
run: async (client, interaction, GuildDB) => {
|
||||
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 banking = await client.dbo.collection("banks").findOne({"banking.userID": interaction.member.user.id}).then(banking => banking);
|
||||
|
||||
let bankingReset = false;
|
||||
if (!banking) bankingReset = true
|
||||
else banking = banking.banking
|
||||
|
||||
if (!bankingReset) {
|
||||
const success = addBank(banking.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.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: [] });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "dayz-armbands",
|
||||
"version": "5.0.0.1",
|
||||
"version": "5.0.0.3",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "dayz-armbands",
|
||||
"version": "5.0.0.1",
|
||||
"version": "5.0.0.3",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@discordjs/rest": "^1.1.0",
|
||||
|
||||
@@ -10,6 +10,8 @@ const { Readable } = require('stream');
|
||||
const { finished } = require('stream/promises');
|
||||
const readline = require('readline');
|
||||
|
||||
const minute = 60000; // 1 minute in milliseconds
|
||||
|
||||
class DayzArmbands extends Client {
|
||||
|
||||
constructor(options, config) {
|
||||
@@ -104,18 +106,33 @@ class DayzArmbands extends Client {
|
||||
const { body } = await fetch(res.data.token.url);
|
||||
await finished(Readable.fromWeb(body).pipe(stream));
|
||||
|
||||
const fileStream = fs.createReadStream('./logs/server-logs.ADM');
|
||||
// const fileStream = fs.createReadStream('./logs/server-logs.ADM');
|
||||
|
||||
const rl = readline.createInterface({
|
||||
input: fileStream,
|
||||
crlfDelay: Infinity
|
||||
});
|
||||
let lines = [];
|
||||
for await (const line of rl) { lines.push(line); }
|
||||
// const rl = readline.createInterface({
|
||||
// input: fileStream,
|
||||
// crlfDelay: Infinity
|
||||
// });
|
||||
// let lines = [];
|
||||
// for await (const line of rl) { lines.push(line); }
|
||||
|
||||
const channel = this.channels.cache.get('993272430342721597');
|
||||
// const channel = this.channels.cache.get('993272430342721597');
|
||||
|
||||
channel.send({ content: lines[lines.length-1] });
|
||||
// channel.send({ content: lines[lines.length-1] });
|
||||
}
|
||||
|
||||
killfeed() {
|
||||
|
||||
}
|
||||
|
||||
async logsUpdateTimer() {
|
||||
setTimeout(async () => {
|
||||
await this.updateLogs().then(() => {
|
||||
this.killfeed(); // Check logs for killfeed
|
||||
// this.alarms(); // check for base alarms (+ rules that may apply such as safe zone)
|
||||
// this.adminLogs(); // check for combat logs / connect + deconnect events
|
||||
});
|
||||
this.logsUpdateTimer(); // restart this function
|
||||
}, minute * 5); // restart every 5 minutes
|
||||
}
|
||||
|
||||
async connectMongo(mongoURI, dbo) {
|
||||
|
||||
Reference in new issue
Block a user