mirror of
https://github.com/danbulant/Shasha
synced 2026-05-24 12:22:00 +00:00
Merge branch 'main' of https://github.com/Neko-Life/Shasha into Neko-Life-main
This commit is contained in:
commit
d7b3b2bcb4
25 changed files with 512 additions and 437 deletions
22
Main.js
22
Main.js
|
|
@ -1,5 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
require("./database/mongo");
|
||||
require("./resources/structures");
|
||||
const Commando = require('@iceprod/discord.js-commando');
|
||||
const client = new Commando.Client({
|
||||
owner: ['820696421912412191', '750335181285490760'],
|
||||
|
|
@ -11,6 +13,8 @@ const { errLog, trySend } = require('./resources/functions');
|
|||
const { join } = require('path');
|
||||
// const { chatAnswer } = require("./resources/shaChat");
|
||||
require("./database/mongo");
|
||||
//const { chatAnswer } = require("./resources/shaChat");
|
||||
const { timestampAt } = require("./resources/debug");
|
||||
|
||||
client.registry
|
||||
.registerGroups([
|
||||
|
|
@ -32,8 +36,6 @@ client.setProvider(
|
|||
|
||||
const guildLog = "840154722434154496";
|
||||
|
||||
let shaGuild;
|
||||
|
||||
client.on('ready', async () => {
|
||||
//shaGuild = client.guilds.cache.map(g => g);
|
||||
//console.log(`Member in ${shaGuild.length} guilds.`);
|
||||
|
|
@ -41,13 +43,19 @@ client.on('ready', async () => {
|
|||
});
|
||||
|
||||
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")) {
|
||||
// chatAnswer(client, msg);
|
||||
}
|
||||
|
||||
if (!msg.guild) {
|
||||
//console.log(`(${msg.channel.recipient.id}) ${msg.channel.recipient.tag}: (${msg.author.id}) ${msg.author.tag}: ${msg.content}`);
|
||||
}
|
||||
console.log(`(${msg.channel.recipient.id}) ${msg.channel.recipient.tag}: (${msg.author.id}) ${msg.author.tag}: ${msg.content}`);
|
||||
} */
|
||||
});
|
||||
|
||||
client.on("guildMemberRemove", memberLeave => {
|
||||
|
|
@ -55,12 +63,12 @@ client.on("guildMemberRemove", memberLeave => {
|
|||
});
|
||||
|
||||
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.`);
|
||||
});
|
||||
|
||||
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.`);
|
||||
});
|
||||
|
||||
|
|
@ -72,6 +80,6 @@ process.on("uncaughtException", e => errLog(e, null, client));
|
|||
process.on("unhandledRejection", 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);
|
||||
|
|
@ -13,11 +13,9 @@ module.exports = class neko extends commando.Command {
|
|||
});
|
||||
}
|
||||
async run(msg) {
|
||||
const aut = msg.guild ? msg.guild.member(msg.author) : msg.author;
|
||||
const title = `${msg.guild ? aut.displayName : aut.username}! ~Nyann~ (UwU) <3`;
|
||||
const title = `${msg.guild ? msg.member.displayName : msg.author.username}! ~Nyann~ (UwU) <3`;
|
||||
const image = `https://nekos.best/nekos/${String(Math.floor(Math.random() * 314)).padStart(4, '0')}.png`;
|
||||
const emb = await defaultImageEmbed(this.client, msg, aut, image, title);
|
||||
trySend(this.client, msg, emb);
|
||||
return ranLog(msg, "neko");
|
||||
const emb = await defaultImageEmbed(msg, image, title);
|
||||
return trySend(this.client, msg, emb);
|
||||
}
|
||||
};
|
||||
|
|
@ -7,6 +7,38 @@ const col = database.collection("Guild");
|
|||
const schedule = database.collection("Schedule");
|
||||
const { scheduler } = require("../../resources/scheduler");
|
||||
|
||||
/*{
|
||||
footer: {
|
||||
text: undefined,
|
||||
icon: undefined
|
||||
},
|
||||
timestamp: false
|
||||
};
|
||||
{
|
||||
mute: {
|
||||
role: undefined,
|
||||
duration: {
|
||||
date: undefined,
|
||||
string: undefined
|
||||
},
|
||||
log: undefined,
|
||||
publicLog: undefined
|
||||
},
|
||||
ban: {
|
||||
duration: {
|
||||
date: undefined,
|
||||
string: undefined
|
||||
},
|
||||
log: undefined,
|
||||
publicLog: undefined
|
||||
},
|
||||
kick: {
|
||||
log: undefined,
|
||||
publicLog: undefined
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
module.exports = class mute extends commando.Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
|
|
@ -30,7 +62,7 @@ module.exports = class mute extends commando.Command {
|
|||
defaultDurationDoc = muteSettingsDoc?.defaultDuration,
|
||||
infractionsDoc = modDoc?.infractions,
|
||||
args = arg.trim().split(/(?<!\\)(\-\-)+/),
|
||||
mentions = args.shift().split(/(?<!\\),+/),
|
||||
mentions = args.shift().split(/(?<!\\),+(?!\d*})/),
|
||||
durationRegExp = /\d+(?![^ymwdhs])[ymwdhs]?o?/gi,
|
||||
invokedAt = msg.createdAt,
|
||||
duration = {
|
||||
|
|
@ -148,20 +180,18 @@ module.exports = class mute extends commando.Command {
|
|||
}
|
||||
const roleConfCheck = msg.guild.roles.cache.get(muteSettingsDoc?.role);
|
||||
if (!roleConfCheck && !settingUp) {
|
||||
return trySend(this.clientPermissions, msg, `No mute role configured! Run \`${this.client.commandPrefix}mute --settings <--role --<role_[name | ID]>> [--duration --<duration> | --log --<channel_[name | ID]>]\` to set it up.`);
|
||||
}
|
||||
if (duration.year > 275500) {
|
||||
duration.year = 275500;
|
||||
return trySend(this.clientPermissions, msg, `No mute role configured! Run \`${msg.guild.commandPrefix}${this.name} --settings <--role --<role_[name | ID]>> [--duration --<duration> | --log --<channel_[name | ID]>]\` to set it up.`);
|
||||
}
|
||||
let untilDate = new Date(String(duration.year), String(duration.month), String(duration.date), String(duration.hour), String(duration.minute), String(duration.second));
|
||||
if (untilDate.toUTCString() === invokedAt.toUTCString() && !settingDuration) {
|
||||
if (untilDate.toString() === "Invalid Date") untilDate = "Indefinite";
|
||||
if (untilDate?.toUTCString() === invokedAt.toUTCString() && !settingDuration) {
|
||||
if (defaultDurationDoc?.date?.valueOf() > 0) {
|
||||
untilDate = new Date(invokedAt.valueOf() + defaultDurationDoc.date.valueOf() - 1000);
|
||||
} else {
|
||||
untilDate = "Indefinite";
|
||||
}
|
||||
}
|
||||
if (untilDate !== "Indefinite") {
|
||||
}
|
||||
if (untilDate instanceof Date) {
|
||||
timeForMessage = [];
|
||||
const elapsedTime = new Date(untilDate.valueOf() - invokedAt.valueOf() + 1000),
|
||||
elapsed = [
|
||||
|
|
@ -215,7 +245,7 @@ module.exports = class mute extends commando.Command {
|
|||
defaultDurationDoc = muteSettingsDoc?.defaultDuration,
|
||||
logChannelDoc = muteSettingsDoc?.logChannel,
|
||||
roleDoc = muteSettingsDoc?.role;
|
||||
let settings = await defaultImageEmbed(this.client, msg, msg.member);
|
||||
let settings = await defaultImageEmbed(msg);
|
||||
settings
|
||||
.setTitle("Mute Configuration")
|
||||
.addField("Role", roleDoc ? "<@&"+roleDoc+">" : "Not set")
|
||||
|
|
@ -251,8 +281,8 @@ module.exports = class mute extends commando.Command {
|
|||
resultMsg += `Can't find user: **${usermention.trim()}**\n`;
|
||||
}
|
||||
} else {
|
||||
if (!settingUp && mentions.length === 1 && mentions[0].length === 0) {
|
||||
return trySend(this.client, msg, "Who do you wanna mute? Provide as first argument `<[RegExp | user_[mention | ID]]>`");
|
||||
if (!settingUp && mentions[0].length === 0) {
|
||||
return trySend(this.client, msg, "Who do you wanna mute? Provide as first argument `<[RegExp | user_[mention | ID]]>`. Use `,` to provide more than one user. Use `--` to split arguments.\nExample:```js\n" + `${msg.guild.commandPrefix}${this.name} 832423842785623423, @Shasha#1234, retard wanna get muted, #6969, ^fuck (ur)? .{5}#\\d\\d69$--69y69mo69w420d420h420m420s--Saying "joe"\`\`\``);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -281,7 +311,7 @@ module.exports = class mute extends commando.Command {
|
|||
infractionToDoc = {
|
||||
infraction: infractionCase ? infractionCase + 1 : 1,
|
||||
by: targetUser,
|
||||
moderator: `**${msg.author.tag}** <@${msg.author.id}> (${msg.author.id})`,
|
||||
moderator: msg.author,
|
||||
punishment: "mute",
|
||||
at: invokedAt,
|
||||
for: timeForMessage,
|
||||
|
|
|
|||
2
cmds/moderation/src/duration.js
Normal file
2
cmds/moderation/src/duration.js
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
'use strict';
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const commando = require("@iceprod/discord.js-commando");
|
||||
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 { randomColors } = require("../../config.json");
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ module.exports = class avatar extends commando.Command {
|
|||
errLog(docErr, msg, this.client);
|
||||
}
|
||||
const footerQuote = r?.["settings"]?.defaultEmbed?.footerQuote;
|
||||
const args = arg.trim().split(/(?<!\\),+/);
|
||||
const args = arg.trim().split(/(?<!\\),+(?!\d*})/);
|
||||
const option = arg.trim().split(/(?<!\\)(\-\-)+/);
|
||||
let user, avatar, member, show, notFound = "";
|
||||
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) {
|
||||
onceOnly = true;
|
||||
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) {
|
||||
|
|
@ -125,58 +125,16 @@ module.exports = class avatar extends commando.Command {
|
|||
}
|
||||
allEmb.push(emb);
|
||||
}
|
||||
let retSent = [];
|
||||
if (notFound.length > 0) {
|
||||
trySend(this.client, msg, notFound);
|
||||
retSent.push(notFound);
|
||||
}
|
||||
for (let index = 0; index < allEmb.length; index++) {
|
||||
const embelement = allEmb[index];
|
||||
const contelement = multipleMemMes[index];
|
||||
trySend(this.client, msg, { embed: embelement, content: contelement, split:{maxLength:2000,char: ", " || ",\n" || ". " || ".\n" || "," || ".",append:',```',prepend:'```md\n# ' }});
|
||||
retSent.push({ embed: embelement, content: contelement, split:{maxLength:2000,char: ",",append:',```',prepend:'```js' }});
|
||||
}
|
||||
return ranLog(msg,'avatar',arg);
|
||||
return retSent.map(r => trySend(this.client, msg, r));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 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);
|
||||
}*/
|
||||
};
|
||||
40
cmds/utility/cloneembed.js
Normal file
40
cmds/utility/cloneembed.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
'use strict';
|
||||
|
||||
const commando = require("@iceprod/discord.js-commando");
|
||||
const { MessageEmbed } = require("discord.js");
|
||||
const { getChannelMessage, errLog, ranLog, trySend, tryReact } = require("../../resources/functions");
|
||||
|
||||
module.exports = class cloneembed extends commando.Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: "clone-embed",
|
||||
aliases: ["clone-emb","clon-emb", "clon-embed"],
|
||||
memberName: "clonemb",
|
||||
group: "utility",
|
||||
description: "Clone an Embed."
|
||||
});
|
||||
}
|
||||
async run(msg, cargs) {
|
||||
const args = cargs.trim().split(/ +/);
|
||||
try {
|
||||
const theMes = await getChannelMessage(this.client,msg,args[0],args[1]);
|
||||
let content;
|
||||
if (theMes.content) {
|
||||
content = theMes.content;
|
||||
}
|
||||
if (!theMes.embeds || (theMes.embeds).length === 0) {
|
||||
return trySend(this.client, msg, 'ypu don\'t know what an embed is? <:cathmmLife:772716381874946068>');
|
||||
}
|
||||
if (!args[0]) {
|
||||
return trySend(this.client, msg, 'Which message??');
|
||||
}
|
||||
const sent = theMes.embeds.map(r => trySend(this.client, msg, {content:content,embed:r}));
|
||||
if (sent) {
|
||||
tryReact(msg, "a:yesLife:794788847996370945");
|
||||
}
|
||||
return sent;
|
||||
} catch (e) {
|
||||
return trySend(this.client, msg, "No embed found. Use `<channel_[mention, ID]> <message_ID>` if it's in another channel.");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
const commando = require("@iceprod/discord.js-commando");
|
||||
const { MessageEmbed } = require("discord.js");
|
||||
const { getChannelMessage, errLog, ranLog, trySend, tryReact } = require("../../resources/functions");
|
||||
|
||||
module.exports = class clonemb extends commando.Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: "clonemb",
|
||||
aliases: ["cloneemb","cloneembed", "clonembed"],
|
||||
memberName: "clonemb",
|
||||
group: "utility",
|
||||
description: "Clone an Embed."
|
||||
});
|
||||
}
|
||||
async run(msg, cargs) {
|
||||
const args = cargs.trim().split(/ +/);
|
||||
const {defaultErrorLogChannel} = require("../../config.json");
|
||||
try {
|
||||
const theMes = await getChannelMessage(this.client,msg,args[0],args[1]);
|
||||
let content;
|
||||
if (theMes.content) {
|
||||
content = theMes.content;
|
||||
}
|
||||
if (!theMes.embeds || (theMes.embeds).length === 0) {
|
||||
return trySend(this.client, msg, 'No embed found.');
|
||||
}
|
||||
if (!args[0]) {
|
||||
return trySend(this.client, msg, 'Which embed??');
|
||||
}
|
||||
trySend(this.client, msg, {content:content,embed:theMes.embeds[0]});
|
||||
const moreEmb = theMes.embeds.slice(1);
|
||||
for(const emb of moreEmb) {
|
||||
trySend(this.client, msg, new MessageEmbed(emb));
|
||||
}
|
||||
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.`);
|
||||
} catch (e) {
|
||||
return errLog(
|
||||
e,
|
||||
msg,
|
||||
this.client,
|
||||
false,
|
||||
"No embed found. Use `<channel_[mention, ID]> <message_ID>` if it's in another channel.",
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const commando = require("@iceprod/discord.js-commando");
|
||||
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");
|
||||
|
||||
module.exports = class embmaker extends commando.Command {
|
||||
|
|
@ -18,15 +18,24 @@ module.exports = class embmaker extends commando.Command {
|
|||
hidden:false
|
||||
});
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {commando.CommandoMessage} msg
|
||||
* @param {*} arg
|
||||
* @returns
|
||||
*/
|
||||
async run(msg, arg) {
|
||||
const args = arg.trim().split(/(?<!\\)(\-\-)+/);
|
||||
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 {
|
||||
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')) {
|
||||
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]);
|
||||
if (editSrc) {
|
||||
const editEmb = editSrc.embeds[0];
|
||||
|
|
@ -54,17 +63,23 @@ module.exports = class embmaker extends commando.Command {
|
|||
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')) {
|
||||
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])
|
||||
.then(quoteThis => {
|
||||
if (quoteThis) {
|
||||
const author = quoteThis.guild.member(quoteThis.author);
|
||||
const author = quoteThis.member;
|
||||
autName = author ? author.displayName : quoteThis.author.username;
|
||||
autIcon = quoteThis.author.displayAvatarURL({size:4096,dynamic:true});
|
||||
autUrl = quoteThis.url;
|
||||
|
|
@ -78,14 +93,16 @@ module.exports = class embmaker extends commando.Command {
|
|||
if (quoteThis.attachments) {
|
||||
for(const attach of quoteThis.attachments) {
|
||||
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')) {
|
||||
|
|
@ -123,16 +140,18 @@ module.exports = class embmaker extends commando.Command {
|
|||
autName = autVal.slice('name'.length).trim().replace(/\\(?!\\)/g,'');
|
||||
}
|
||||
if (autVal.toLowerCase().startsWith('icon')) {
|
||||
if (/^http/.test(autVal.slice('icon'.length).trim())) {
|
||||
if (/^https?:\/\/\w+\.\w\w/.test(autVal.slice('icon'.length).trim())) {
|
||||
autIcon = autVal.slice('icon'.length).trim();
|
||||
} else {
|
||||
reportMessage += "**[AUTHOR]** Invalid icon URL.\n";
|
||||
autIcon = null;
|
||||
}
|
||||
}
|
||||
if (autVal.toLowerCase().startsWith('url')) {
|
||||
if (/^http/.test(autVal.slice('url'.length).trim())) {
|
||||
if (/^https?:\/\/\w+\.\w\w/.test(autVal.slice('url'.length).trim())) {
|
||||
autUrl = autVal.slice('url'.length).trim();
|
||||
} else {
|
||||
reportMessage += "**[AUTHOR]** Invalid URL.\n";
|
||||
autUrl = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -146,47 +165,54 @@ module.exports = class embmaker extends commando.Command {
|
|||
}
|
||||
}
|
||||
if (value.toLowerCase().startsWith("image")) {
|
||||
if (/^http/.test(value.slice("image".length).trim())) {
|
||||
if (/^https?:\/\/\w+\.\w\w/.test(value.slice("image".length).trim())) {
|
||||
embed.setImage(value.slice("image".length).trim());
|
||||
} else {
|
||||
reportMessage += "**[IMAGE]** Invalid URL.\n";
|
||||
embed.setImage(null);
|
||||
}
|
||||
}
|
||||
if (value.toLowerCase().startsWith("thumbnail")) {
|
||||
if (/^http/.test(value.slice("thumbnail".length).trim())) {
|
||||
if (/^https?:\/\/\w+\.\w\w/.test(value.slice("thumbnail".length).trim())) {
|
||||
embed.setThumbnail(value.slice("thumbnail".length).trim());
|
||||
} else {
|
||||
reportMessage += "**[THUMBNAIL]** Invalid URL.\n";
|
||||
embed.setThumbnail(null);
|
||||
}
|
||||
}
|
||||
if (value.toLowerCase().startsWith('url')) {
|
||||
if (/^http/.test(value.slice("url".length).trim())) {
|
||||
if (/^https?:\/\/\w+\.\w\w/.test(value.slice("url".length).trim())) {
|
||||
embed.setURL(value.slice("url".length).trim());
|
||||
} else {
|
||||
reportMessage += "**[URL]** Invalid URL.\n";
|
||||
embed.setURL(null);
|
||||
}
|
||||
}
|
||||
if (value.toLowerCase().startsWith('attachment')) {
|
||||
const attach = value.slice("attachments".length).trim().split(/ +/);
|
||||
for(const theFile of attach) {
|
||||
if (/^http/.test(theFile)) {
|
||||
if (/^https?:\/\/\w+\.\w\w/.test(theFile)) {
|
||||
newAttach.push(theFile);
|
||||
} else {
|
||||
if (theFile.toLowerCase() !== "-copy") {
|
||||
reportMessage += "**[ATTACHMENT]** Invalid URL.\n";
|
||||
}
|
||||
}
|
||||
if (theFile === '-copy' && editSrc) {
|
||||
if (editSrc.attachments) {
|
||||
if (theFile.toLowerCase() === '-copy' && editSrc) {
|
||||
if (editSrc.attachments[0].length > 0) {
|
||||
for(const attach of editSrc.attachments) {
|
||||
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(!/[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));
|
||||
} else {
|
||||
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());
|
||||
}
|
||||
}
|
||||
if (!embed.timestamp) {
|
||||
reportMessage += "**[TIMESTAMP]** Invalid format.\n";
|
||||
}
|
||||
}
|
||||
if (value.toLowerCase().startsWith('footer')) {
|
||||
const footerData = value.trim().split(/( \-)+/);
|
||||
|
|
@ -203,9 +232,10 @@ module.exports = class embmaker extends commando.Command {
|
|||
footertext = footval.slice("text".length).trim().replace(/\\(?!\\)/g,'');
|
||||
}
|
||||
if (footval.toLowerCase().startsWith('icon')) {
|
||||
if (/^http/.test(footval.slice('icon'.length).trim())) {
|
||||
if (/^https?:\/\/\w+\.\w\w/.test(footval.slice('icon'.length).trim())) {
|
||||
footericon = footval.slice('icon'.length).trim();
|
||||
} else {
|
||||
reportMessage += "**[FOOTER]** Invalid icon URL.\n";
|
||||
footericon = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -240,15 +270,21 @@ module.exports = class embmaker extends commando.Command {
|
|||
content = value.slice('content'.length).trim().replace(/\\(?!\\)/g,'');
|
||||
}
|
||||
if (value.toLowerCase().startsWith('channel')) {
|
||||
let ID = value.slice('channel'.length).trim();
|
||||
let ID = cleanMentionID(value.slice('channel'.length).trim());
|
||||
if (ID.toLowerCase() === 'here') {
|
||||
channel = msg.channel;
|
||||
}
|
||||
if (ID.startsWith('<#') && ID.endsWith('>')) {
|
||||
ID = ID.slice(2, -1);
|
||||
}
|
||||
if (!/\D/.test(ID)) {
|
||||
channel = this.client.channels.cache.get(ID);
|
||||
} else {
|
||||
if (/^\d{17,19}$/.test(ID)) {
|
||||
channel = msg.guild.channels.cache.get(ID);
|
||||
if (!channel && this.client.owners.includes(msg.author.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 +299,15 @@ module.exports = class embmaker extends commando.Command {
|
|||
if (autName || autIcon && embed.author !== null) {
|
||||
embed.setAuthor(autName,autIcon,autUrl);
|
||||
}
|
||||
if (!footertext && footericon || !footertext && embed.timestamp) {
|
||||
footertext = '';
|
||||
}
|
||||
if (footertext || footericon && embed.footer !== null) {
|
||||
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) {
|
||||
embed.setDescription('');
|
||||
if (embed.length === 0 && (embed.thumbnail === null || embed.thumbnail.url === null) && embed.author === null && (embed.image === null || embed.image.url === null)) {
|
||||
if (embed.timestamp) {
|
||||
embed.setFooter('');
|
||||
} else {
|
||||
embed.setDescription("_ _");
|
||||
}
|
||||
}
|
||||
if (embed.color === 16777215) {
|
||||
embed.setColor(16777214);
|
||||
|
|
@ -279,28 +316,31 @@ module.exports = class embmaker extends commando.Command {
|
|||
embed = null;
|
||||
}
|
||||
if (newAttach.length > 0) {
|
||||
console.log("Uploading attachments...");
|
||||
reportMessage += "**[ATTACHMENT]** Uploading attachments....\n";
|
||||
}
|
||||
let sent = [];
|
||||
if (reportMessage.length > 0) {
|
||||
sent.push(trySend(this.client, msg, reportMessage));
|
||||
}
|
||||
if (editSrc) {
|
||||
if (channel) {
|
||||
channel.send({content:content,embed:embed,files:newAttach}).catch(e => noPerm(msg));
|
||||
sent.push(channel.send({content:content,embed:embed,files:newAttach}).catch(e => noPerm(msg)));
|
||||
} else {
|
||||
channel = msg.channel;
|
||||
if (editSrc.author === this.client.user) {
|
||||
try {
|
||||
editSrc.edit({content:content,embed:embed,files:newAttach}).catch(e => errLog(e, msg, this.client));
|
||||
} catch (e) {
|
||||
sent.push(editSrc.edit({content:content,embed:embed,files:newAttach}).catch(e => {
|
||||
errLog(e, msg, this.client);
|
||||
try {
|
||||
channel.send('Something\'s wrong, i can\'t edit that so here <:WhenLife:773061840351657984>');
|
||||
channel.send({content:content,embed:embed,files:newAttach});
|
||||
sent.push(channel.send('Something\'s wrong, i can\'t edit that so here <:WhenLife:773061840351657984>'));
|
||||
sent.push(channel.send({content:content,embed:embed,files:newAttach}));
|
||||
} catch (e) {
|
||||
noPerm(msg);
|
||||
}
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
try {
|
||||
channel.send('I can\'t edit that, so here <:catstareLife:794930503076675584>');
|
||||
channel.send({content:content,embed:embed,files:newAttach});
|
||||
sent.push(channel.send('I can\'t edit that, so here <:catstareLife:794930503076675584>'));
|
||||
sent.push(channel.send({content:content,embed:embed,files:newAttach}));
|
||||
} catch (e) {
|
||||
noPerm(msg);
|
||||
}
|
||||
|
|
@ -310,10 +350,13 @@ module.exports = class embmaker extends commando.Command {
|
|||
if (!channel) {
|
||||
channel = msg.channel;
|
||||
}
|
||||
channel.send({content:content,embed:embed,files:newAttach}).catch(e => noPerm(msg));
|
||||
sent.push(channel.send({content:content,embed:embed,files:newAttach}).catch(e => noPerm(msg)));
|
||||
}
|
||||
tryReact(msg, "a:yesLife:794788847996370945");
|
||||
return ranLog(msg,'embmaker',`${arg}\nContent: ${content}\nAttachments: ${newAttach}`);
|
||||
if (sent.length > 0) {
|
||||
tryReact(msg, "a:yesLife:794788847996370945");
|
||||
}
|
||||
ranLog(this.client, msg, ("```js\n" + JSON.stringify(embed, null, 2) + "```").slice(0, 2048));
|
||||
return sent;
|
||||
} catch (e) {
|
||||
return errLog(e, msg, this.client, true, "", true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ module.exports = class invite extends commando.Command {
|
|||
});
|
||||
}
|
||||
run(msg) {
|
||||
trySend(this.client, msg, "Mute me after cuz it's spam\n"+conf.invite);
|
||||
return ranLog(msg, "invite");
|
||||
return trySend(this.client, msg, "Mute me after cuz it's spam\n"+conf.invite);
|
||||
}
|
||||
};
|
||||
|
|
@ -12,12 +12,6 @@ module.exports = class lookup extends commando.Command {
|
|||
description: "Lookup something in the server using mention, ID, or RegExp."
|
||||
});
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {commando.CommandoMessage} msg
|
||||
* @param {*} arg
|
||||
* @returns
|
||||
*/
|
||||
async run(msg, arg) {
|
||||
let show;
|
||||
const showArg = arg.match(/(?<!\\)\-\-show *\d*/i);
|
||||
|
|
@ -34,13 +28,12 @@ module.exports = class lookup extends commando.Command {
|
|||
const args = arg.split(/ +/);
|
||||
let [fetchedMember, fetchedRoles, fetchedChannels, memMes] = [[], [], [], ""];
|
||||
const lowCaseArg0 = args[0].toLowerCase();
|
||||
if (lowCaseArg0 === "role") {
|
||||
if (lowCaseArg0.startsWith("--role")) {
|
||||
if (args[1]) {
|
||||
const cleanRoleID = cleanMentionID(arg.slice("role".length).trim());
|
||||
if (!/\D/.test(cleanRoleID)) {
|
||||
const cleanRoleID = cleanMentionID(arg.slice("--roles".length).trim());
|
||||
if (/^\d{17,19}$/.test(cleanRoleID)) {
|
||||
fetchedRoles.push(msg.guild.roles.cache.get(cleanRoleID));
|
||||
}
|
||||
if (/\D/.test(cleanRoleID) || fetchedRoles[0] == null) {
|
||||
} else {
|
||||
fetchedRoles = findRoleRegEx(msg, cleanRoleID);
|
||||
}
|
||||
if (fetchedRoles.length > 1) {
|
||||
|
|
@ -53,13 +46,12 @@ module.exports = class lookup extends commando.Command {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (lowCaseArg0 === "channel") {
|
||||
if (lowCaseArg0.startsWith("--channel")) {
|
||||
if (args[1]) {
|
||||
const cleanChannelID = cleanMentionID(arg.slice("channel".length).trim());
|
||||
if (!/\D/.test(cleanChannelID)) {
|
||||
const cleanChannelID = cleanMentionID(arg.slice("--channels".length).trim());
|
||||
if (/^\d{17,19}$/.test(cleanChannelID)) {
|
||||
fetchedChannels.push(msg.guild.roles.cache.get(cleanChannelID));
|
||||
}
|
||||
if (/\D/.test(cleanChannelID) || fetchedChannels[0] == null) {
|
||||
} else {
|
||||
fetchedChannels = findChannelRegEx(msg, cleanChannelID);
|
||||
}
|
||||
if (fetchedChannels.length > 1) {
|
||||
|
|
@ -72,10 +64,13 @@ module.exports = class lookup extends commando.Command {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (!/\D/.test(arg)) {
|
||||
fetchedMember.push(msg.guild.member(arg));
|
||||
if (arg.toLowerCase().startsWith("--member")) {
|
||||
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);
|
||||
}
|
||||
if (fetchedMember.length > 1) {
|
||||
|
|
@ -89,7 +84,7 @@ module.exports = class lookup extends commando.Command {
|
|||
}
|
||||
}
|
||||
if (memMes.length > 0) {
|
||||
return trySend(this.client, msg, memMes);
|
||||
return trySend(this.client, msg, { content: memMes, split: { char: ",", append: ",```", prepend: "```js", maxLength: 2000 } });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const commando = require("@iceprod/discord.js-commando");
|
||||
const { getChannelMessage, ranLog, errLog, noPerm, trySend } = require("../../resources/functions");
|
||||
const { getChannelMessage, trySend } = require("../../resources/functions");
|
||||
|
||||
module.exports = class mesemb extends commando.Command {
|
||||
constructor(client) {
|
||||
|
|
@ -13,16 +13,12 @@ module.exports = class mesemb extends commando.Command {
|
|||
});
|
||||
}
|
||||
async run(msg, arg) {
|
||||
const args = arg.trim().split(/ +/);
|
||||
try {
|
||||
const message = await getChannelMessage(this.client,msg,args[0],args[1]);
|
||||
console.log(message.embeds);
|
||||
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'}});
|
||||
return ranLog(msg,'mesemb',result.content);
|
||||
} catch (e) {
|
||||
noPerm(msg);
|
||||
return errLog(e, msg, this.client);
|
||||
}
|
||||
const args = arg.trim().split(/ +/);
|
||||
const message = await getChannelMessage(this.client,msg,args[0],args[1]);
|
||||
if (!message) {
|
||||
return trySend(this.client, msg, "404 message not found!");
|
||||
}
|
||||
const mesemb = '```js\n'+JSON.stringify(message.embeds, null, 2)+'```';
|
||||
return trySend(this.client, msg, {content:'Collected:'+mesemb,split:{maxLength:2000,char: ",",append:',```',prepend:'```js\n'}});
|
||||
}
|
||||
};
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const commando = require("@iceprod/discord.js-commando");
|
||||
const { errLog, getChannelMessage, ranLog, noPerm, trySend } = require("../../resources/functions");
|
||||
const { getChannelMessage, trySend } = require("../../resources/functions");
|
||||
|
||||
module.exports = class mesinfo extends commando.Command {
|
||||
constructor(client) {
|
||||
|
|
@ -13,25 +13,16 @@ module.exports = class mesinfo extends commando.Command {
|
|||
});
|
||||
}
|
||||
async run(msg, arg) {
|
||||
const {defaultErrorLogChannel} = require("../../config.json");
|
||||
const args = arg.trim().split(/ +/);
|
||||
const message = await getChannelMessage(this.client, msg, args[0], args[1]);
|
||||
console.log(message);
|
||||
if (!message) {
|
||||
return trySend(this.client, msg, "No message with that ID <:catstareLife:794930503076675584>")
|
||||
} else {
|
||||
try {
|
||||
const mesinfo = 'Collected:```js\n'+JSON.stringify(message, null, 2).replace(/`/g,"\\`")+'```';
|
||||
const mentionJSON = message.mentions.toJSON();
|
||||
const sendMentionInfo = 'Mentions:```js\n'+JSON.stringify(mentionJSON, null, 2)+'```';
|
||||
const Attachments = 'Attachments:```js\n'+JSON.stringify(message.attachments, null, 2)+'```';
|
||||
const sendmesinfo = mesinfo+sendMentionInfo+Attachments;
|
||||
const result1 = await trySend(this.client, msg, {content:sendmesinfo,split:{maxLength:2000,char: ", " || ",\n" || ". " || ".\n" || "," || ".",append:',```',prepend:'```js\n'}});
|
||||
return ranLog(msg,'mesinfo',`${result1}`);
|
||||
} catch (e) {
|
||||
noPerm(msg);
|
||||
return errLog(e, msg, this.client, false, "", false, defaultErrorLogChannel);
|
||||
}
|
||||
}
|
||||
const args = arg.trim().split(/ +/);
|
||||
const message = await getChannelMessage(this.client, msg, args[0], args[1]);
|
||||
if (!message) {
|
||||
return trySend(this.client, msg, "No message with that ID <:catstareLife:794930503076675584>")
|
||||
}
|
||||
const mesinfo = 'Collected:```js\n'+JSON.stringify(message, null, 2).replace(/`/g,"\\`")+'```';
|
||||
const mentionJSON = message.mentions.toJSON();
|
||||
const sendMentionInfo = 'Mentions:```js\n'+JSON.stringify(mentionJSON, null, 2)+'```';
|
||||
const Attachments = 'Attachments:```js\n'+JSON.stringify(message.attachments, null, 2)+'```';
|
||||
const sendmesinfo = mesinfo+sendMentionInfo+Attachments;
|
||||
return trySend(this.client, msg, {content:sendmesinfo,split:{maxLength:2000,char: ",",append:',```',prepend:'```js\n'}});
|
||||
}
|
||||
};
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const commando = require("@iceprod/discord.js-commando");
|
||||
const { MessageEmbed } = require("discord.js");
|
||||
const { getChannelMessage, ranLog, errLog, noPerm, tryReact, trySend } = require("../../resources/functions");
|
||||
const { getChannelMessage, errLog, noPerm, tryReact, trySend, ranLog } = require("../../resources/functions");
|
||||
const { database } = require("../../database/mongo");
|
||||
const col = database.collection("Guild");
|
||||
|
||||
|
|
@ -24,10 +24,10 @@ module.exports = class newquoteotd extends commando.Command {
|
|||
const quoteOTD = findDoc?.["settings"]?.quoteOTD;
|
||||
const color = colorConf.randomColors;
|
||||
if (!quoteOTD || !quoteOTD.channel) {
|
||||
return msg.channel.send(`Quote OTD channel not set! Run \`${this.client.commandPrefix}quoteotd\` to set one.`);
|
||||
return trySend(this.client, msg, `Quote OTD channel not set! Run \`${msg.guild.commandPrefix}quoteotd\` to set one.`);
|
||||
}
|
||||
if (!args[0]) {
|
||||
return msg.channel.send('Provide `<message_ID>`!');
|
||||
return trySend(this.client, msg, 'Provide `<message_ID>`!');
|
||||
}
|
||||
try {
|
||||
let emb = new MessageEmbed();
|
||||
|
|
@ -51,11 +51,14 @@ module.exports = class newquoteotd extends commando.Command {
|
|||
.setThumbnail(thumbnail)
|
||||
.setFooter(quoteOTD.footerText, quoteOTD.footerIcon)
|
||||
.setColor(color[Math.floor(Math.random()*color.length)]);
|
||||
await trySend(this.client, quoteOTD.channel, emb);
|
||||
tryReact(msg, "a:yesLife:794788847996370945");
|
||||
return ranLog(msg,'newqotd',`${msg.author.tag} (${msg.author.id}) made new QOTD \`${description}\` by ${author.tag} (${author.id})`);
|
||||
const sent = trySend(this.client, quoteOTD.channel, emb);
|
||||
if (sent) {
|
||||
tryReact(msg, "a:yesLife:794788847996370945");
|
||||
}
|
||||
return sent;
|
||||
}
|
||||
return msg.channel.send('No message with that ID from this channel. Use `[<channel_[mention, ID]> <message_ID>, message_link]` if it\'s in another channel.');
|
||||
ranLog(this.client, msg, "New quote: " + msg.content + "\nBy: " + mes.author.tag + ` (${mes.author.id})`);
|
||||
return trySend(this.client, msg, 'No message with that ID from this channel. Use `[<channel_[mention, ID]> <message_ID>, message_link]` if it\'s in another channel.');
|
||||
} catch (e) {
|
||||
noPerm(msg);
|
||||
return errLog(e, msg, this.client, true, "", true);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const commando = require("@iceprod/discord.js-commando");
|
||||
const { writeJSONSync } = require("fs-extra");
|
||||
const { join } = require("path");
|
||||
const { ranLog, trySend } = require("../../resources/functions");
|
||||
const { trySend, ranLog } = require("../../resources/functions");
|
||||
const { database } = require("../../database/mongo");
|
||||
const col = database.collection("Guild");
|
||||
|
||||
|
|
@ -36,13 +34,13 @@ module.exports = class quoteotd extends commando.Command {
|
|||
if (!this.client.channels.cache.get(data)) {
|
||||
return trySend(this.client, msg, 'Invalid/unknown channel provided! Try mentioning a channel or use `ChannelID`');
|
||||
} 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`;
|
||||
}
|
||||
}
|
||||
if (startW.startsWith('text')) {
|
||||
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`;
|
||||
}
|
||||
if (startW.startsWith('icon')) {
|
||||
|
|
@ -50,16 +48,16 @@ module.exports = class quoteotd extends commando.Command {
|
|||
if (!/^http/.test(data)) {
|
||||
return trySend(this.client, msg, 'Invalid icon url provided!');
|
||||
} 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`;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result.length > 0) {
|
||||
trySend(this.client, msg, result);
|
||||
ranLog(this.client, msg, result);
|
||||
return trySend(this.client, msg, result);
|
||||
} else {
|
||||
return trySend(this.client, msg, `Provide argument: \`--channel [mention, ID], --text [footer text], --icon [url footer icon]\``);
|
||||
}
|
||||
return ranLog(msg,'qotd',result);
|
||||
}
|
||||
};
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const commando = require("@iceprod/discord.js-commando");
|
||||
const emoteMessage = require("../../resources/emoteMessage");
|
||||
const { ranLog, trySend, tryDelete } = require("../../resources/functions");
|
||||
|
||||
module.exports = class say extends commando.Command {
|
||||
|
|
@ -12,19 +13,21 @@ module.exports = class say extends commando.Command {
|
|||
description: "Say."
|
||||
});
|
||||
}
|
||||
run(msg, args) {
|
||||
let noArgs = `<@!${msg.author.id}> what to say?`;
|
||||
async run(msg, args) {
|
||||
let noArgs = '';
|
||||
if (!args) {
|
||||
args = noArgs;
|
||||
}
|
||||
args = emoteMessage(this.client, args);
|
||||
const sendThis = {content:args, disableMentions:"all"};
|
||||
if (msg.member?.hasPermission("ADMINISTRATOR")) {
|
||||
if (msg.member?.hasPermission('MENTION_EVERYONE')) {
|
||||
sendThis.disableMentions = "none";
|
||||
}
|
||||
trySend(this.client, msg, sendThis);
|
||||
const sent = await trySend(this.client, msg, sendThis);
|
||||
if (args !== noArgs && msg.channel.guild && msg.member.hasPermission("MANAGE_MESSAGES")) {
|
||||
tryDelete(msg);
|
||||
}
|
||||
return ranLog(msg,'say',`Content: ${args}`);
|
||||
ranLog(this.client, msg, sent.content);
|
||||
return sent;
|
||||
}
|
||||
};
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
'use strict';
|
||||
const commando = require("@iceprod/discord.js-commando");
|
||||
const { ranLog, errLog, trySend, sentAdCheck, tryReact, findChannelRegEx, cleanMentionID } = require("../../resources/functions");
|
||||
const emoteMessage = require("../../resources/emoteMessage");
|
||||
const { ranLog, errLog, trySend, tryReact, findChannelRegEx, cleanMentionID } = require("../../resources/functions");
|
||||
|
||||
module.exports = class send extends commando.Command {
|
||||
constructor(client) {
|
||||
|
|
@ -19,25 +20,32 @@ module.exports = class send extends commando.Command {
|
|||
return trySend(this.client, msg, 'Where?!?');
|
||||
}
|
||||
const search = cleanMentionID(comarg[0]),
|
||||
channel = findChannelRegEx(msg, search)[0],
|
||||
sendTheMes = args.slice(comarg[0].length).trim();
|
||||
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);
|
||||
if (!channel && this.client.owners.includes(msg.author)) {
|
||||
channel = this.client.channels.cache.get(search);
|
||||
}
|
||||
}
|
||||
if (!channel) {
|
||||
channel = findChannelRegEx(msg, search, ["category", "voice"])[0];
|
||||
}
|
||||
if (!channel) {
|
||||
return trySend(this.client, msg, "That channel is like your gf. Doesn't exist <:cathmmLife:772716381874946068>");
|
||||
} else {
|
||||
if (!channel.permissionsFor(msg.author).has("SEND_MESSAGES")) {
|
||||
return trySend(this.client, msg, "No <: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 {
|
||||
if (sendTheMes.length === 0) {
|
||||
return trySend(this.client, channel, `<@!${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"};
|
||||
if (msg.member?.hasPermission("MENTION_EVERYONE")) {
|
||||
sendThis.disableMentions = "none";
|
||||
}
|
||||
const send = await trySend(this.client, channel, sendThis);
|
||||
sentAdCheck(send);
|
||||
const filter = () => true,
|
||||
collector = send.createReactionCollector(filter, {time: 15*6*1000, dispose:true});
|
||||
collector.on('collect', r => {
|
||||
|
|
@ -46,8 +54,11 @@ module.exports = class send extends commando.Command {
|
|||
} catch (e) {}
|
||||
});
|
||||
collector.on('remove', async r => await msg.reactions.resolve(r).id.remove(r.id));
|
||||
tryReact(msg, 'yeLife:796401669188354090');
|
||||
return ranLog(msg,'send',`ID: ${send.id} url: ${send.url}\nSent to channel: ${channel.name} (${channel.id}) of ${send.guild.name}\nContent: ${args.slice(at.length)}`);
|
||||
if (send) {
|
||||
tryReact(msg, 'yeLife:796401669188354090');
|
||||
}
|
||||
ranLog(this.client, msg, send.content);
|
||||
return send;
|
||||
} catch (e) {
|
||||
return errLog(e, msg, this.client);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ module.exports = class servav extends commando.Command {
|
|||
const server_ID = arg.split(/ +/)[0];
|
||||
const doc = msg.guild?.id ?? msg.author.id;
|
||||
const col = database.collection(msg.guild ? "Guild" : "User");
|
||||
col.findOne({document: doc}, async (err, res) => {
|
||||
col.findOne({document: doc}, (err, res) => {
|
||||
if (err) {
|
||||
errLog(err, msg, this.client);
|
||||
}
|
||||
const footerQuote = res?.["settings"]?.defaultEmbed?.footerQuote;
|
||||
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)) {
|
||||
target = this.client.guilds.cache.get(server_ID);
|
||||
} else {
|
||||
|
|
@ -54,8 +54,7 @@ module.exports = class servav extends commando.Command {
|
|||
const color = getColor(target.owner.displayColor)
|
||||
embed.setColor(color);
|
||||
}
|
||||
trySend(this.client, msg, embed);
|
||||
return ranLog(msg, "servav", `**${target.name}** (${target.id})`);
|
||||
return trySend(this.client, msg, embed);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,19 +17,20 @@ module.exports = class setfootq extends commando.Command {
|
|||
}
|
||||
async run(msg, args) {
|
||||
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');
|
||||
}
|
||||
const data = msg.guild ? "Guild" : "User";
|
||||
const col = database.collection(data);
|
||||
const doc = msg.guild?.id ?? msg.author.id;
|
||||
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) {
|
||||
return errLog(e, msg, this.client);
|
||||
}
|
||||
const result = await trySend(this.client, msg, `Changed from \`${oldQ?.["settings"]?.defaultEmbed?.footerQuote}\` to \`${args.trim()}\``);
|
||||
return ranLog(msg, "setfooterquote", result.content);
|
||||
ranLog(this.client, msg, result.content);
|
||||
return result;
|
||||
});
|
||||
} catch (e) {
|
||||
return errLog(e, msg, this.client);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
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 {
|
||||
constructor(client) {
|
||||
|
|
@ -12,30 +12,36 @@ module.exports = class uinfo extends commando.Command {
|
|||
description: "\"Detailed\" Profile."
|
||||
});
|
||||
}
|
||||
async run(msg, arg ) {
|
||||
const args = arg.trim().split(/ +/);
|
||||
async run(msg, arg) {
|
||||
try {
|
||||
let profile;
|
||||
if (args[0]) {
|
||||
profile = await getUser(this.client, msg, args[0]);
|
||||
if (arg.length > 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 {
|
||||
profile = msg.author;
|
||||
}
|
||||
const member = msg.guild.member(profile);
|
||||
let result = 'User: '+profile.tag+'```js\n';
|
||||
let result = "";
|
||||
if (profile) {
|
||||
result = result+JSON.stringify(profile, null, 2)+'```';
|
||||
result += 'User: '+profile.tag+'```js\n' + JSON.stringify(profile, null, 2)+'```';
|
||||
}
|
||||
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)) {
|
||||
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'}});
|
||||
return ranLog(msg,'profile', msg.content);
|
||||
return trySend(this.client, msg, {content: result, split:{maxLength:2000,char: ",",append:',```',prepend:'```js\n'}});
|
||||
} catch (e) {
|
||||
return errLog(e, msg, this.client, false, 'Gimme the right ID!', true);
|
||||
return trySend(this.client, msg, "404 ERROR not found~");
|
||||
}
|
||||
}
|
||||
};
|
||||
12
resources/debug.js
Normal file
12
resources/debug.js
Normal 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
28
resources/emoteMessage.js
Normal 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;
|
||||
}
|
||||
|
|
@ -1,14 +1,17 @@
|
|||
'use strict';
|
||||
|
||||
const { MessageEmbed, Message, GuildMember, User, Client, GuildChannel, Role, MessageOptions, Channel } = require('discord.js');
|
||||
const { defaultErrorLogChannel } = require("../config.json");
|
||||
const { defaultErrorLogChannel, ranLogger } = require("../config.json");
|
||||
const { database } = require("../database/mongo");
|
||||
const { timestampAt } = require('./debug');
|
||||
const getColor = require('./getColor');
|
||||
const { randomColors } = require("../config.json");
|
||||
const { CommandoMessage, CommandoClient } = require('@iceprod/discord.js-commando');
|
||||
|
||||
/**
|
||||
* Log an error. If second argument, third argument is required
|
||||
* @param {Error} theError - Catched error (error)
|
||||
* @param {Message} msg - Message object (msg)
|
||||
* @param {CommandoMessage} msg - Message object (msg)
|
||||
* @param {Client} client - This client (this.client)
|
||||
* @param {Boolean} sendTheError - Add error content to notify message (true | false)
|
||||
* @param {String} errorMessage - Error message ("You don't have enough permission to use that command!")
|
||||
|
|
@ -17,8 +20,7 @@ const getColor = require('./getColor');
|
|||
async function errLog(theError, msg, client, sendTheError, errorMessage, notify) {
|
||||
let errLogPath, [logThis, inLogChannel, sendErr] = ['', '', ''];
|
||||
if (msg) {
|
||||
const comErr = msg.content.trim().split(/ +/)[0];
|
||||
logThis = `\`${comErr}\` (${msg.id}) ${msg.url} in ${msg.guild ? `**${msg.channel.name}** (${msg.channel.id}) of **${msg.guild.name}** (${msg.guild.id})` : `**DM**`} ran by **${msg.author.tag}** (${msg.author.id}) \n\n`;
|
||||
logThis = `\`${msg.command.name}\` (${msg.id}) ${msg.url} in ${msg.guild ? `**${msg.channel.name}** (${msg.channel.id}) of **${msg.guild.name}** (${msg.guild.id})` : `**DM**`} ran by **${msg.author.tag}** (${msg.author.id}) \n\n`;
|
||||
msg.guild ? errLogPath = `../Guilds/${msg.guild.id}/Log/` : errLogPath = '../Log/';
|
||||
if (errorMessage) {
|
||||
if (errorMessage.length > 0) {
|
||||
|
|
@ -45,8 +47,8 @@ async function errLog(theError, msg, client, sendTheError, errorMessage, notify)
|
|||
if (msg && msg.guild && msg.guild.id === "823815890285756447") {
|
||||
logThis = "";
|
||||
}
|
||||
const sendAt = await client.channels.cache.get(defaultErrorLogChannel);
|
||||
sendAt.send(logThis + inLogChannel.trim(),{split:true});
|
||||
const sendAt = client.channels.cache.get(defaultErrorLogChannel);
|
||||
sendAt.send(logThis + inLogChannel.trim() + timestampAt(),{split:true});
|
||||
} catch (errmes) {
|
||||
errLog(errmes, msg);
|
||||
}
|
||||
|
|
@ -62,7 +64,7 @@ async function errLog(theError, msg, client, sendTheError, errorMessage, notify)
|
|||
* @param {Message} msg - Message object (msg)
|
||||
* @param {String} MainID - Message ID | Channel ID | Channel Mention
|
||||
* @param {String} SecondID - Message ID
|
||||
* @returns {Promise<Message>} Message object
|
||||
* @returns {Promise<Message>} Message object | undefined
|
||||
*/
|
||||
async function getChannelMessage(client, msg, MainID, SecondID) {
|
||||
if (!MainID) {
|
||||
|
|
@ -81,31 +83,10 @@ async function getChannelMessage(client, msg, MainID, SecondID) {
|
|||
const meschannel = client.channels.cache.get(MainID);
|
||||
return await meschannel.messages.fetch(SecondID);
|
||||
} catch (theError) {
|
||||
return errLog(theError, msg, client);
|
||||
return
|
||||
}
|
||||
}
|
||||
return await msg.channel.messages.fetch(MainID).catch(e => {return errLog(e, msg, client)});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
return await msg.channel.messages.fetch(MainID).catch(e => {return});
|
||||
}
|
||||
|
||||
function execCB(error, stdout, stderr) {
|
||||
|
|
@ -116,17 +97,22 @@ function execCB(error, stdout, stderr) {
|
|||
console.log('stdout:\n'+stdout);
|
||||
console.log('stderr:\n'+stderr);
|
||||
}
|
||||
|
||||
async function ranLog(msg, cmd, addition) {
|
||||
let errLogPath;
|
||||
if (msg.guild) {
|
||||
errLogPath = `../Guilds/${msg.guild.id}/Log/`;
|
||||
} else {
|
||||
errLogPath = '../Log/';
|
||||
}
|
||||
let add = '\n'+addition;
|
||||
const b = new Date().toUTCString();
|
||||
return //console.log(inLog);
|
||||
/**
|
||||
* Command usage logger
|
||||
* @param {CommandoClient} client
|
||||
* @param {CommandoMessage} msg
|
||||
* @param {String} addition
|
||||
*/
|
||||
async function ranLog(client, msg, addition) {
|
||||
const channel = client.channels.cache.get(ranLogger);
|
||||
const embed = await defaultImageEmbed(msg, null, msg.command.name.toLocaleUpperCase() + ` (${msg.id})`);
|
||||
embed.setAuthor(msg.author.tag + ` (${msg.author.id})`, msg.author.displayAvatarURL({"size": 4096, "dynamic": true}))
|
||||
.setURL(msg.url)
|
||||
.setDescription(addition)
|
||||
.setFooter(timestampAt(), msg.guild?.iconURL({"size": 4096, "dynamic": true}))
|
||||
.addField("Guild", `**${msg.guild?.name}** (${msg.guild?.id})`, true)
|
||||
.addField("Channel", `**${msg.channel?.name}** (${msg.channel.id})`, true);
|
||||
trySend(client, channel, {embed: embed});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -172,22 +158,13 @@ function multipleMembersFound(client, msg, arr, key, max = 4, withID) {
|
|||
|
||||
/**
|
||||
* Get member object with RegExp
|
||||
* @param {Message} msg
|
||||
* @param {String} name
|
||||
* @param {Message} msg Message object of the guild being searched
|
||||
* @param {String} name Keyword
|
||||
* @returns {GuildMember[]} Member object found
|
||||
*/
|
||||
function findMemberRegEx(msg, name) {
|
||||
let found = [];
|
||||
const re = new RegExp(name, "i");
|
||||
const list = msg.guild?.members.cache.array();
|
||||
if (list) {
|
||||
for(const mem of list) {
|
||||
if (re.test(mem.displayName) || re.test(mem.user.tag)) {
|
||||
found.push(mem);
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
return msg.guild?.members.cache.array().filter(r => re.test(r.displayName) || re.test(r.user.tag));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -204,10 +181,11 @@ function noPerm(msg) {
|
|||
* Send message
|
||||
* @param {Client} client - (this.client)
|
||||
* @param {Message | String | Channel} msg Message object | channel_ID
|
||||
* @param {MessageOptions} content - ({content:content,optionblabla})
|
||||
* @param {MessageOptions} content - ({content:content,optionblabla})
|
||||
* @param {Boolean} adCheck - Check source for Discord invite link (true)
|
||||
* @returns {Promise<Message>} Sent message object
|
||||
*/
|
||||
async function trySend(client, msg, content) {
|
||||
async function trySend(client, msg, content, adCheck = true) {
|
||||
//console.log(...content);
|
||||
let msgOf;
|
||||
if (msg?.channel) {
|
||||
|
|
@ -219,6 +197,15 @@ async function trySend(client, msg, content) {
|
|||
msgOf = msg;
|
||||
}
|
||||
}
|
||||
if (adCheck) {
|
||||
if (content.content) {
|
||||
content.content = sentAdCheck(content.content);
|
||||
} else {
|
||||
if (typeof content === "string") {
|
||||
content = sentAdCheck(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
const sentMes = await msgOf.send(content)
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
|
|
@ -227,7 +214,6 @@ async function trySend(client, msg, content) {
|
|||
}
|
||||
return
|
||||
});
|
||||
sentAdCheck(sentMes);
|
||||
return sentMes;
|
||||
}
|
||||
|
||||
|
|
@ -254,45 +240,36 @@ function tryReact(msg, reaction) {
|
|||
|
||||
/**
|
||||
* Check a message sent by client for ads
|
||||
* @param {Message} sent - Sent message object (await msg.channel.send("discord.gg/banana"))
|
||||
* @param {String} content - Sent message object (await msg.channel.send("discord.gg/banana"))
|
||||
*/
|
||||
function sentAdCheck(sent) {
|
||||
if (sent) {
|
||||
if (/(https:\/\/)?(www\.)?discord\.gg\/(?:\w{2,15}(?!\w)(?= *))/.test(sent.content)) {
|
||||
let newCont = sent.content.replace(/(https:\/\/)?(www\.)?discord\.gg\/(?:\w{2,15}(?!\w)(?= *))/, '`Some invite link goes here`');
|
||||
sent.edit(newCont, `Command abuse: Contain server invite link.`);
|
||||
function sentAdCheck(content) {
|
||||
if (content.length > 5) {
|
||||
if (/(https:\/\/)?(www\.)?discord\.gg\/(?:\w{2,15}(?!\w)(?= *))/.test(content)) {
|
||||
content = content.replace(/(https:\/\/)?(www\.)?discord\.gg\/(?:\w{2,15}(?!\w)(?= *))/, '`Some invite link goes here`');
|
||||
}
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make default image embed
|
||||
* @param {Client} client
|
||||
* @param {Message} msg
|
||||
* @param {URL} image
|
||||
* @param {String} image
|
||||
* @param {GuildMember | User} author
|
||||
* @param {String} title
|
||||
* @param {String} footerText
|
||||
* @param {String} footerQuote
|
||||
* @returns {Promise<MessageEmbed>}
|
||||
*/
|
||||
async function defaultImageEmbed(client, msg, author, image, title, footerText) {
|
||||
const { randomColors } = require("../config.json");
|
||||
let footerQuote = footerText;
|
||||
async function defaultImageEmbed(msg, image, title, footerQuote) {
|
||||
if (!footerQuote) {
|
||||
const r = await database.collection(msg.guild ? "Guild" : "User").findOne({document: msg.guild?.id ?? msg.author.id});
|
||||
const r = await database.collection(msg.guild ? "Guild" : "User").findOne({document: msg.guild?.id ?? msg.author.id}).catch(() => {});
|
||||
footerQuote = r?.["settings"]?.defaultEmbed?.footerQuote || "";
|
||||
}
|
||||
let emb = new MessageEmbed();
|
||||
try {
|
||||
emb
|
||||
.setTitle(title)
|
||||
.setImage(image)
|
||||
.setColor(msg.guild ? getColor(author?.displayColor) : randomColors[Math.floor(Math.random() * randomColors.length)])
|
||||
.setFooter(footerQuote);
|
||||
} catch (e) {
|
||||
return errLog(e, msg, client, false, "", false);
|
||||
}
|
||||
return emb;
|
||||
return new MessageEmbed()
|
||||
.setTitle(title)
|
||||
.setImage(image)
|
||||
.setColor(msg.guild ? getColor(msg.member.displayColor) : randomColors[Math.floor(Math.random() * randomColors.length)])
|
||||
.setFooter(footerQuote);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -316,42 +293,31 @@ function cleanMentionID(key) {
|
|||
|
||||
/**
|
||||
* Get channel object wit RegExp
|
||||
* @param {Message} msg
|
||||
* @param {String} name
|
||||
* @param {Message} msg Message object of the guild being searched
|
||||
* @param {String} name Keyword
|
||||
* @param {ChannelType[]} exclude Exclude channel type
|
||||
* @returns {GuildChannel[]} Channels object found
|
||||
*/
|
||||
function findChannelRegEx(msg, name) {
|
||||
let found = [];
|
||||
function findChannelRegEx(msg, name, exclude) {
|
||||
const re = new RegExp(name, "i");
|
||||
const list = msg.guild?.channels.cache.array();
|
||||
if (list) {
|
||||
for(const mem of list) {
|
||||
if (re.test(mem.name)) {
|
||||
found.push(mem);
|
||||
}
|
||||
return msg.guild?.channels.cache.array().filter(r => {
|
||||
if (exclude?.includes(r.type)) {
|
||||
return false;
|
||||
} else {
|
||||
return re.test(r.name);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get role object with RegExp
|
||||
* @param {Message} msg
|
||||
* @param {String} name
|
||||
* @param {Message} msg Message object of the guild being searched
|
||||
* @param {String} name Keyword
|
||||
* @returns {Role[]} Roles object found
|
||||
*/
|
||||
function findRoleRegEx(msg, name) {
|
||||
let found = [];
|
||||
const re = new RegExp(name, "i");
|
||||
const list = msg.guild?.roles.cache.array();
|
||||
if (list) {
|
||||
for(const mem of list) {
|
||||
if (re.test(mem.name)) {
|
||||
found.push(mem);
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
return msg.guild?.roles.cache.array().filter(r => re.test(r.name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -438,7 +404,6 @@ module.exports = {
|
|||
cleanMentionID,
|
||||
multipleMembersFound, multipleRolesFound, multipleChannelsFound,
|
||||
findMemberRegEx, findChannelRegEx, findRoleRegEx,
|
||||
getUser,
|
||||
getChannelMessage, errLog,
|
||||
execCB, ranLog, noPerm,
|
||||
trySend, tryDelete, tryReact,
|
||||
|
|
|
|||
5
resources/scheduler/unmute.js
Normal file
5
resources/scheduler/unmute.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
require("@iceprod/discord.js-commando");
|
||||
|
||||
module.exports.unmuteExec = async function () {}
|
||||
|
|
@ -24,7 +24,7 @@ const URL = [
|
|||
];
|
||||
const browser = puppeteer.launch();
|
||||
const page1 = browser.then(r => r.newPage());
|
||||
page1.then(r => r.goto(URL[10]).catch(console.error));
|
||||
page1.then(r => r.goto(URL[1]).catch(console.error));
|
||||
|
||||
/**
|
||||
* Chat with Shasha
|
||||
|
|
@ -59,7 +59,7 @@ async function shaChat(client, index, question) {
|
|||
*/
|
||||
async function fetchAnswer(page, index) {
|
||||
try {
|
||||
await page.waitForSelector(`#answer > div:nth-child(${index})`, {timeout:5000}).catch(() => {});
|
||||
await page.waitForSelector(`#answer > div:nth-child(${index})`).catch(() => {});
|
||||
const result = await page.evaluate((index) => {
|
||||
const res = document.querySelector(`#answer > div:nth-child(${index})`).childNodes[4].textContent;
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -1,70 +1,104 @@
|
|||
'use strict';
|
||||
|
||||
const { Structures } = require("discord.js");
|
||||
const { Structures } = require("discord.js"),
|
||||
{ database } = require("../database/mongo");
|
||||
const { errLog } = require("./functions");
|
||||
|
||||
class Settings {
|
||||
constructor(client, type, id) {
|
||||
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 {
|
||||
Structures.extend("Guild", g => {
|
||||
return class Guild extends g {
|
||||
constructor(client, data) {
|
||||
super(client, data);
|
||||
this.settings = new Settings(client, "Guild", this.id);
|
||||
this.dbLoaded = false;
|
||||
}
|
||||
embed = {
|
||||
footer: {
|
||||
text: undefined,
|
||||
icon: undefined
|
||||
},
|
||||
timestamp: false
|
||||
};
|
||||
moderation = {
|
||||
mute: {
|
||||
role: undefined,
|
||||
duration: {
|
||||
date: undefined,
|
||||
string: undefined
|
||||
},
|
||||
log: undefined,
|
||||
publicLog: undefined
|
||||
},
|
||||
ban: {
|
||||
duration: {
|
||||
date: undefined,
|
||||
string: undefined
|
||||
},
|
||||
log: undefined,
|
||||
publicLog: undefined
|
||||
},
|
||||
kick: {
|
||||
log: undefined,
|
||||
publicLog: undefined
|
||||
}
|
||||
async dbLoad() {
|
||||
const ret = await database.collection("Guild").findOne({document: this.id}).then((r, j) => {
|
||||
if (j) return errLog(j, null, this.client);
|
||||
this.infractions = r?.moderation?.infractions;
|
||||
this.moderation = r?.moderation?.settings;
|
||||
this.defaultEmbed = r?.settings?.defaultEmbed;
|
||||
return this.dbLoaded = true;
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
/**
|
||||
* Get user infractions
|
||||
* @param {String} get - User ID
|
||||
* @returns {Promise<Object[]>} Infractions object
|
||||
*/
|
||||
async getInfractions(get) {
|
||||
try {
|
||||
const r = await database.collection("Guild").findOne({ document: this.id });
|
||||
this.infractions = r?.moderation?.infractions;
|
||||
let found = [];
|
||||
if (this.infractions.length > 0) {
|
||||
for (const inf of this.infractions) {
|
||||
for (const user of inf.by) {
|
||||
if (user.id === get) {
|
||||
found.push(inf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found.length > 0) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
} catch (e) { }
|
||||
}
|
||||
async addInfraction(add) {
|
||||
try {
|
||||
const r = await database.collection("Guild").findOne({ document: this.id });
|
||||
this.infractions = r?.moderation?.infractions;
|
||||
const ret = database.collection("Guild").updateOne({document: this.id}, {$push:{"moderation.infractions":add}}, (e, r) => {
|
||||
if (e) return errLog(e, null, this.client);
|
||||
if (r) {
|
||||
this.infractions.push(add);
|
||||
return true;
|
||||
};
|
||||
});
|
||||
return ret;
|
||||
} 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 => {
|
||||
return class Settings extends User {
|
||||
Structures.extend("User", u => {
|
||||
return class User extends u {
|
||||
constructor(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
|
||||
};
|
||||
}
|
||||
});
|
||||
Loading…
Reference in a new issue