fix/ensure-proper-sendError
This commit is contained in:
34 files changed
+52
-57
No files matched your search
+1
-1
@@ -145,7 +145,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
+1
-1
@@ -186,7 +186,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
@@ -15,7 +15,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
@@ -14,7 +14,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
@@ -15,7 +15,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
+2
-2
@@ -308,7 +308,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
@@ -327,7 +327,7 @@ module.exports = {
|
||||
const channelid = args[0].options[0].options[0].value;
|
||||
|
||||
if (args[0].options[0].name == 'add') {
|
||||
const channelAdd = client.channels.cache.get(channelid);
|
||||
const channelAdd = client.GetChannel(channelid);
|
||||
|
||||
const newChannelErrorEmbed = new EmbedBuilder().setColor(client.config.Colors.Red)
|
||||
let error = false;
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
@@ -14,7 +14,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
@@ -21,7 +21,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
@@ -20,7 +20,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
@@ -13,7 +13,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
+4
-7
@@ -46,7 +46,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
@@ -80,10 +80,7 @@ module.exports = {
|
||||
(x) => x.aliases && x.aliases.includes(args[0].options[0].value)
|
||||
);
|
||||
if (!cmd)
|
||||
return client.sendError(
|
||||
interaction,
|
||||
`❌ | Unable to find that command.`
|
||||
);
|
||||
return interaction.send({ content: `❌ | Unable to find that command.` });
|
||||
|
||||
let embed = new EmbedBuilder()
|
||||
.setDescription(cmd.description)
|
||||
@@ -129,7 +126,7 @@ module.exports = {
|
||||
} else if (args[0].name == 'credits') {
|
||||
const creditsEmbed = new EmbedBuilder()
|
||||
.setColor(client.config.Colors.Default)
|
||||
.setTitle('QuarksBot Credits')
|
||||
.setTitle('DayzRBot Credits')
|
||||
.setDescription(`
|
||||
**Bot Author:** McDazzzled#5307
|
||||
|
||||
@@ -141,7 +138,7 @@ module.exports = {
|
||||
const end = new Date().getTime();
|
||||
const stats = new EmbedBuilder()
|
||||
.setColor(client.config.Colors.Default)
|
||||
.setTitle('QuarksBot Statistics')
|
||||
.setTitle('DayzRBot Statistics')
|
||||
.addFields(
|
||||
{ name: 'Guilds', value: `${client.guilds.cache.size}`, inline: true },
|
||||
{ name: 'Users', value: `${client.users.cache.size}`, inline: true },
|
||||
|
||||
@@ -39,7 +39,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
@@ -14,7 +14,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
@@ -14,7 +14,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
@@ -42,7 +42,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
@@ -15,7 +15,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
@@ -32,7 +32,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ module.exports = {
|
||||
SlashCommand: {
|
||||
/**
|
||||
*
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
* @param {import("discord.js").Message} message
|
||||
* @param {string[]} args
|
||||
* @param {*} param3
|
||||
|
||||
@@ -3,7 +3,7 @@ const { EmbedBuilder } = require('discord.js');
|
||||
module.exports = async (client, member) => {
|
||||
|
||||
let GuildDB = await client.GetGuild(member.guild.id);
|
||||
const channel = client.channels.cache.get(GuildDB.welcomeChannel);
|
||||
const channel = client.GetChannel(GuildDB.welcomeChannel);
|
||||
|
||||
let embed = new EmbedBuilder()
|
||||
.setColor(client.config.Colors.Default)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dayzr-bot",
|
||||
"version": "9.1.2",
|
||||
"version": "9.1.3",
|
||||
"description": "A General Purpose Discord Bot for DayZ Nitrado Servers.",
|
||||
"main": "index.js",
|
||||
"nodemonConfig": {
|
||||
|
||||
@@ -100,7 +100,6 @@ class DayzRBot extends Client {
|
||||
const client = this;
|
||||
}
|
||||
|
||||
|
||||
log(Text) { this.logger.log(Text); }
|
||||
error(Text) { this.logger.error(Text); }
|
||||
|
||||
@@ -186,7 +185,7 @@ class DayzRBot extends Client {
|
||||
"server.playerstats": s
|
||||
}
|
||||
}, function (err, res) {
|
||||
if (err) this.error(err);
|
||||
if (err) this.sendError(this.GetChannel(guild.adminLogsChannel), err);
|
||||
});
|
||||
|
||||
history.lastLog = lines[lines.length-1];
|
||||
@@ -306,11 +305,14 @@ class DayzRBot extends Client {
|
||||
const event = require(EventsDir + "/" + file);
|
||||
if (['interactionCreate','guildMemberAdd'].includes(file.split(".")[0])) 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.log("Event Loaded: " + file.split(".")[0]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Allows shorter lines of code elsewhere
|
||||
GetChannel(channel_id) { return this.channels.cache.get(channel_id); }
|
||||
|
||||
sendError(Channel, Error) {
|
||||
this.error(Error);
|
||||
let embed = new EmbedBuilder()
|
||||
@@ -320,7 +322,6 @@ class DayzRBot extends Client {
|
||||
Channel.send(embed);
|
||||
}
|
||||
|
||||
|
||||
// Handles internal errors for slash commands. E.g failed to update database from slash command.
|
||||
sendInternalError(Interaction, Error) {
|
||||
this.error(Error);
|
||||
|
||||
@@ -6,7 +6,7 @@ module.exports = {
|
||||
|
||||
let guild = await client.GetGuild(guildId);
|
||||
if (!client.exists(guild.connectionLogsChannel)) return;
|
||||
const channel = client.channels.cache.get(guild.connectionLogsChannel);
|
||||
const channel = client.GetChannel(guild.connectionLogsChannel);
|
||||
|
||||
let newDt = await client.getDateEST(data.time);
|
||||
let unixTime = Math.floor(newDt.getTime()/1000);
|
||||
@@ -40,7 +40,7 @@ module.exports = {
|
||||
|
||||
let guild = await client.GetGuild(guildId);
|
||||
if (!client.exists(guild.connectionLogsChannel)) return;
|
||||
const channel = client.channels.cache.get(guild.connectionLogsChannel);
|
||||
const channel = client.GetChannel(guild.connectionLogsChannel);
|
||||
if (!channel) return;
|
||||
|
||||
let unixTime = Math.floor(newDt.getTime()/1000);
|
||||
|
||||
@@ -18,7 +18,7 @@ module.exports = {
|
||||
let distance = Math.sqrt(Math.pow(diff[0], 2) + Math.pow(diff[1], 2)).toFixed(2)
|
||||
|
||||
if (distance < alarm.radius) {
|
||||
const channel = client.channels.cache.get(alarm.channel);
|
||||
const channel = client.GetChannel(alarm.channel);
|
||||
|
||||
let newDt = await client.getDateEST(data.time);
|
||||
let unixTime = Math.floor(newDt.getTime()/1000);
|
||||
@@ -90,7 +90,7 @@ module.exports = {
|
||||
|
||||
if (update) {
|
||||
client.dbo.collection("guilds").updateOne({ "server.serverID": guildId }, {$set: { "server.uavs": uavs }}, function (err, res) {
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
if (err) return client.sendError(client.GetChannel(guild.adminLogsChannel), err);
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -108,7 +108,7 @@ module.exports = {
|
||||
let distance = Math.sqrt(Math.pow(diff[0], 2) + Math.pow(diff[1], 2)).toFixed(2)
|
||||
|
||||
if (distance < alarm.radius) {
|
||||
const channel = client.channels.cache.get(alarm.channel);
|
||||
const channel = client.GetChannel(alarm.channel);
|
||||
|
||||
let newDt = await client.getDateEST(data.time);
|
||||
let unixTime = Math.floor(newDt.getTime()/1000);
|
||||
@@ -127,7 +127,7 @@ module.exports = {
|
||||
|
||||
ExpireEvent: async(client, guild, e) => {
|
||||
let hasMR = (guild.memberRole != "");
|
||||
const channel = client.channels.cache.get(e.channel);
|
||||
const channel = client.GetChannel(e.channel);
|
||||
if (client.exists(e.channel)) channel.send({ embeds: [new EmbedBuilder().setColor(client.config.colors.Default).setDescription(`${hasMR ? `<@&${guild.memberRole}>\n`:''}**The ${e.name} Event has ended!**`)] });
|
||||
|
||||
client.dbo.collection("guilds").updateOne({ "server.serverID": guild.serverID }, {
|
||||
@@ -135,7 +135,7 @@ module.exports = {
|
||||
"server.events": e
|
||||
}
|
||||
}, function(err, res) {
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
if (err) return client.sendError(client.GetChannel(guild.adminLogsChannel), err);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -152,7 +152,7 @@ module.exports = {
|
||||
.setDescription(`**${e.name} Event**\n${e.gamertag} was located at **[${player.pos[0]}, ${player.pos[1]}](https://www.izurvive.com/chernarusplussatmap/#location=${player.pos[0]};${player.pos[1]})** at <t:${unixTime}>`);
|
||||
|
||||
if (!client.exists(e.channel)) return module.exports.ExpireEvent(client, guild, e); // Expire event since it has invalid channel.
|
||||
const channel = client.channels.cache.get(e.channel);
|
||||
const channel = client.GetChannel(e.channel);
|
||||
channel.send({ embeds: [trackEvent], content: `${hasMR ? `\n<@&${guild.memberRole}>`:'@here'}` });
|
||||
|
||||
let now = new Date();
|
||||
|
||||
@@ -7,7 +7,7 @@ module.exports = {
|
||||
HandleKillfeed: async (client, guildId, stats, line) => {
|
||||
|
||||
let guild = await client.GetGuild(guildId);
|
||||
const channel = client.channels.cache.get(guild.killfeedChannel);
|
||||
const channel = client.GetChannel(guild.killfeedChannel);
|
||||
|
||||
let templateKilled = /(.*) \| Player \"(.*)\" \(DEAD\) \(id=(.*) pos=<(.*)>\) killed by Player \"(.*)\" \(id=(.*) pos=<(.*)>\) with (.*) from (.*) meters /g;
|
||||
let template = /(.*) \| Player \"(.*)\" \(id=(.*) pos=<(.*)>\)\[HP\: (.*)\] hit by Player \"(.*)\" \(id=(.*) pos=<(.*)>\) into (.*) for (.*) damage \((.*)\) with (.*) from (.*) meters /g;
|
||||
@@ -115,14 +115,14 @@ module.exports = {
|
||||
let newBank = new User();
|
||||
newBank.createUser(killerStat.discordID, guildId, guild.startingBalance);
|
||||
newBank.save().catch(err => {
|
||||
if (err) return client.sendInternalError(interaction, err);
|
||||
if (err) return client.sendError(client.GetChannel(guild.killfeedChannel), err);
|
||||
});
|
||||
|
||||
} else banking = banking.user;
|
||||
|
||||
if (!client.exists(banking.guilds[guildId])) {
|
||||
const success = addUser(banking.guilds, guildId, killer.discordID, this, guild.startingBalance);
|
||||
if (!success) return client.sendError(guild.connectionLogsChannel, 'Failed to add bank');
|
||||
if (!success) return client.sendError(client.GetChannel(guild.killfeedChannel), 'Automatic Bounty Payout: Failed to add bank to database.');
|
||||
}
|
||||
|
||||
const newBalance = banking.guilds[guildId].balance + totalBounty;
|
||||
@@ -132,7 +132,7 @@ module.exports = {
|
||||
[`user.guilds.${guildId}.balance`]: newBalance,
|
||||
}
|
||||
}, function(err, res) {
|
||||
if (err) return client.sendError(guild.connectionLogsChannel, err);
|
||||
if (err) return client.sendError(client.GetChannel(guild.killfeedChannel), `Killfeed Error: Updating killer bank balance\n${err}`);
|
||||
});
|
||||
|
||||
receivedBounty = new EmbedBuilder()
|
||||
|
||||
+2
-2
@@ -197,7 +197,7 @@ module.exports = {
|
||||
if (!client.exists(guild.playerstats)) guild.playerstats = [];
|
||||
if (!client.exists(guild.activePlayersChannel)) return;
|
||||
|
||||
const channel = client.channels.cache.get(guild.activePlayersChannel);
|
||||
const channel = client.GetChannel(guild.activePlayersChannel);
|
||||
let activePlayers = guild.playerstats.filter(p => p.connected == true);
|
||||
|
||||
let des = ``;
|
||||
@@ -223,7 +223,7 @@ module.exports = {
|
||||
|
||||
return channel.send({ embeds: [PlayersEmbed, activePlayersEmbed] }).then(sentMessage => {
|
||||
setTimeout(() => {
|
||||
sentMessage.delete().catch(error => client.sendError(channel, error));
|
||||
sentMessage.delete().catch(error => client.sendError(channel, `HandleActivePlayersList Error: \n${error}`));
|
||||
}, 360000);
|
||||
});
|
||||
}
|
||||
|
||||
+1
-4
@@ -39,10 +39,7 @@ module.exports = {
|
||||
let bans = res.data.gameserver.settings.general.bans;
|
||||
if (ban) bans += `\r\n${gamertag}`;
|
||||
else if (!ban) bans = bans.replace(gamertag, '');
|
||||
else {
|
||||
client.error("Incorrect Ban Option: HandlePlayerBan")
|
||||
throw "Incorrect Ban Option: HandlePlayerBan"
|
||||
}
|
||||
else client.error("Incorrect Ban Option: HandlePlayerBan");
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("category", "general");
|
||||
|
||||
@@ -5,7 +5,7 @@ const { REST } = require('@discordjs/rest');
|
||||
|
||||
/**
|
||||
* Register slash commands for a guild
|
||||
* @param {require("../structures/QuarksBot")} client
|
||||
* @param {require("../structures/DayzRBot")} client
|
||||
*/
|
||||
module.exports = {
|
||||
// Register guild commands
|
||||
|
||||
Reference in new issue
Block a user