Merge remote-tracking branch 'Shasha/Rina'

This commit is contained in:
Neko Life 2021-05-28 23:43:56 +00:00
commit 6c98809ffe
20 changed files with 293 additions and 236 deletions

2
.gitignore vendored
View file

@ -120,5 +120,3 @@ dist
.yarn/build-state.yml .yarn/build-state.yml
.yarn/install-state.gz .yarn/install-state.gz
.pnp.* .pnp.*
settings.sqlite3
settings.sqlite3

18
Main.js
View file

@ -1,5 +1,7 @@
'use strict'; 'use strict';
require("./database/mongo");
require("./resources/structures");
const Commando = require('@iceprod/discord.js-commando'); const Commando = require('@iceprod/discord.js-commando');
const client = new Commando.Client({ const client = new Commando.Client({
owner: ['820696421912412191', '750335181285490760'], owner: ['820696421912412191', '750335181285490760'],
@ -10,7 +12,7 @@ let configFile = require('./config.json');
const { errLog, trySend } = require('./resources/functions'); const { errLog, trySend } = require('./resources/functions');
const { join } = require('path'); const { join } = require('path');
const { chatAnswer } = require("./resources/shaChat"); const { chatAnswer } = require("./resources/shaChat");
require("./database/mongo"); const { timestampAt } = require("./resources/debug");
client.registry client.registry
.registerGroups([ .registerGroups([
@ -32,8 +34,6 @@ client.setProvider(
const guildLog = "840154722434154496"; const guildLog = "840154722434154496";
let shaGuild;
client.on('ready', async () => { client.on('ready', async () => {
//shaGuild = client.guilds.cache.map(g => g); //shaGuild = client.guilds.cache.map(g => g);
//console.log(`Member in ${shaGuild.length} guilds.`); //console.log(`Member in ${shaGuild.length} guilds.`);
@ -41,6 +41,12 @@ client.on('ready', async () => {
}); });
client.on("message", async msg => { client.on("message", async msg => {
if (msg.guild?.dbLoaded === false && !msg.author.bot) {
await msg.guild.dbLoad();
}
if (msg.author.dbLoaded === false && !msg.author.bot) {
await msg.author.dbLoad();
}
if (msg.channel.id === "837178237322919966" && !msg.author.bot && !msg.content.toLowerCase().startsWith(client.commandPrefix+"chat")) { if (msg.channel.id === "837178237322919966" && !msg.author.bot && !msg.content.toLowerCase().startsWith(client.commandPrefix+"chat")) {
chatAnswer(client, msg); chatAnswer(client, msg);
} }
@ -55,12 +61,12 @@ client.on("guildMemberRemove", memberLeave => {
}); });
client.on("guildCreate", newShaGuild => { client.on("guildCreate", newShaGuild => {
shaGuild = client.guilds.cache.map(g => g); const shaGuild = client.guilds.cache.map(g => g);
trySend(client, guildLog, `Joined **${newShaGuild.name}** (${newShaGuild.id}) <:awamazedLife:795227334339985418> I'm in ${shaGuild.length} servers now.`); trySend(client, guildLog, `Joined **${newShaGuild.name}** (${newShaGuild.id}) <:awamazedLife:795227334339985418> I'm in ${shaGuild.length} servers now.`);
}); });
client.on("guildDelete", leaveShaGuild => { client.on("guildDelete", leaveShaGuild => {
shaGuild = client.guilds.cache.map(g => g); const shaGuild = client.guilds.cache.map(g => g);
trySend(client, guildLog, `Left **${leaveShaGuild.name}** (${leaveShaGuild.id}) <:WhenLife:773061840351657984> I'm in ${shaGuild.length} servers now.`); trySend(client, guildLog, `Left **${leaveShaGuild.name}** (${leaveShaGuild.id}) <:WhenLife:773061840351657984> I'm in ${shaGuild.length} servers now.`);
}); });
@ -72,6 +78,6 @@ process.on("uncaughtException", e => errLog(e, null, client));
process.on("unhandledRejection", e => errLog(e, null, client)); process.on("unhandledRejection", e => errLog(e, null, client));
process.on("warning", e => errLog(e, null, client)); process.on("warning", e => errLog(e, null, client));
// client.on("debug", (...args) => console.log(...args)); //client.on("debug", (...args) => console.log(...args, timestampAt()));
client.login(configFile.token); client.login(configFile.token);

View file

@ -2,7 +2,7 @@
const commando = require("@iceprod/discord.js-commando"); const commando = require("@iceprod/discord.js-commando");
const { MessageEmbed } = require("discord.js"); const { MessageEmbed } = require("discord.js");
const { ranLog, errLog, trySend, findMemberRegEx, multipleMembersFound, cleanMentionID } = require("../../resources/functions"); const { ranLog, errLog, trySend, findMemberRegEx, multipleMembersFound, cleanMentionID, tryReact } = require("../../resources/functions");
const { database } = require("../../database/mongo"); const { database } = require("../../database/mongo");
const { randomColors } = require("../../config.json"); const { randomColors } = require("../../config.json");
@ -24,7 +24,7 @@ module.exports = class avatar extends commando.Command {
errLog(docErr, msg, this.client); errLog(docErr, msg, this.client);
} }
const footerQuote = r?.["settings"]?.defaultEmbed?.footerQuote; const footerQuote = r?.["settings"]?.defaultEmbed?.footerQuote;
const args = arg.trim().split(/(?<!\\),+/); const args = arg.trim().split(/(?<!\\),+(?!\d*})/);
const option = arg.trim().split(/(?<!\\)(\-\-)+/); const option = arg.trim().split(/(?<!\\)(\-\-)+/);
let user, avatar, member, show, notFound = ""; let user, avatar, member, show, notFound = "";
let [allEmb, multipleMemMes, dupliCheck] = [[], [], []]; let [allEmb, multipleMemMes, dupliCheck] = [[], [], []];
@ -36,7 +36,7 @@ module.exports = class avatar extends commando.Command {
if (msg.guild ? !msg.guild.member(msg.author).hasPermission("MANAGE_MESSAGES") : false) { if (msg.guild ? !msg.guild.member(msg.author).hasPermission("MANAGE_MESSAGES") : false) {
onceOnly = true; onceOnly = true;
if (args.length > 1) { if (args.length > 1) {
trySend(this.client, msg, "Manage messages permission required to show two or more avatar at once!"); tryReact(msg, "cathmmLife:772716381874946068");
} }
} }
for (const ops of option) { for (const ops of option) {
@ -136,47 +136,4 @@ module.exports = class avatar extends commando.Command {
return ranLog(msg,'avatar',arg); return ranLog(msg,'avatar',arg);
}); });
} }
}; };
// Old codes
/*args = args.split(/ +/);
try {
let member;
let avUrl;
let avatar = new MessageEmbed();
if (args[0]) {
member = await getUser(this.client, args[0]);
}
if (!args[0]) {
avUrl = msg.author.displayAvatarURL({size:4096,dynamic:true});
avatar
.setColor(msg.member.displayColor)
.setTitle(msg.member.displayName);
} else
if (member) {
avUrl = member.displayAvatarURL({size:4096,dynamic:true});
try {
avatar.setColor(msg.guild.member(member).displayColor);
} catch (e) {errLog(e)}
try {
avatar
.setTitle(msg.guild.member(member).displayName);
} catch (e) {
errLog(e);
avatar
.setTitle(member.username);
}
}
if (!avUrl) {
return msg.channel.send('Who is that? I dunno them!');
}
avatar
//.setAuthor(msg.author.username, msg.author.displayAvatarURL({size:4096, dynamic:true}))
.setImage(avUrl)
.setFooter(footerQuote);
msg.channel.send(avatar);
return ranLog(msg,'avatar', `${member ? `Avatar of ${member.tag} (${member.id}): ` : `Self avatar: `} ${avUrl}`);
} catch (e) {
await msg.channel.send('Who is that? I dunno them!');
return errLog(e);
}*/

View file

@ -4,11 +4,11 @@ const commando = require("@iceprod/discord.js-commando");
const { MessageEmbed } = require("discord.js"); const { MessageEmbed } = require("discord.js");
const { getChannelMessage, errLog, ranLog, trySend, tryReact } = require("../../resources/functions"); const { getChannelMessage, errLog, ranLog, trySend, tryReact } = require("../../resources/functions");
module.exports = class clonemb extends commando.Command { module.exports = class cloneembed extends commando.Command {
constructor(client) { constructor(client) {
super(client, { super(client, {
name: "clonemb", name: "clone-embed",
aliases: ["cloneemb","cloneembed", "clonembed"], aliases: ["clone-emb","clon-emb", "clon-embed"],
memberName: "clonemb", memberName: "clonemb",
group: "utility", group: "utility",
description: "Clone an Embed." description: "Clone an Embed."
@ -16,7 +16,6 @@ module.exports = class clonemb extends commando.Command {
} }
async run(msg, cargs) { async run(msg, cargs) {
const args = cargs.trim().split(/ +/); const args = cargs.trim().split(/ +/);
const {defaultErrorLogChannel} = require("../../config.json");
try { try {
const theMes = await getChannelMessage(this.client,msg,args[0],args[1]); const theMes = await getChannelMessage(this.client,msg,args[0],args[1]);
let content; let content;
@ -24,10 +23,10 @@ module.exports = class clonemb extends commando.Command {
content = theMes.content; content = theMes.content;
} }
if (!theMes.embeds || (theMes.embeds).length === 0) { if (!theMes.embeds || (theMes.embeds).length === 0) {
return trySend(this.client, msg, 'No embed found.'); return trySend(this.client, msg, 'ypu don\'t know what an embed is? <:cathmmLife:772716381874946068>');
} }
if (!args[0]) { if (!args[0]) {
return trySend(this.client, msg, 'Which embed??'); return trySend(this.client, msg, 'Which message??');
} }
trySend(this.client, msg, {content:content,embed:theMes.embeds[0]}); trySend(this.client, msg, {content:content,embed:theMes.embeds[0]});
const moreEmb = theMes.embeds.slice(1); const moreEmb = theMes.embeds.slice(1);
@ -37,14 +36,7 @@ module.exports = class clonemb extends commando.Command {
tryReact(msg, "a:yesLife:794788847996370945"); tryReact(msg, "a:yesLife:794788847996370945");
return ranLog(msg,'clonemb',`Embed ${theMes.url} (${theMes.id}) in ${theMes.channel.name} (${theMes.channel.id}) of ${theMes.guild.name} cloned.`); return ranLog(msg,'clonemb',`Embed ${theMes.url} (${theMes.id}) in ${theMes.channel.name} (${theMes.channel.id}) of ${theMes.guild.name} cloned.`);
} catch (e) { } catch (e) {
return errLog( return trySend(this.client, msg, "No embed found. Use `<channel_[mention, ID]> <message_ID>` if it's in another channel.");
e,
msg,
this.client,
false,
"No embed found. Use `<channel_[mention, ID]> <message_ID>` if it's in another channel.",
true
);
} }
} }
}; };

View file

@ -2,7 +2,7 @@
const commando = require("@iceprod/discord.js-commando"); const commando = require("@iceprod/discord.js-commando");
const { MessageEmbed } = require("discord.js"); const { MessageEmbed } = require("discord.js");
const { ranLog, errLog, getChannelMessage, noPerm, tryReact } = require("../../resources/functions"); const { ranLog, errLog, getChannelMessage, noPerm, tryReact, findChannelRegEx, trySend, cleanMentionID } = require("../../resources/functions");
const getColor = require("../../resources/getColor"); const getColor = require("../../resources/getColor");
module.exports = class embmaker extends commando.Command { module.exports = class embmaker extends commando.Command {
@ -18,15 +18,24 @@ module.exports = class embmaker extends commando.Command {
hidden:false hidden:false
}); });
} }
/**
*
* @param {commando.CommandoMessage} msg
* @param {*} arg
* @returns
*/
async run(msg, arg) { async run(msg, arg) {
const args = arg.trim().split(/(?<!\\)(\-\-)+/); const args = arg.trim().split(/(?<!\\)(\-\-)+/);
let embed = new MessageEmbed(); let embed = new MessageEmbed();
let autName, footertext, autIcon, autUrl, footericon, content, channel, editSrc, newAttach = []; let autName, footertext, autIcon, autUrl, footericon, content, channel, editSrc, newAttach = [], reportMessage = "";
try { try {
for(const value of args) { for(const value of args) {
if (value.toLowerCase().startsWith("json")) {
embed = new MessageEmbed(JSON.parse(value.slice("json".length).trim()));
}
if (value.toLowerCase().startsWith('edit')) { if (value.toLowerCase().startsWith('edit')) {
const editArg = value.slice('edit'.length).trim().split(/ +/); const editArg = value.slice('edit'.length).trim().split(/ +/);
if (editArg) { if (editArg[0].length > 0) {
editSrc = await getChannelMessage(this.client, msg, editArg[0], editArg[1]); editSrc = await getChannelMessage(this.client, msg, editArg[0], editArg[1]);
if (editSrc) { if (editSrc) {
const editEmb = editSrc.embeds[0]; const editEmb = editSrc.embeds[0];
@ -54,17 +63,23 @@ module.exports = class embmaker extends commando.Command {
footericon = editEmb.footer.iconURL; footericon = editEmb.footer.iconURL;
} }
} }
} else {
reportMessage += "**[EDIT]** No editable embed found.\n";
} }
} else {
reportMessage += "**[EDIT]** Unknown message.\n";
} }
} else {
reportMessage += "**[EDIT]** No argument provided.\n";
} }
} }
if (value.toLowerCase().startsWith('quote')) { if (value.toLowerCase().startsWith('quote')) {
const quoteargs = value.slice('quote'.length).toLowerCase().trim().split(/ +/); const quoteargs = value.slice('quote'.length).toLowerCase().trim().split(/ +/);
if (quoteargs) { if (quoteargs[0].length > 0) {
await getChannelMessage(this.client, msg, quoteargs[0], quoteargs[1]) await getChannelMessage(this.client, msg, quoteargs[0], quoteargs[1])
.then(quoteThis => { .then(quoteThis => {
if (quoteThis) { if (quoteThis) {
const author = quoteThis.guild.member(quoteThis.author); const author = quoteThis.member;
autName = author ? author.displayName : quoteThis.author.username; autName = author ? author.displayName : quoteThis.author.username;
autIcon = quoteThis.author.displayAvatarURL({size:4096,dynamic:true}); autIcon = quoteThis.author.displayAvatarURL({size:4096,dynamic:true});
autUrl = quoteThis.url; autUrl = quoteThis.url;
@ -78,14 +93,16 @@ module.exports = class embmaker extends commando.Command {
if (quoteThis.attachments) { if (quoteThis.attachments) {
for(const attach of quoteThis.attachments) { for(const attach of quoteThis.attachments) {
attach.map(g => { attach.map(g => {
if (/^http/.test(g.proxyURL)) { newAttach.push(g.proxyURL);
newAttach.push(g.proxyURL);
}
}); });
} }
} }
} else {
reportMessage += "**[QUOTE]** Unknown message.\n";
} }
}); });
} else {
reportMessage += "**[QUOTE]** No argument provided.\n";
} }
} }
if (value.toLowerCase().startsWith('remove')) { if (value.toLowerCase().startsWith('remove')) {
@ -126,6 +143,7 @@ module.exports = class embmaker extends commando.Command {
if (/^http/.test(autVal.slice('icon'.length).trim())) { if (/^http/.test(autVal.slice('icon'.length).trim())) {
autIcon = autVal.slice('icon'.length).trim(); autIcon = autVal.slice('icon'.length).trim();
} else { } else {
reportMessage += "**[AUTHOR]** Invalid icon URL.\n";
autIcon = null; autIcon = null;
} }
} }
@ -133,6 +151,7 @@ module.exports = class embmaker extends commando.Command {
if (/^http/.test(autVal.slice('url'.length).trim())) { if (/^http/.test(autVal.slice('url'.length).trim())) {
autUrl = autVal.slice('url'.length).trim(); autUrl = autVal.slice('url'.length).trim();
} else { } else {
reportMessage += "**[AUTHOR]** Invalid URL.\n";
autUrl = null; autUrl = null;
} }
} }
@ -149,6 +168,7 @@ module.exports = class embmaker extends commando.Command {
if (/^http/.test(value.slice("image".length).trim())) { if (/^http/.test(value.slice("image".length).trim())) {
embed.setImage(value.slice("image".length).trim()); embed.setImage(value.slice("image".length).trim());
} else { } else {
reportMessage += "**[IMAGE]** Invalid URL.\n";
embed.setImage(null); embed.setImage(null);
} }
} }
@ -156,6 +176,7 @@ module.exports = class embmaker extends commando.Command {
if (/^http/.test(value.slice("thumbnail".length).trim())) { if (/^http/.test(value.slice("thumbnail".length).trim())) {
embed.setThumbnail(value.slice("thumbnail".length).trim()); embed.setThumbnail(value.slice("thumbnail".length).trim());
} else { } else {
reportMessage += "**[THUMBNAIL]** Invalid URL.\n";
embed.setThumbnail(null); embed.setThumbnail(null);
} }
} }
@ -163,6 +184,7 @@ module.exports = class embmaker extends commando.Command {
if (/^http/.test(value.slice("url".length).trim())) { if (/^http/.test(value.slice("url".length).trim())) {
embed.setURL(value.slice("url".length).trim()); embed.setURL(value.slice("url".length).trim());
} else { } else {
reportMessage += "**[URL]** Invalid URL.\n";
embed.setURL(null); embed.setURL(null);
} }
} }
@ -171,22 +193,26 @@ module.exports = class embmaker extends commando.Command {
for(const theFile of attach) { for(const theFile of attach) {
if (/^http/.test(theFile)) { if (/^http/.test(theFile)) {
newAttach.push(theFile); newAttach.push(theFile);
} else {
if (theFile.toLowerCase() !== "-copy") {
reportMessage += "**[ATTACHMENT]** Invalid URL.\n";
}
} }
if (theFile === '-copy' && editSrc) { if (theFile.toLowerCase() === '-copy' && editSrc) {
if (editSrc.attachments) { if (editSrc.attachments[0].length > 0) {
for(const attach of editSrc.attachments) { for(const attach of editSrc.attachments) {
attach.map(g => { attach.map(g => {
if (/^http/.test(g.proxyURL)) { newAttach.push(g.proxyURL);
newAttach.push(g.proxyURL);
}
}); });
} }
} else {
reportMessage += "**[ATTACHMENT]** No attachment to copy.\n";
} }
} }
} }
} }
if (value.toLowerCase().startsWith("timestamp")) { if (value.toLowerCase().startsWith("timestamp")) {
if(!/[a-zA-Z]/.test(value.slice("timestamp".length).trim())) { if(!/\D/.test(value.slice("timestamp".length).trim())) {
embed.setTimestamp(parseInt(value.slice("timestamp".length).trim(), 10)); embed.setTimestamp(parseInt(value.slice("timestamp".length).trim(), 10));
} else { } else {
if (value.slice("timestamp".length).trim().toLowerCase() === 'now') { if (value.slice("timestamp".length).trim().toLowerCase() === 'now') {
@ -195,6 +221,9 @@ module.exports = class embmaker extends commando.Command {
embed.setTimestamp(value.slice("timestamp".length).trim()); embed.setTimestamp(value.slice("timestamp".length).trim());
} }
} }
if (!embed.timestamp) {
reportMessage += "**[TIMESTAMP]** Invalid format.\n";
}
} }
if (value.toLowerCase().startsWith('footer')) { if (value.toLowerCase().startsWith('footer')) {
const footerData = value.trim().split(/( \-)+/); const footerData = value.trim().split(/( \-)+/);
@ -206,6 +235,7 @@ module.exports = class embmaker extends commando.Command {
if (/^http/.test(footval.slice('icon'.length).trim())) { if (/^http/.test(footval.slice('icon'.length).trim())) {
footericon = footval.slice('icon'.length).trim(); footericon = footval.slice('icon'.length).trim();
} else { } else {
reportMessage += "**[FOOTER]** Invalid icon URL.\n";
footericon = null; footericon = null;
} }
} }
@ -240,15 +270,23 @@ module.exports = class embmaker extends commando.Command {
content = value.slice('content'.length).trim().replace(/\\(?!\\)/g,''); content = value.slice('content'.length).trim().replace(/\\(?!\\)/g,'');
} }
if (value.toLowerCase().startsWith('channel')) { if (value.toLowerCase().startsWith('channel')) {
let ID = value.slice('channel'.length).trim(); let ID = cleanMentionID(value.slice('channel'.length).trim());
if (ID.toLowerCase() === 'here') { if (ID.toLowerCase() === 'here') {
channel = msg.channel; channel = msg.channel;
} } else {
if (ID.startsWith('<#') && ID.endsWith('>')) { if (/^\d{17,19}$/.test(ID)) {
ID = ID.slice(2, -1); channel = msg.guild.channels.cache.get(ID);
} if (!channel) {
if (!/\D/.test(ID)) { if (this.client.owners.includes(msg.author.id)) {
channel = this.client.channels.cache.get(ID); channel = this.client.channels.cache.get(ID);
}
}
} else {
channel = findChannelRegEx(msg, ID, ["category", "voice"])[0];
}
if (!channel) {
reportMessage += "**[CHANNEL]** Unknown channel.\n";
}
} }
} }
} }
@ -263,14 +301,15 @@ module.exports = class embmaker extends commando.Command {
if (autName || autIcon && embed.author !== null) { if (autName || autIcon && embed.author !== null) {
embed.setAuthor(autName,autIcon,autUrl); embed.setAuthor(autName,autIcon,autUrl);
} }
if (!footertext && footericon || !footertext && embed.timestamp) {
footertext = '';
}
if (footertext || footericon && embed.footer !== null) { if (footertext || footericon && embed.footer !== null) {
embed.setFooter(footertext,footericon); embed.setFooter(footertext,footericon);
} }
if (embed.length === 0 && (embed.thumbnail === null || embed.thumbnail.url === null) && embed.author === null && (embed.image === null || embed.image.url === null) && embed.timestamp === null) { if (embed.length === 0 && (embed.thumbnail === null || embed.thumbnail.url === null) && embed.author === null && (embed.image === null || embed.image.url === null)) {
embed.setDescription(''); if (embed.timestamp) {
embed.setFooter('');
} else {
embed.setDescription("_ _");
}
} }
if (embed.color === 16777215) { if (embed.color === 16777215) {
embed.setColor(16777214); embed.setColor(16777214);
@ -279,7 +318,10 @@ module.exports = class embmaker extends commando.Command {
embed = null; embed = null;
} }
if (newAttach.length > 0) { if (newAttach.length > 0) {
console.log("Uploading attachments..."); reportMessage += "**[ATTACHMENT]** Uploading attachments....\n";
}
if (reportMessage.length > 0) {
trySend(this.client, msg, reportMessage);
} }
if (editSrc) { if (editSrc) {
if (channel) { if (channel) {

View file

@ -34,13 +34,12 @@ module.exports = class lookup extends commando.Command {
const args = arg.split(/ +/); const args = arg.split(/ +/);
let [fetchedMember, fetchedRoles, fetchedChannels, memMes] = [[], [], [], ""]; let [fetchedMember, fetchedRoles, fetchedChannels, memMes] = [[], [], [], ""];
const lowCaseArg0 = args[0].toLowerCase(); const lowCaseArg0 = args[0].toLowerCase();
if (lowCaseArg0 === "role") { if (lowCaseArg0 === "--role") {
if (args[1]) { if (args[1]) {
const cleanRoleID = cleanMentionID(arg.slice("role".length).trim()); const cleanRoleID = cleanMentionID(arg.slice("--role".length).trim());
if (!/\D/.test(cleanRoleID)) { if (/^\d{17,19}$/.test(cleanRoleID)) {
fetchedRoles.push(msg.guild.roles.cache.get(cleanRoleID)); fetchedRoles.push(msg.guild.roles.cache.get(cleanRoleID));
} } else {
if (/\D/.test(cleanRoleID) || fetchedRoles[0] == null) {
fetchedRoles = findRoleRegEx(msg, cleanRoleID); fetchedRoles = findRoleRegEx(msg, cleanRoleID);
} }
if (fetchedRoles.length > 1) { if (fetchedRoles.length > 1) {
@ -53,13 +52,12 @@ module.exports = class lookup extends commando.Command {
} }
} }
} else { } else {
if (lowCaseArg0 === "channel") { if (lowCaseArg0 === "--channel") {
if (args[1]) { if (args[1]) {
const cleanChannelID = cleanMentionID(arg.slice("channel".length).trim()); const cleanChannelID = cleanMentionID(arg.slice("--channel".length).trim());
if (!/\D/.test(cleanChannelID)) { if (/^\d{17,19}$/.test(cleanChannelID)) {
fetchedChannels.push(msg.guild.roles.cache.get(cleanChannelID)); fetchedChannels.push(msg.guild.roles.cache.get(cleanChannelID));
} } else {
if (/\D/.test(cleanChannelID) || fetchedChannels[0] == null) {
fetchedChannels = findChannelRegEx(msg, cleanChannelID); fetchedChannels = findChannelRegEx(msg, cleanChannelID);
} }
if (fetchedChannels.length > 1) { if (fetchedChannels.length > 1) {
@ -72,10 +70,13 @@ module.exports = class lookup extends commando.Command {
} }
} }
} else { } else {
if (!/\D/.test(arg)) { if (arg.toLowerCase().startsWith("--member")) {
fetchedMember.push(msg.guild.member(arg)); arg = arg.slice("--members".length).trim();
} }
if (/\D/.test(arg) || fetchedMember[0] === null) { arg = cleanMentionID(arg);
if (/^\d{17,19}$/.test(arg)) {
fetchedMember.push(msg.guild.member(arg));
} else {
fetchedMember = findMemberRegEx(msg, arg); fetchedMember = findMemberRegEx(msg, arg);
} }
if (fetchedMember.length > 1) { if (fetchedMember.length > 1) {

View file

@ -18,7 +18,7 @@ module.exports = class mesemb extends commando.Command {
const message = await getChannelMessage(this.client,msg,args[0],args[1]); const message = await getChannelMessage(this.client,msg,args[0],args[1]);
console.log(message.embeds); console.log(message.embeds);
const mesemb = '```js\n'+JSON.stringify(message.embeds, null, 2)+'```'; const mesemb = '```js\n'+JSON.stringify(message.embeds, null, 2)+'```';
const result = await trySend(this.client, msg, {content:'Collected:'+mesemb,split:{maxLength:2000,char: ", " || ",\n" || ". " || ".\n" || "," || ".",append:',```',prepend:'```js\n'}}); const result = await trySend(this.client, msg, {content:'Collected:'+mesemb,split:{maxLength:2000,char: ",",append:',```',prepend:'```js\n'}});
return ranLog(msg,'mesemb',result.content); return ranLog(msg,'mesemb',result.content);
} catch (e) { } catch (e) {
noPerm(msg); noPerm(msg);

View file

@ -26,11 +26,11 @@ module.exports = class mesinfo extends commando.Command {
const sendMentionInfo = 'Mentions:```js\n'+JSON.stringify(mentionJSON, null, 2)+'```'; const sendMentionInfo = 'Mentions:```js\n'+JSON.stringify(mentionJSON, null, 2)+'```';
const Attachments = 'Attachments:```js\n'+JSON.stringify(message.attachments, null, 2)+'```'; const Attachments = 'Attachments:```js\n'+JSON.stringify(message.attachments, null, 2)+'```';
const sendmesinfo = mesinfo+sendMentionInfo+Attachments; const sendmesinfo = mesinfo+sendMentionInfo+Attachments;
const result1 = await trySend(this.client, msg, {content:sendmesinfo,split:{maxLength:2000,char: ", " || ",\n" || ". " || ".\n" || "," || ".",append:',```',prepend:'```js\n'}}); const result1 = await trySend(this.client, msg, {content:sendmesinfo,split:{maxLength:2000,char: ",",append:',```',prepend:'```js\n'}});
return ranLog(msg,'mesinfo',`${result1}`); return ranLog(msg,'mesinfo',`${result1}`);
} catch (e) { } catch (e) {
noPerm(msg); noPerm(msg);
return errLog(e, msg, this.client, false, "", false, defaultErrorLogChannel); return errLog(e, msg, this.client);
} }
} }
} }

View file

@ -24,7 +24,7 @@ module.exports = class newquoteotd extends commando.Command {
const quoteOTD = findDoc?.["settings"]?.quoteOTD; const quoteOTD = findDoc?.["settings"]?.quoteOTD;
const color = colorConf.randomColors; const color = colorConf.randomColors;
if (!quoteOTD || !quoteOTD.channel) { if (!quoteOTD || !quoteOTD.channel) {
return msg.channel.send(`Quote OTD channel not set! Run \`${this.client.commandPrefix}quoteotd\` to set one.`); return msg.channel.send(`Quote OTD channel not set! Run \`${msg.guild.commandPrefix}quoteotd\` to set one.`);
} }
if (!args[0]) { if (!args[0]) {
return msg.channel.send('Provide `<message_ID>`!'); return msg.channel.send('Provide `<message_ID>`!');

View file

@ -36,13 +36,13 @@ module.exports = class quoteotd extends commando.Command {
if (!this.client.channels.cache.get(data)) { if (!this.client.channels.cache.get(data)) {
return trySend(this.client, msg, 'Invalid/unknown channel provided! Try mentioning a channel or use `ChannelID`'); return trySend(this.client, msg, 'Invalid/unknown channel provided! Try mentioning a channel or use `ChannelID`');
} else { } else {
col.updateOne({document: msg.guild.id}, {$set: {"settings.quoteOTD.channel": data}}, { upsert: true }); col.updateOne({document: msg.guild.id}, {$set: {"settings.quoteOTD.channel": data}, $setOnInsert: { document: msg.guild.id }}, { upsert: true });
result = result+`Channel set to \`${this.client.channels.cache.get(data).name}\`\n`; result = result+`Channel set to \`${this.client.channels.cache.get(data).name}\`\n`;
} }
} }
if (startW.startsWith('text')) { if (startW.startsWith('text')) {
data = arr.slice('text'.length).trim(); data = arr.slice('text'.length).trim();
col.updateOne({document: msg.guild.id}, {$set: {"settings.quoteOTD.footerText": data}}, { upsert: true }); col.updateOne({document: msg.guild.id}, {$set: {"settings.quoteOTD.footerText": data}, $setOnInsert: { document: msg.guild.id }}, { upsert: true });
result = result+`Footer text set to \`${data}\`\n`; result = result+`Footer text set to \`${data}\`\n`;
} }
if (startW.startsWith('icon')) { if (startW.startsWith('icon')) {
@ -50,7 +50,7 @@ module.exports = class quoteotd extends commando.Command {
if (!/^http/.test(data)) { if (!/^http/.test(data)) {
return trySend(this.client, msg, 'Invalid icon url provided!'); return trySend(this.client, msg, 'Invalid icon url provided!');
} else { } else {
col.updateOne({document: msg.guild.id}, {$set: {"settings.quoteOTD.footerIcon": data}}, { upsert: true }); col.updateOne({document: msg.guild.id}, {$set: {"settings.quoteOTD.footerIcon": data}, $setOnInsert: { document: msg.guild.id }}, { upsert: true });
result = result+`Footer icon set!\n`; result = result+`Footer icon set!\n`;
} }
} }

View file

@ -1,6 +1,7 @@
'use strict'; 'use strict';
const commando = require("@iceprod/discord.js-commando"); const commando = require("@iceprod/discord.js-commando");
const emoteMessage = require("../../resources/emoteMessage");
const { ranLog, trySend, tryDelete } = require("../../resources/functions"); const { ranLog, trySend, tryDelete } = require("../../resources/functions");
module.exports = class say extends commando.Command { module.exports = class say extends commando.Command {
@ -17,6 +18,7 @@ module.exports = class say extends commando.Command {
if (!args) { if (!args) {
args = noArgs; args = noArgs;
} }
args = emoteMessage(this.client, args);
const sendThis = {content:args, disableMentions:"all"}; const sendThis = {content:args, disableMentions:"all"};
if (msg.member?.hasPermission("ADMINISTRATOR")) { if (msg.member?.hasPermission("ADMINISTRATOR")) {
sendThis.disableMentions = "none"; sendThis.disableMentions = "none";

View file

@ -1,6 +1,7 @@
'use strict'; 'use strict';
const commando = require("@iceprod/discord.js-commando"); const commando = require("@iceprod/discord.js-commando");
const { ranLog, errLog, trySend, sentAdCheck, tryReact } = require("../../resources/functions"); const emoteMessage = require("../../resources/emoteMessage");
const { ranLog, errLog, trySend, sentAdCheck, tryReact, findChannelRegEx, cleanMentionID } = require("../../resources/functions");
module.exports = class send extends commando.Command { module.exports = class send extends commando.Command {
constructor(client) { constructor(client) {
@ -9,36 +10,47 @@ module.exports = class send extends commando.Command {
memberName: "send", memberName: "send",
group: "utility", group: "utility",
description: "Send message to designated channel.", description: "Send message to designated channel.",
userPermissions:["MANAGE_MESSAGES"] guildOnly:true
}); });
} }
async run(msg, args ) { async run(msg, args ) {
const comarg = args.trim().split(/ +/); const comarg = args.trim().split(/ +/);
const bot = this.client;
let at = comarg[0]; let at = comarg[0];
if (!comarg[0]) { if (!comarg[0]) {
return trySend(this.client, msg, 'Where?!?'); return trySend(this.client, msg, 'Where?!?');
} }
if (comarg[0].startsWith('<#') && comarg[0].endsWith('>')) { const search = cleanMentionID(comarg[0]),
at = comarg[0].slice(2, -1); sendTheMes = emoteMessage(this.client, args.slice(comarg[0].length).trim());
let channel;
if (/^\d{17,19}$/.test(search)) {
channel = msg.guild.channels.cache.get(search);
} }
const channel = bot.channels.cache.get(at);
const sendTheMes = args.slice(comarg[0].length).trim();
if (!channel) { if (!channel) {
return trySend(this.client, msg, "Give me the right `channel_[mention, ID]` bruh"); channel = findChannelRegEx(msg, search, ["category", "voice"])[0];
if (!channel) {
if (this.client.owners.includes(msg.author)) {
channel = this.client.channels.cache.get(search);
}
if (!channel) {
return trySend(this.client, msg, "That channel is like your gf. Doesn't exist <:cathmmLife:772716381874946068>");
}
}
}
if (!channel.permissionsFor(msg.author).has("SEND_MESSAGES") || !channel.permissionsFor(msg.author).has("VIEW_CHANNEL")) {
return trySend(this.client, msg, "No <:cathmmLife:772716381874946068>");
} }
try { try {
if (sendTheMes.length === 0) { if (sendTheMes.length === 0) {
return trySend(this.client, at, `<@!${msg.author.id}> If you wanna send nothin then why you even typed that <:bruhLife:798789686242967554>`); return trySend(this.client, channel, `<@!${msg.author.id}>, If you wanna send nothin then why you even typed that <:bruhLife:798789686242967554>`);
} }
const sendThis = {content:sendTheMes, disableMentions:"all"}; const sendThis = {content:sendTheMes, disableMentions:"all"};
if (msg.member?.hasPermission("ADMINISTRATOR")) { if (msg.member?.hasPermission("MENTION_EVERYONE")) {
sendThis.disableMentions = "none"; sendThis.disableMentions = "none";
} }
const send = await trySend(this.client, channel, sendThis); const send = await trySend(this.client, channel, sendThis);
sentAdCheck(send); sentAdCheck(send);
const filter = () => true; const filter = () => true,
const collector = send.createReactionCollector(filter, {time: 15*6*1000, dispose:true}); collector = send.createReactionCollector(filter, {time: 15*6*1000, dispose:true});
collector.on('collect', r => { collector.on('collect', r => {
try { try {
msg.react(r.emoji); msg.react(r.emoji);

View file

@ -31,7 +31,7 @@ module.exports = class servav extends commando.Command {
} }
const footerQuote = res?.["settings"]?.defaultEmbed?.footerQuote; const footerQuote = res?.["settings"]?.defaultEmbed?.footerQuote;
let icon, target; let icon, target;
if (server_ID && this.client.owners.includes(msg.author.id)) { if (server_ID && this.client.owners.includes(msg.author)) {
if (!/\D/.test(server_ID)) { if (!/\D/.test(server_ID)) {
target = this.client.guilds.cache.get(server_ID); target = this.client.guilds.cache.get(server_ID);
} else { } else {

View file

@ -17,14 +17,14 @@ module.exports = class setfootq extends commando.Command {
} }
async run(msg, args) { async run(msg, args) {
try { try {
if (!msg.guild?.member(msg.author).hasPermission("MANAGE_GUILD" && !this.client.owners.includes(msg.author))) { if (msg.guild ? !msg.guild.member(msg.author).hasPermission("MANAGE_GUILD") : false && !this.client.owners.includes(msg.author)) {
return trySend(this.client, msg, 'No lol'); return trySend(this.client, msg, 'No lol');
} }
const data = msg.guild ? "Guild" : "User"; const data = msg.guild ? "Guild" : "User";
const col = database.collection(data); const col = database.collection(data);
const doc = msg.guild?.id ?? msg.author.id; const doc = msg.guild?.id ?? msg.author.id;
const oldQ = await col.findOne({document: doc}); const oldQ = await col.findOne({document: doc});
col.updateOne({document: doc}, {$set: {"settings.defaultEmbed.footerQuote": args.trim()}}, { upsert: true }, async (e) => { col.updateOne({document: doc}, {$set: {"settings.defaultEmbed.footerQuote": args.trim()}, $setOnInsert: { document: msg.guild?.id ?? msg.author.id }}, { upsert: true }, async (e) => {
if (e) { if (e) {
return errLog(e, msg, this.client); return errLog(e, msg, this.client);
} }

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const commando = require("@iceprod/discord.js-commando"); const commando = require("@iceprod/discord.js-commando");
const { getUser, errLog, ranLog, trySend } = require("../../resources/functions"); const { ranLog, trySend, cleanMentionID, findMemberRegEx } = require("../../resources/functions");
module.exports = class uinfo extends commando.Command { module.exports = class uinfo extends commando.Command {
constructor(client) { constructor(client) {
@ -12,30 +12,37 @@ module.exports = class uinfo extends commando.Command {
description: "\"Detailed\" Profile." description: "\"Detailed\" Profile."
}); });
} }
async run(msg, arg ) { async run(msg, arg) {
const args = arg.trim().split(/ +/);
try { try {
let profile; let profile;
if (args[0]) { if (arg.length > 0) {
profile = await getUser(this.client, msg, args[0]); const hmm = cleanMentionID(arg);
if (/^\d{17,19}$/.test(hmm)) {
profile = this.client.users.cache.get(hmm);
if (!profile) {
profile = await this.client.users.fetch(hmm);
}
} else {
profile = findMemberRegEx(msg, hmm)[0].user;
}
} else { } else {
profile = msg.author; profile = msg.author;
} }
const member = msg.guild.member(profile); const member = msg.guild.member(profile);
let result = 'User: '+profile.tag+'```js\n'; let result = "";
if (profile) { if (profile) {
result = result+JSON.stringify(profile, null, 2)+'```'; result += 'User: '+profile.tag+'```js\n' + JSON.stringify(profile, null, 2)+'```';
} }
if (member) { if (member) {
result = result+'As member: '+member.displayName+'```js\n'+JSON.stringify(member, null, 2)+'```'; result += 'As member: '+member.displayName+'```js\n'+JSON.stringify(member, null, 2)+'```';
if ((member.displayColor)) { if ((member.displayColor)) {
result = result+'Display color:```js\n'+member.displayColor+'```'; result += 'Display color:```js\n'+member.displayColor+'```';
} }
} }
trySend(this.client, msg, result, {split:{maxLength:2000,char: ", " || ",\n" || ". " || ".\n" || "," || ".",append:',```',prepend:'```js\n'}}); trySend(this.client, msg, result, {split:{maxLength:2000,char: ",",append:',```',prepend:'```js\n'}});
return ranLog(msg,'profile', msg.content); return ranLog(msg,'profile', msg.content);
} catch (e) { } catch (e) {
return errLog(e, msg, this.client, false, 'Gimme the right ID!', true); return trySend(this.client, msg, "404 ERROR not found~");
} }
} }
}; };

View file

@ -11,10 +11,8 @@
"fs-extra": "^9.1.0", "fs-extra": "^9.1.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"mongodb": "^3.6.6", "mongodb": "^3.6.6",
"nightmare": "^3.0.2",
"node": "^15.12.0", "node": "^15.12.0",
"node-fetch": "^2.6.1", "node-fetch": "^2.6.1",
"pup": "^0.0.2",
"puppeteer": "^9.0.0", "puppeteer": "^9.0.0",
"sqlite": "^4.0.21", "sqlite": "^4.0.21",
"sqlite3": "^5.0.2", "sqlite3": "^5.0.2",

12
resources/debug.js Normal file
View file

@ -0,0 +1,12 @@
'use strict';
function timestampAt() {
const date = new Date(),
string = date.toLocaleTimeString("UTC", {"day": "numeric", "month": "2-digit", "year": "2-digit", "hour12": true}),
ampm = string.slice(string.length - 3),
miliseconds = date.getUTCMilliseconds(),
result = string.slice(0, -3) + "." + miliseconds + ampm;
return "At: " + result;
};
module.exports = { timestampAt }

28
resources/emoteMessage.js Normal file
View file

@ -0,0 +1,28 @@
'use strict';
module.exports = function emoteMessage(client, content) {
const emotes = content.match(/:\w{1,32}:(?!\d{17,19}>)/g);
if (emotes?.length > 0) {
let theEmotes = [];
for (const emoteName of emotes) {
let findThis = emoteName.slice(1, -1);
const findEmote = client.emojis.cache.array();
let found;
for (const emote of findEmote) {
if (emote.name.toLowerCase() === findThis.toLowerCase()) {
found = emote;
break;
}
}
theEmotes.push(found);
}
if (theEmotes.length > 0) {
for (let index = 0; index < emotes.length; index++) {
if (theEmotes[index]) {
content = content.replace(emotes[index], `<${theEmotes[index].animated ? "a" : ""}:${theEmotes[index].name}:${theEmotes[index].id}>`);
}
}
}
}
return content;
}

View file

@ -3,6 +3,7 @@
const { MessageEmbed, Message, GuildMember, User, Client, GuildChannel, Role, MessageOptions, Channel } = require('discord.js'); const { MessageEmbed, Message, GuildMember, User, Client, GuildChannel, Role, MessageOptions, Channel } = require('discord.js');
const { defaultErrorLogChannel } = require("../config.json"); const { defaultErrorLogChannel } = require("../config.json");
const { database } = require("../database/mongo"); const { database } = require("../database/mongo");
const { timestampAt } = require('./debug');
const getColor = require('./getColor'); const getColor = require('./getColor');
/** /**
@ -45,8 +46,8 @@ async function errLog(theError, msg, client, sendTheError, errorMessage, notify)
if (msg && msg.guild && msg.guild.id === "823815890285756447") { if (msg && msg.guild && msg.guild.id === "823815890285756447") {
logThis = ""; logThis = "";
} }
const sendAt = await client.channels.cache.get(defaultErrorLogChannel); const sendAt = client.channels.cache.get(defaultErrorLogChannel);
sendAt.send(logThis + inLogChannel.trim(),{split:true}); sendAt.send(logThis + inLogChannel.trim() + timestampAt(),{split:true});
} catch (errmes) { } catch (errmes) {
errLog(errmes, msg); errLog(errmes, msg);
} }
@ -81,31 +82,10 @@ async function getChannelMessage(client, msg, MainID, SecondID) {
const meschannel = client.channels.cache.get(MainID); const meschannel = client.channels.cache.get(MainID);
return await meschannel.messages.fetch(SecondID); return await meschannel.messages.fetch(SecondID);
} catch (theError) { } catch (theError) {
return errLog(theError, msg, client); return
} }
} }
return await msg.channel.messages.fetch(MainID).catch(e => {return errLog(e, msg, client)}); return await msg.channel.messages.fetch(MainID).catch(e => {return});
}
/**
* Get user object
* @param {Client} client - This client (this.client)
* @param {String} MainID - User ID | User Mention
* @returns {Promise<User>} User object
* @example const user = getUser(this.client, args[0]);
*/
async function getUser(client, msg, MainID) {
if (MainID.startsWith('<') && MainID.endsWith('>')) {
MainID = MainID.slice(2, -1);
}
if (MainID.startsWith('!')) {
MainID = (MainID.slice(1));
}
try {
return await client.users.fetch(MainID);
} catch (theError) {
return errLog(theError, msg, client);
}
} }
function execCB(error, stdout, stderr) { function execCB(error, stdout, stderr) {
@ -117,7 +97,7 @@ function execCB(error, stdout, stderr) {
console.log('stderr:\n'+stderr); console.log('stderr:\n'+stderr);
} }
async function ranLog(msg, cmd, addition) { async function ranLog(msg, cmd, addition) { return /*
let errLogPath; let errLogPath;
if (msg.guild) { if (msg.guild) {
errLogPath = `../Guilds/${msg.guild.id}/Log/`; errLogPath = `../Guilds/${msg.guild.id}/Log/`;
@ -126,7 +106,7 @@ async function ranLog(msg, cmd, addition) {
} }
let add = '\n'+addition; let add = '\n'+addition;
const b = new Date().toUTCString(); const b = new Date().toUTCString();
return //console.log(inLog); return //console.log(inLog); */
} }
/** /**
@ -172,8 +152,8 @@ function multipleMembersFound(client, msg, arr, key, max = 4, withID) {
/** /**
* Get member object with RegExp * Get member object with RegExp
* @param {Message} msg * @param {Message} msg Message object of the guild being searched
* @param {String} name * @param {String} name Keyword
* @returns {GuildMember[]} Member object found * @returns {GuildMember[]} Member object found
*/ */
function findMemberRegEx(msg, name) { function findMemberRegEx(msg, name) {
@ -290,7 +270,7 @@ async function defaultImageEmbed(client, msg, author, image, title, footerText)
.setColor(msg.guild ? getColor(author?.displayColor) : randomColors[Math.floor(Math.random() * randomColors.length)]) .setColor(msg.guild ? getColor(author?.displayColor) : randomColors[Math.floor(Math.random() * randomColors.length)])
.setFooter(footerQuote); .setFooter(footerQuote);
} catch (e) { } catch (e) {
return errLog(e, msg, client, false, "", false); return errLog(e, msg, client);
} }
return emb; return emb;
} }
@ -316,18 +296,21 @@ function cleanMentionID(key) {
/** /**
* Get channel object wit RegExp * Get channel object wit RegExp
* @param {Message} msg * @param {Message} msg Message object of the guild being searched
* @param {String} name * @param {String} name Keyword
* @param {ChannelType[]} exclude Exclude channel type
* @returns {GuildChannel[]} Channels object found * @returns {GuildChannel[]} Channels object found
*/ */
function findChannelRegEx(msg, name) { function findChannelRegEx(msg, name, exclude) {
let found = []; let found = [];
const re = new RegExp(name, "i"); const re = new RegExp(name, "i");
const list = msg.guild?.channels.cache.array(); const list = msg.guild?.channels.cache.array();
if (list) { if (list) {
for(const mem of list) { for(const mem of list) {
if (re.test(mem.name)) { if (re.test(mem.name)) {
found.push(mem); if (exclude?.includes(mem.type)) {} else {
found.push(mem);
}
} }
} }
return found; return found;
@ -336,8 +319,8 @@ function findChannelRegEx(msg, name) {
/** /**
* Get role object with RegExp * Get role object with RegExp
* @param {Message} msg * @param {Message} msg Message object of the guild being searched
* @param {String} name * @param {String} name Keyword
* @returns {Role[]} Roles object found * @returns {Role[]} Roles object found
*/ */
function findRoleRegEx(msg, name) { function findRoleRegEx(msg, name) {
@ -438,7 +421,6 @@ module.exports = {
cleanMentionID, cleanMentionID,
multipleMembersFound, multipleRolesFound, multipleChannelsFound, multipleMembersFound, multipleRolesFound, multipleChannelsFound,
findMemberRegEx, findChannelRegEx, findRoleRegEx, findMemberRegEx, findChannelRegEx, findRoleRegEx,
getUser,
getChannelMessage, errLog, getChannelMessage, errLog,
execCB, ranLog, noPerm, execCB, ranLog, noPerm,
trySend, tryDelete, tryReact, trySend, tryDelete, tryReact,

View file

@ -1,70 +1,90 @@
'use strict'; 'use strict';
const { Structures } = require("discord.js"); const { Structures } = require("discord.js"),
{ database } = require("../database/mongo");
const { errLog } = require("./functions");
class Settings { Structures.extend("Guild", g => {
constructor(client, type, id) { return class Guild extends g {
this.client = client;
this.type = type;
this.id = id;
}
get(setting) {
collection(this.type).findOne({ id: this.id })[setting];
}
}
Structures.extend("Guild", Guild => {
return class GuildSettings extends Guild {
constructor(client, data) { constructor(client, data) {
super(client, data); super(client, data);
this.settings = new Settings(client, "Guild", this.id); this.dbLoaded = false;
} }
embed = { async dbLoad() {
footer: { const ret = await database.collection("Guild").findOne({document: this.id}).then((r, j) => {
text: undefined, if (j) return errLog(j, null, this.client);
icon: undefined this.infractions = r?.moderation?.infractions;
}, this.moderation = r?.moderation?.settings;
timestamp: false this.defaultEmbed = r?.settings?.defaultEmbed;
}; return this.dbLoaded = true;
moderation = { });
mute: { return ret;
role: undefined, }
duration: { /**
date: undefined, * Get user infractions
string: undefined * @param {String} get - User ID
}, * @returns {Promise<Object[]>} Infractions object
log: undefined, */
publicLog: undefined async getInfractions(get) {
}, try {
ban: { const r = await database.collection("Guild").findOne({ document: this.id });
duration: { this.infractions = r?.moderation?.infractions;
date: undefined, let found = [];
string: undefined if (this.infractions.length > 0) {
}, for (const inf of this.infractions) {
log: undefined, for (const user of inf.by) {
publicLog: undefined if (user.id === get) {
}, found.push(inf);
kick: { break;
log: undefined, }
publicLog: undefined }
} }
if (found.length > 0) {
return found;
}
}
} catch (e) { }
}
setDefaultEmbed(set) {
const ret = database.collection("Guild").updateOne({document: this.id}, {$set:{"settings.defaultEmbed": set}}, {upsert: true}, (e) => {
if (e) return errLog(e, null, this.client);
this.defaultEmbed = set;
return true;
});
return ret;
}
setModerationSettings(set) {
const ret = database.collection("Guild").updateOne({document:this.id}, {$set:{"moderation.settings": set}}, {upsert: true}, (e) => {
if (e) return errLog(e, null, this.client);
this.moderation = set;
return true;
});
return ret;
} }
} }
}); });
Structures.extend("User", User => { Structures.extend("User", u => {
return class Settings extends User { return class User extends u {
constructor(client, data) { constructor(client, data) {
super(client, data); super(client, data);
this.settings = new Settings(client, User, this.id); this.dbLoaded = false;
}
async dbLoad() {
const ret = await database.collection("User").findOne({document: this.id}).then((r, j) => {
if (j) return errLog(j, null, this.client);
this.defaultEmbed = r?.settings?.defaultEmbed;
return this.dbLoaded = true;
});
return ret;
}
setDefaultEmbed(set) {
const ret = database.collection("User").updateOne({document: this.id}, {$set:{"settings.defaultEmbed": set}}, {upsert: true}, (e) => {
if (e) return errLog(e, null, this.client);
this.defaultEmbed = set;
return true;
});
return ret;
} }
embed = {
footer: {
text: undefined,
icon: undefined
},
timestamp: false
};
} }
}); });