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/install-state.gz
.pnp.*
settings.sqlite3
settings.sqlite3

18
Main.js
View file

@ -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'],
@ -10,7 +12,7 @@ let configFile = require('./config.json');
const { errLog, trySend } = require('./resources/functions');
const { join } = require('path');
const { chatAnswer } = require("./resources/shaChat");
require("./database/mongo");
const { timestampAt } = require("./resources/debug");
client.registry
.registerGroups([
@ -32,8 +34,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,6 +41,12 @@ 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);
}
@ -55,12 +61,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 +78,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);

View file

@ -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) {
@ -136,47 +136,4 @@ module.exports = class avatar extends commando.Command {
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 { getChannelMessage, errLog, ranLog, trySend, tryReact } = require("../../resources/functions");
module.exports = class clonemb extends commando.Command {
module.exports = class cloneembed extends commando.Command {
constructor(client) {
super(client, {
name: "clonemb",
aliases: ["cloneemb","cloneembed", "clonembed"],
name: "clone-embed",
aliases: ["clone-emb","clon-emb", "clon-embed"],
memberName: "clonemb",
group: "utility",
description: "Clone an Embed."
@ -16,7 +16,6 @@ module.exports = class clonemb extends commando.Command {
}
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;
@ -24,10 +23,10 @@ module.exports = class clonemb extends commando.Command {
content = theMes.content;
}
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]) {
return trySend(this.client, msg, 'Which embed??');
return trySend(this.client, msg, 'Which message??');
}
trySend(this.client, msg, {content:content,embed:theMes.embeds[0]});
const moreEmb = theMes.embeds.slice(1);
@ -37,14 +36,7 @@ module.exports = class clonemb extends commando.Command {
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
);
return trySend(this.client, msg, "No embed found. Use `<channel_[mention, ID]> <message_ID>` if it's in another channel.");
}
}
};

View file

@ -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')) {
@ -126,6 +143,7 @@ module.exports = class embmaker extends commando.Command {
if (/^http/.test(autVal.slice('icon'.length).trim())) {
autIcon = autVal.slice('icon'.length).trim();
} else {
reportMessage += "**[AUTHOR]** Invalid icon URL.\n";
autIcon = null;
}
}
@ -133,6 +151,7 @@ module.exports = class embmaker extends commando.Command {
if (/^http/.test(autVal.slice('url'.length).trim())) {
autUrl = autVal.slice('url'.length).trim();
} else {
reportMessage += "**[AUTHOR]** Invalid URL.\n";
autUrl = null;
}
}
@ -149,6 +168,7 @@ module.exports = class embmaker extends commando.Command {
if (/^http/.test(value.slice("image".length).trim())) {
embed.setImage(value.slice("image".length).trim());
} else {
reportMessage += "**[IMAGE]** Invalid URL.\n";
embed.setImage(null);
}
}
@ -156,6 +176,7 @@ module.exports = class embmaker extends commando.Command {
if (/^http/.test(value.slice("thumbnail".length).trim())) {
embed.setThumbnail(value.slice("thumbnail".length).trim());
} else {
reportMessage += "**[THUMBNAIL]** Invalid URL.\n";
embed.setThumbnail(null);
}
}
@ -163,6 +184,7 @@ module.exports = class embmaker extends commando.Command {
if (/^http/.test(value.slice("url".length).trim())) {
embed.setURL(value.slice("url".length).trim());
} else {
reportMessage += "**[URL]** Invalid URL.\n";
embed.setURL(null);
}
}
@ -171,22 +193,26 @@ module.exports = class embmaker extends commando.Command {
for(const theFile of attach) {
if (/^http/.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(/( \-)+/);
@ -206,6 +235,7 @@ module.exports = class embmaker extends commando.Command {
if (/^http/.test(footval.slice('icon'.length).trim())) {
footericon = footval.slice('icon'.length).trim();
} else {
reportMessage += "**[FOOTER]** Invalid icon URL.\n";
footericon = null;
}
}
@ -240,15 +270,23 @@ 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) {
if (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 +301,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,7 +318,10 @@ module.exports = class embmaker extends commando.Command {
embed = null;
}
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 (channel) {

View file

@ -34,13 +34,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 === "--role") {
if (args[1]) {
const cleanRoleID = cleanMentionID(arg.slice("role".length).trim());
if (!/\D/.test(cleanRoleID)) {
const cleanRoleID = cleanMentionID(arg.slice("--role".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 +52,12 @@ module.exports = class lookup extends commando.Command {
}
}
} else {
if (lowCaseArg0 === "channel") {
if (lowCaseArg0 === "--channel") {
if (args[1]) {
const cleanChannelID = cleanMentionID(arg.slice("channel".length).trim());
if (!/\D/.test(cleanChannelID)) {
const cleanChannelID = cleanMentionID(arg.slice("--channel".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 +70,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) {

View file

@ -18,7 +18,7 @@ module.exports = class mesemb extends commando.Command {
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'}});
const result = await trySend(this.client, msg, {content:'Collected:'+mesemb,split:{maxLength:2000,char: ",",append:',```',prepend:'```js\n'}});
return ranLog(msg,'mesemb',result.content);
} catch (e) {
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 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'}});
const result1 = await trySend(this.client, msg, {content:sendmesinfo,split:{maxLength:2000,char: ",",append:',```',prepend:'```js\n'}});
return ranLog(msg,'mesinfo',`${result1}`);
} catch (e) {
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 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 msg.channel.send(`Quote OTD channel not set! Run \`${msg.guild.commandPrefix}quoteotd\` to set one.`);
}
if (!args[0]) {
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)) {
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,7 +50,7 @@ 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`;
}
}

View file

@ -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 {
@ -17,6 +18,7 @@ module.exports = class say extends commando.Command {
if (!args) {
args = noArgs;
}
args = emoteMessage(this.client, args);
const sendThis = {content:args, disableMentions:"all"};
if (msg.member?.hasPermission("ADMINISTRATOR")) {
sendThis.disableMentions = "none";

View file

@ -1,6 +1,7 @@
'use strict';
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 {
constructor(client) {
@ -9,36 +10,47 @@ module.exports = class send extends commando.Command {
memberName: "send",
group: "utility",
description: "Send message to designated channel.",
userPermissions:["MANAGE_MESSAGES"]
guildOnly:true
});
}
async run(msg, args ) {
const comarg = args.trim().split(/ +/);
const bot = this.client;
let at = comarg[0];
if (!comarg[0]) {
return trySend(this.client, msg, 'Where?!?');
}
if (comarg[0].startsWith('<#') && comarg[0].endsWith('>')) {
at = comarg[0].slice(2, -1);
const search = cleanMentionID(comarg[0]),
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) {
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 {
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"};
if (msg.member?.hasPermission("ADMINISTRATOR")) {
if (msg.member?.hasPermission("MENTION_EVERYONE")) {
sendThis.disableMentions = "none";
}
const send = await trySend(this.client, channel, sendThis);
sentAdCheck(send);
const filter = () => true;
const collector = send.createReactionCollector(filter, {time: 15*6*1000, dispose:true});
const filter = () => true,
collector = send.createReactionCollector(filter, {time: 15*6*1000, dispose:true});
collector.on('collect', r => {
try {
msg.react(r.emoji);

View file

@ -31,7 +31,7 @@ module.exports = class servav extends commando.Command {
}
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 {

View file

@ -17,14 +17,14 @@ 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);
}

View file

@ -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,37 @@ 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'}});
trySend(this.client, msg, result, {split:{maxLength:2000,char: ",",append:',```',prepend:'```js\n'}});
return ranLog(msg,'profile', msg.content);
} 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",
"lodash": "^4.17.21",
"mongodb": "^3.6.6",
"nightmare": "^3.0.2",
"node": "^15.12.0",
"node-fetch": "^2.6.1",
"pup": "^0.0.2",
"puppeteer": "^9.0.0",
"sqlite": "^4.0.21",
"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 { defaultErrorLogChannel } = require("../config.json");
const { database } = require("../database/mongo");
const { timestampAt } = require('./debug');
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") {
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);
}
@ -81,31 +82,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) {
@ -117,7 +97,7 @@ function execCB(error, stdout, stderr) {
console.log('stderr:\n'+stderr);
}
async function ranLog(msg, cmd, addition) {
async function ranLog(msg, cmd, addition) { return /*
let errLogPath;
if (msg.guild) {
errLogPath = `../Guilds/${msg.guild.id}/Log/`;
@ -126,7 +106,7 @@ async function ranLog(msg, cmd, addition) {
}
let add = '\n'+addition;
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
* @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) {
@ -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)])
.setFooter(footerQuote);
} catch (e) {
return errLog(e, msg, client, false, "", false);
return errLog(e, msg, client);
}
return emb;
}
@ -316,18 +296,21 @@ 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) {
function findChannelRegEx(msg, name, exclude) {
let found = [];
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);
if (exclude?.includes(mem.type)) {} else {
found.push(mem);
}
}
}
return found;
@ -336,8 +319,8 @@ function findChannelRegEx(msg, name) {
/**
* 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) {
@ -438,7 +421,6 @@ module.exports = {
cleanMentionID,
multipleMembersFound, multipleRolesFound, multipleChannelsFound,
findMemberRegEx, findChannelRegEx, findRoleRegEx,
getUser,
getChannelMessage, errLog,
execCB, ranLog, noPerm,
trySend, tryDelete, tryReact,

View file

@ -1,70 +1,90 @@
'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) { }
}
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
};
}
});