almost mvp
This commit is contained in:
0
PRIVATEPOLICY.md
Normal file
0
PRIVATEPOLICY.md
Normal file
@@ -4,7 +4,9 @@
|
|||||||
"description": "A discord bot intended to complete the audit log",
|
"description": "A discord bot intended to complete the audit log",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"development": "nodemon",
|
||||||
|
"run": "node index.js",
|
||||||
|
"deploypm2": "pm2 start index.js --name \"logori\""
|
||||||
},
|
},
|
||||||
"author": "Alejandro W. Sior, Ben Kyd <benjaminkyd@gmail.com> (https://benkyd.co.uk)",
|
"author": "Alejandro W. Sior, Ben Kyd <benjaminkyd@gmail.com> (https://benkyd.co.uk)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
0
scripts/deploy2.0.js
Normal file
0
scripts/deploy2.0.js
Normal file
@@ -1,5 +1,10 @@
|
|||||||
const OffensiveWordsList = require('./ajds-wordslist.js').BlackList;
|
const OffensiveWordsList = require('./ajds-wordslist.js').BlackList;
|
||||||
|
|
||||||
|
// AJDS stands for the Automated James Defense System
|
||||||
|
// or the Anti James Defense System
|
||||||
|
// first conseptualised by UDXS and Ben at
|
||||||
|
// https://github.com/terminal-atomics/ajds
|
||||||
|
|
||||||
module.exports.ScoreMember = async function(erismember)
|
module.exports.ScoreMember = async function(erismember)
|
||||||
{
|
{
|
||||||
// Higher score = higher trust factor
|
// Higher score = higher trust factor
|
||||||
|
|||||||
@@ -88,6 +88,15 @@ module.exports.FetchGuild = async function(id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports.UpdateGuildName = async function(id, name)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
await Guild.update({name: name}, {where: {id: id}});
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports.UpdateGuildPrefix = async function(id, prefix)
|
module.exports.UpdateGuildPrefix = async function(id, prefix)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ module.exports.registerCommands = async function()
|
|||||||
|
|
||||||
Commands['initserv'] = { command: 'initserv', alias: 'nil', name: 'Initialize Server', desc: 'Initialises a new Guild', callback: InitializeGuild, adminOnly: true };
|
Commands['initserv'] = { command: 'initserv', alias: 'nil', name: 'Initialize Server', desc: 'Initialises a new Guild', callback: InitializeGuild, adminOnly: true };
|
||||||
Commands['setprefix'] = { command: 'setprefix', alias: 'prefix', name: 'Set Prefix', desc: 'Sets the servers prefix for the guild', callback: SetPrefix, adminOnly: true };
|
Commands['setprefix'] = { command: 'setprefix', alias: 'prefix', name: 'Set Prefix', desc: 'Sets the servers prefix for the guild', callback: SetPrefix, adminOnly: true };
|
||||||
Commands['setlogchannel'] = { command: 'setlogchannel', alias: 'log', name: 'Set Log Channel', desc: 'Sets the guild log channel to the current channel', callback: SetLogChannel, adminOnly: true };
|
Commands['setfallbackchannel'] = { command: 'setlogchannel', alias: 'setlogchannel', name: 'Set Log Channel', desc: 'Sets the guild log channel to the current channel', callback: SetLogChannel, adminOnly: true };
|
||||||
|
|
||||||
// create a cache of prefix's so that the database doesn't have to be
|
// create a cache of prefix's so that the database doesn't have to be
|
||||||
// queried every single time, new guilds should also add themselve's
|
// queried every single time, new guilds should also add themselve's
|
||||||
@@ -108,6 +108,7 @@ module.exports.newMessage = async function(message)
|
|||||||
|
|
||||||
async function InitializeGuild(message, args)
|
async function InitializeGuild(message, args)
|
||||||
{
|
{
|
||||||
|
// Outlines private policy etc
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -166,12 +166,19 @@ function ColourConvert(colour)
|
|||||||
|
|
||||||
async function GuildCreate(guild)
|
async function GuildCreate(guild)
|
||||||
{
|
{
|
||||||
|
const AlreadyGuild = await Database.FetchGuild(guild.id);
|
||||||
|
if (AlreadyGuild == -1)
|
||||||
|
{
|
||||||
|
Database.NewGuild(guild.id, guild.name, '*', -1, {}, 0);
|
||||||
|
} else {
|
||||||
|
if (AlreadyGuild.name == guild.name) return;
|
||||||
|
Database.UpdateGuildName(guild.id, guild.name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function GuildDelete(guild)
|
async function GuildDelete(guild)
|
||||||
{
|
{
|
||||||
|
// TODO: innactive guild tags in the database
|
||||||
}
|
}
|
||||||
|
|
||||||
async function Warn(message, id)
|
async function Warn(message, id)
|
||||||
@@ -588,33 +595,35 @@ 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;
|
||||||
|
|
||||||
const LastAuditEntry = (await message.channel.guild.getAuditLogs(1)).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();
|
||||||
Logger.debug(JSON.stringify(DeletedMessage, null, 4))
|
|
||||||
|
|
||||||
let embed = new DiscordEmbed({
|
// console.log(JSON.stringify(DeletedMessage, null, 4))
|
||||||
title: LastAuditEntry.actionType == MESSAGE_DELETE ? 'Message Deleted' : 'User Deleted Own Message',
|
|
||||||
colour: ColourConvert('#E0532B'),
|
try {
|
||||||
url: 'https://logori.xyz',
|
var embed = new DiscordEmbed({
|
||||||
timestamp: new Date(),
|
author: {
|
||||||
footer: { text: `ID: ${message.id}` }
|
name: `${DeletedMessage.author.username}#${DeletedMessage.author.discriminator}`,
|
||||||
});
|
icon_url: DeletedMessage.author.avatarURL,
|
||||||
|
url: 'https://logori.xyz'
|
||||||
|
},
|
||||||
|
title: 'Message Deleted',
|
||||||
|
colour: ColourConvert('#E0532B'),
|
||||||
|
url: 'https://logori.xyz',
|
||||||
|
timestamp: new Date(),
|
||||||
|
footer: { text: `ID: ${message.id}` }
|
||||||
|
});
|
||||||
|
|
||||||
// user DIDDNT deleted own message
|
|
||||||
if (LastAuditEntry.actionType == MESSAGE_DELETE)
|
|
||||||
{
|
|
||||||
embed.field('', `**Message Owner:** ${DeletedMessage.author.mention}
|
embed.field('', `**Message Owner:** ${DeletedMessage.author.mention}
|
||||||
**Responsible Moderator**: ${LastAuditEntry.user.mention}
|
**Responsible Moderator**: ${LastAuditEntry.user.mention}
|
||||||
**Channel:** ${message.channel.mention}
|
**Channel:** ${message.channel.mention}
|
||||||
**Message Content:** ${DeletedMessage.content} `);
|
**Message Content:** ${DeletedMessage.content} `);
|
||||||
} else
|
} catch (e)
|
||||||
{
|
{
|
||||||
embed.field('', `**Message Owner:** ${DeletedMessage.author.mention}
|
Logger.warn('The stupid messagedelete function messed up again');
|
||||||
**Channel:** ${message.channel.mention}
|
|
||||||
**Message Content:** ${DeletedMessage.content} `);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Discord.bot.createMessage(FallbackChannel, { embed: embed.sendable });
|
Discord.bot.createMessage(FallbackChannel, { embed: embed.sendable });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -622,4 +631,26 @@ async function MessageUpdate(message, oldmessage)
|
|||||||
{
|
{
|
||||||
const FallbackChannel = await GetLogChannel(message.channel.guild.id);
|
const FallbackChannel = await GetLogChannel(message.channel.guild.id);
|
||||||
if (FallbackChannel == -1) return;
|
if (FallbackChannel == -1) return;
|
||||||
|
|
||||||
|
if (!message || !oldmessage) return;
|
||||||
|
if (message.content == oldmessage.content) return;
|
||||||
|
|
||||||
|
let embed = new DiscordEmbed({
|
||||||
|
author: {
|
||||||
|
name: `${message.author.username}#${message.author.discriminator}`,
|
||||||
|
icon_url: message.author.avatarURL,
|
||||||
|
url: 'https://logori.xyz'
|
||||||
|
},
|
||||||
|
title: 'Message Edited',
|
||||||
|
colour: ColourConvert('#328FA8'),
|
||||||
|
url: 'https://logori.xyz',
|
||||||
|
timestamp: new Date(),
|
||||||
|
footer: { text: `ID: ${message.id}` }
|
||||||
|
});
|
||||||
|
|
||||||
|
embed.field('', `**Message Owner:** ${message.author.mention}
|
||||||
|
**Old Message:**: ${oldmessage.content}
|
||||||
|
**New Message:**: ${message.content}`);
|
||||||
|
|
||||||
|
Discord.bot.createMessage(FallbackChannel, { embed: embed.sendable });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user