fixed the fallback channel setting

This commit is contained in:
Ben
2020-08-06 17:19:26 +01:00
parent 5262a5b13e
commit c7c709d516
5 changed files with 24 additions and 12 deletions

1
legacy/config.json Normal file
View File

@@ -0,0 +1 @@
{"token":"YOUR BOT TOKEN HERE","game":"BOT GAME HERE","owner":"BOT OWNER ID HERE","hastebinServer":"https://hastebin.com"}

View File

@@ -14,6 +14,7 @@
"colors": "^1.4.0", "colors": "^1.4.0",
"dotenv": "^8.2.0", "dotenv": "^8.2.0",
"eris": "^0.13.3", "eris": "^0.13.3",
"express-authentication": "^0.3.2",
"moment": "^2.27.0", "moment": "^2.27.0",
"sequelize": "^6.3.3", "sequelize": "^6.3.3",
"sqlite3": "^5.0.0" "sqlite3": "^5.0.0"

View File

@@ -151,7 +151,18 @@ async function SetPrefix(message, args)
async function SetLogChannel(message, args) async function SetLogChannel(message, args)
{ {
const AlreadyGuild = await Database.FetchGuild(message.guildID);
const guild = await Discord.bot.getRESTGuild(message.guildID);
if (AlreadyGuild == -1)
{
Database.NewGuild(guild.id, guild.name, '*', message.channel.id, {}, 0);
} else {
if (AlreadyGuild.name != guild.name)
{
Database.UpdateGuildName(guild.id, message.guild.name);
}
Database.UpdateGuildLogChannel(guild.id, message.channel.id); Database.UpdateGuildLogChannel(guild.id, message.channel.id);
}
DiscordHelpers.SendMessageSafe(message.channel.id, 'Logging fallback channel set to this channel'); DiscordHelpers.SendMessageSafe(message.channel.id, 'Logging fallback channel set to this channel');
} }

View File

@@ -606,27 +606,25 @@ async function GuildMemberRemove(guild, member)
DiscordHelpers.SendMessageSafe(FallbackChannel, { embed: embed.sendable }); DiscordHelpers.SendMessageSafe(FallbackChannel, { embed: embed.sendable });
} }
// FIXME: this is broken af lmao
async function MessageDelete(message) async function MessageDelete(message)
{ {
const FallbackChannel = await GetLogChannel(message.channel.guild.id); const FallbackChannel = await GetLogChannel(message.channel.guild.id);
if (FallbackChannel == -1) return; if (FallbackChannel == -1) return;
/*
* IMPORTANT(aosync): Check if audit log entry is recent enough. Because it might cause it to use an entry for a previous action. // FIXME: Check if audit log entry is recent enough. Because it might cause it to use an entry for a previous action.
* When this is implemented, we'll just have to assume deleter is author when no recent enough entry is found. // When this is implemented, we'll just have to assume deleter is author when no recent enough entry is found.
*/
const LastAuditEntry = (await message.channel.guild.getAuditLogs(1, undefined, MESSAGE_DELETE)).entries[0]; const LastAuditEntry = (await message.channel.guild.getAuditLogs(1, undefined, MESSAGE_DELETE)).entries[0];
const DeletedMessage = LastAuditEntry.channel.messages.random(); const DeletedMessage = LastAuditEntry.channel.messages.random();
try { try {
var authorMention = 'Author not found'; let authorMention = 'Author not found';
var author = { let author = {
name: 'Unknown', name: 'Unknown',
url: 'https://logori.xyz' url: 'https://logori.xyz'
} }
var responsible = LastAuditEntry ? LastAuditEntry.user.mention : 'Message author'; let responsible = LastAuditEntry ? LastAuditEntry.user.mention : 'Message author';
if (message.author) { if (message.author) {
author.name = message.author.username; author.name = message.author.username;
author.icon_url = message.author.avatarURL; author.icon_url = message.author.avatarURL;
@@ -639,7 +637,7 @@ async function MessageDelete(message)
// Left blank because currently inaccurate. When the IMPORTANT comment is achieved, the above lines can be uncommented. // Left blank because currently inaccurate. When the IMPORTANT comment is achieved, the above lines can be uncommented.
} }
var embed = new DiscordEmbed({ let embed = new DiscordEmbed({
author: author, author: author,
title: 'Message Deleted', title: 'Message Deleted',
colour: ColourConvert('#E0532B'), colour: ColourConvert('#E0532B'),

View File

@@ -16,7 +16,8 @@ module.exports.GetMemberJoinPos = (memberid, guild) =>
} }
module.exports.SendMessageSafe = async (channelid, message) => module.exports.SendMessageSafe = async (channelid, message) =>
{ {
// TODO: make this an actual check instead of a guess // TODO: make this an actual check instead of a guess & catch lol
try { try {
Discord.bot.createMessage(channelid, message); Discord.bot.createMessage(channelid, message);
} catch (e) } catch (e)