I'm really questioning life rn

This commit is contained in:
Neko Life 2021-06-05 18:16:13 +00:00
parent 8727d56772
commit 0442ccbe8d
11 changed files with 394 additions and 92 deletions

49
Main.js
View file

@ -9,9 +9,9 @@ const client = new Commando.Client({
}); });
const sqlite = require('sqlite'); const sqlite = require('sqlite');
let configFile = require('./config.json'); let configFile = require('./config.json');
const { errLog, trySend } = require('./resources/functions'); const { errLog, trySend, noPerm } = require('./resources/functions');
const { join } = require('path'); const { join } = require('path');
//const { chatAnswer } = require("./resources/shaChat"); const { chatAnswer } = require("./resources/shaChat");
const { timestampAt } = require("./resources/debug"); const { timestampAt } = require("./resources/debug");
client.registry client.registry
@ -20,7 +20,8 @@ client.registry
'moderation', 'moderation',
'experiment', 'experiment',
'image', 'image',
'fun' 'fun',
"owner"
]) ])
.registerDefaults() .registerDefaults()
.registerCommandsIn(join(__dirname, 'cmds')); .registerCommandsIn(join(__dirname, 'cmds'));
@ -41,19 +42,43 @@ client.on('ready', async () => {
}); });
client.on("message", async msg => { client.on("message", async msg => {
if (msg.guild?.dbLoaded === false && !msg.author.bot) {
await msg.guild.dbLoad();
}
if (msg.author.dbLoaded === false && !msg.author.bot) { if (msg.author.dbLoaded === false && !msg.author.bot) {
await msg.author.dbLoad(); msg.author.dbLoad();
}/* }
if (msg.channel.id === "837178237322919966" && !msg.author.bot && !msg.content.toLowerCase().startsWith(client.commandPrefix+"chat")) { if (msg.channel.id === "837178237322919966" && !msg.author.bot && !msg.isCommand) {
chatAnswer(client, msg); msg.channel.startTyping().then(trySend(client, msg, await chatAnswer(msg.cleanContent))
).then(msg.channel.stopTyping()).catch(msg.channel.stopTyping());
} }
if (!msg.guild) { 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}`);
} */ } else {
if (/(?<!dont|don't|no).*giv.*(heart|nick).*(nick|heart)/i.test(msg.content)) {
if (!msg.member.displayName?.endsWith("<3")) {
msg.member.setNickname(msg.member.displayName + " <3")
.then(r => {
if (r) {
trySend(client, msg, "YES! <3 <3");
};
})
.catch(noPerm(msg));
}
}
if (/(dont|don't|no).*giv.*(heart|nick).*(nick|heart)/i.test(msg.content)) {
if (msg.member.displayName?.endsWith(" <3")) {
msg.member.setNickname(msg.member.displayName.slice(0, -3))
.then(r => {
if (r) {
trySend(client, msg, "okay <3");
};
})
.catch(noPerm(msg));
}
}
if (msg.guild.dbLoaded === false) {
msg.guild.dbLoad();
}
}
}); });
client.on("guildMemberRemove", memberLeave => { client.on("guildMemberRemove", memberLeave => {

View file

@ -1,7 +1,8 @@
'use strict'; 'use strict';
const commando = require("@iceprod/discord.js-commando"); const commando = require("@iceprod/discord.js-commando");
//const { chatAnswer } = require("../../resources/shaChat"); const { trySend } = require("../../resources/functions");
const { chatAnswer } = require("../../resources/shaChat");
module.exports = class chat extends commando.Command { module.exports = class chat extends commando.Command {
constructor(client) { constructor(client) {
@ -13,6 +14,13 @@ module.exports = class chat extends commando.Command {
}); });
} }
async run(msg) { async run(msg) {
//chatAnswer(this.client, msg); return msg.channel.startTyping().then(
trySend(this.client, msg, await chatAnswer(msg.cleanContent.slice((msg.guild.commandPrefix + msg.command.name).length + 1))).then(r => {
msg.channel.stopTyping();
return r;
}).catch(
msg.channel.stopTyping()
)
);
} }
}; };

192
cmds/moderation/eventlog.js Normal file
View file

@ -0,0 +1,192 @@
'use strict';
const commando = require("@iceprod/discord.js-commando");
const { getChannelProchedure, trySend, defaultImageEmbed } = require("../../resources/functions");
module.exports = class eventlog extends commando.Command {
constructor(client) {
super(client, {
name: "eventlog",
aliases: ["eventlogs"],
memberName: "eventlog",
group: "moderation",
description: "Configure server's Event Log Channels.",
guildOnly: true,
userPermissions: ["MANAGE_GUILD"]
});
}
async run(msg, arg) {
const set = arg.split(/(?<!\\)(--)+/);
let eventChannels = msg.guild.eventChannels;
if (!eventChannels) eventChannels = {};
if (set.length < 2 && set[0].length === 0) return trySend(this.client, msg, await resultEmbed(this));
let report = "", joinleavelog, channellog, banunbanlog, messagelog = { channel: undefined, ignore: [] }, invitelog, rolelog, guildlog, membernicklog, emotelog, memberroleslog, remove = false, setMessageIgnore = false;
for (const args of set) {
const lowArg = args.toLowerCase();
if (lowArg.startsWith("remove")) remove = true;
if (lowArg.startsWith("joinleave")) {
if (remove) eventChannels.joinLeave = undefined; else {
joinleavelog = getChannelProchedure(this.client, msg, args.slice("joinleaves".length).trim())?.id;
if (!joinleavelog) report += "**[JOINLEAVE]** Unknown channel.\n";
}
}
if (lowArg.startsWith("channel")) {
if (remove) eventChannels.channel = undefined; else {
channellog = getChannelProchedure(this.client, msg, args.slice("channels".length).trim())?.id;
if (!channellog) report += "**[CHANNEL]** Unknown channel.\n";
}
}
if (lowArg.startsWith("banunban")) {
if (remove) {
eventChannels.banUnban = undefined;
} else {
banunbanlog = getChannelProchedure(this.client, msg, args.slice("banunbanS".length).trim())?.id;
if (!banunbanlog) {
report += "**[BANUNBAN]** Unknown channel.\n";
}
}
}
if (lowArg.startsWith("message")) {
if (remove) {
eventChannels.message = {
channel: undefined,
ignore: []
}
} else {
const mesArgs = args.slice("message").trim().split(/(?<!\\)-(?!-)/);
if (mesArgs.length > 0 && /(?<!\\)-ignore/i.test(lowArg)) {
setMessageIgnore = true;
for (const mesArg of mesArgs) {
if (mesArg.toLowerCase().startsWith("ignore")) {
const ignoreArgs = mesArg.slice("ignores".length).trim().split(/(?<!\\),+(?!\d*})/);
if (ignoreArgs.length > 0) {
for (const ign of ignoreArgs) {
if (ign.length === 0) {
continue;
}
const chan = getChannelProchedure(this.client, msg, ign);
if (chan) {
if (messagelog.ignore.includes(chan.id)) {
report += "**[MESSAGE_CHANNELIGNORE]** Duplicate result: <#" + chan.id +
`> with keyword: **${ign.trim()}**\n`;
} else {
messagelog.ignore.push(chan.id);
}
} else {
report += "**[MESSAGE_CHANNELIGNORE]** Unknown channel: **" + ign.trim() + "**\n";
}
}
}
}
}
}
messagelog.channel = getChannelProchedure(this.client, msg, args.slice("messages".length).replace(/(?<!\\)-ignore.*/i, "").trim())?.id;
if (!messagelog.channel) {
report += "**[MESSAGE]** Unknown channel.\n";
}
}
}
if (lowArg.startsWith("invite")) {
if (remove) {
eventChannels.invite = undefined;
} else {
invitelog = getChannelProchedure(this.client, msg, args.slice("invites".length).trim())?.id;
if (!invitelog) {
report += "**[INVITE]** Unknown channel.\n";
}
}
}
if (lowArg.startsWith("role")) {
if (remove) {
eventChannels.role = undefined;
} else {
rolelog = getChannelProchedure(this.client, msg, args.slice("roles".length).trim())?.id;
if (!rolelog) {
report += "**[ROLE]** Unknown channel.\n";
}
}
}
if (lowArg.startsWith("guild")) {
if (remove) {
eventChannels.guild = undefined;
} else {
guildlog = getChannelProchedure(this.client, msg, args.slice("guilds".length).trim())?.id;
if (!guildlog) {
report += "**[GUILD]** Unknown channel.\n";
}
}
}
if (lowArg.startsWith("member")) {
if (remove) {
eventChannels.member = undefined;
} else {
membernicklog = getChannelProchedure(this.client, msg, args.slice("members".length).trim())?.id;
if (!membernicklog) {
report += "**[MEMBER]** Unknown channel.\n";
}
}
}
if (lowArg.startsWith("emoji")) {
if (remove) {
eventChannels.emote = undefined;
} else {
emotelog = getChannelProchedure(this.client, msg, args.slice("emojis".length).trim())?.id;
if (!emotelog) {
report += "**[EMOJI]** Unknown channel.\n";
}
}
}
if (lowArg.startsWith("memberrole")) {
if (remove) {
eventChannels.memberRole = undefined;
} else {
memberroleslog = getChannelProchedure(this.client, msg, args.slice("memberroles".length).trim())?.id;
if (!memberroleslog) {
report += "**[MEMBERROLE]** Unknown channel.\n";
}
}
}
}
async function resultEmbed(the) {
const emb = await defaultImageEmbed(msg, null, "Event Log Channels Configuration");
emb
.setDescription(`Set configuration using \`\`\`js\n${msg.guild.commandPrefix + the.name} [--remove] --<Category> <Channel_[Mention | Name | ID]>\`\`\`**Categories:** \`\`\`js\n[MESSAGE [-ignore <Channel_[Mention | Name | ID]>], JOINLEAVE, MEMBER, MEMBERROLE, BANUNBAN, GUILD, ROLE, CHANNEL, EMOJI, INVITE]\`\`\``)
.addField(`Message Edit and Delete`, eventChannels?.message?.channel ? `<#${eventChannels?.message.channel}>\n**Ignores:** ${eventChannels?.message?.ignore?.length > 0 ?
"<#" + eventChannels?.message.ignore.join(">, <#") + ">" : "None"}`
: "Not set", true)
.addField(`Member Join and Leave`, eventChannels?.joinLeave ? `<#${eventChannels?.joinLeave}>` : "Not set", true)
.addField(`Member Profile Updates`, eventChannels?.member ? `<#${eventChannels?.member}>` : "Not set", true)
.addField(`Member Role Updates`, eventChannels?.memberRole ? `<#${eventChannels?.memberRole}>` : "Not set", true)
.addField(`Member Ban and Unban`, eventChannels?.banUnban ? `<#${eventChannels?.banUnban}>` : "Not set", true)
.addField(`Server Updates`, eventChannels?.guild ? `<#${eventChannels?.guild}>` : "Not set", true)
.addField(`Server Role Updates`, eventChannels?.role ? `<#${eventChannels?.role}>` : "Not set", true)
.addField(`Server Channels Updates`, eventChannels?.channel ? `<#${eventChannels?.channel}>` : "Not set", true)
.addField(`Server Emoji Updates`, eventChannels?.emote ? `<#${eventChannels?.emote}>` : "Not set", true)
.addField(`Server Invites`, eventChannels?.invite ? `<#${eventChannels?.invite}>` : "Not set", true);
return emb;
}
eventChannels = {
joinLeave: joinleavelog ?? eventChannels?.joinLeave,
channel: channellog ?? eventChannels?.channel,
banUnban: banunbanlog ?? eventChannels?.banUnban,
message: {
channel: messagelog.channel ?? eventChannels?.message?.channel,
ignore: setMessageIgnore ? messagelog.ignore : eventChannels?.message?.ignore
},
invite: invitelog ?? eventChannels?.invite,
role: rolelog ?? eventChannels?.role,
guild: guildlog ?? eventChannels?.guild,
member: membernicklog ?? eventChannels?.member,
emote: emotelog ?? eventChannels?.emote,
memberRole: memberroleslog ?? eventChannels?.memberRole
}
await msg.guild.setEventChannels(eventChannels);
if (msg.guild.eventChannels === eventChannels) {
report += "Event Log Channels set!\n";
}
report += "\n**SUMMARY:**";
if (report.length > 0) {
return trySend(this.client, msg, (await resultEmbed(this)).setDescription(report.slice(0, 2048)));
}
}
};

18
cmds/owner/update.js Normal file
View file

@ -0,0 +1,18 @@
'use strict';
const commando = require("@iceprod/discord.js-commando");
module.exports = class update extends commando.Command {
constructor(client) {
super(client, {
name: "update",
memberName: "update",
group: "owner",
description: "Update Shasha.",
ownerOnly: true
});
}
run(msg) {
}
};

View file

@ -13,9 +13,7 @@ module.exports = class embmaker extends commando.Command {
aliases: ["embedmaker","createmb","creatembed"], aliases: ["embedmaker","createmb","creatembed"],
group: "utility", group: "utility",
description: "Embed creator.", description: "Embed creator.",
details:`Embed creator: You can just copy this template and remove unneeded argument. Every argument is optional.\`\`\`\n--title [text]\n--description [text]\n--author:\n -name [text]\n -icon [url]\n -url [url]\n--color [hex, number, name of color]\n--image [url]\n--thumbnail [url]\n--url [url]\n--newfield:\n -name [text]\n -desc [text]\n -inline (true if provided)\n--footer:\n -text [text]\n -icon [url]\n--content [text]\n--channel [channel_[mention, ID]]\n--timestamp [ISO 8601, UNIX Timestamp (Milliseconds)] - Use https://time.lol \n--attachments [url] - You can put [-copy] when editing to copy all the message attachments (Cannot remove existing attachment unless [--channel] provided) \`\`\`Embed editor: You can put \`\`\`--edit <[message_ID, channel_[mention, ID] message_ID]>\`\`\` as first argument to edit the embed in a message. All existing property will be replaced with provided argument. Put \`\`\`--remove [author, fields, footer]\`\`\` to remove all existing property of the provided argument in the embed.\n\nOther arguments:\`\`\`\n--quote <[message_ID, channel_[mention, ID] message_ID]> - Quote a message\`\`\``, details:`Embed creator: You can just copy this template and remove unneeded argument. Every argument is optional.\`\`\`\n--title [text]\n--description [text]\n--author:\n -name [text]\n -icon [url]\n -url [url]\n--color [hex, number, name of color]\n--image [url]\n--thumbnail [url]\n--url [url]\n--newfield:\n -name [text]\n -desc [text]\n -inline (true if provided)\n--footer:\n -text [text]\n -icon [url]\n--content [text]\n--channel [channel_[mention, ID]]\n--timestamp [ISO 8601, UNIX Timestamp (Milliseconds)] - Use https://time.lol \n--attachments [url] - You can put [-copy] when editing to copy all the message attachments (Cannot remove existing attachment unless [--channel] provided) \`\`\`Embed editor: You can put \`\`\`--edit <[message_ID, channel_[mention, ID] message_ID]>\`\`\` as first argument to edit the embed in a message. All existing property will be replaced with provided argument. Put \`\`\`--remove [author, fields, footer]\`\`\` to remove all existing property of the provided argument in the embed.\n\nOther arguments:\`\`\`\n--quote <[message_ID, channel_[mention, ID] message_ID]> - Quote a message\`\`\``
ownerOnly:false,
hidden:false
}); });
} }
/** /**
@ -25,6 +23,9 @@ module.exports = class embmaker extends commando.Command {
* @returns * @returns
*/ */
async run(msg, arg) { async run(msg, arg) {
if (msg.guild && !this.client.owners.includes(msg.author) && !msg.member.hasPermission("EMBED_LINKS")) {
return trySend(this.client, msg, "LMFAO no");
}
const args = arg.trim().split(/(?<!\\)(\-\-)+/); const args = arg.trim().split(/(?<!\\)(\-\-)+/);
let embed = new MessageEmbed(); let embed = new MessageEmbed();
let autName, footertext, autIcon, autUrl, footericon, content, channel, editSrc, newAttach = [], reportMessage = ""; let autName, footertext, autIcon, autUrl, footericon, content, channel, editSrc, newAttach = [], reportMessage = "";
@ -32,8 +33,13 @@ module.exports = class embmaker extends commando.Command {
for(const value of args) { for(const value of args) {
if (value.toLowerCase().startsWith("json")) { if (value.toLowerCase().startsWith("json")) {
embed = new MessageEmbed(JSON.parse(value.slice("json".length).trim())); embed = new MessageEmbed(JSON.parse(value.slice("json".length).trim()));
continue;
} }
if (value.toLowerCase().startsWith('edit')) { if (value.toLowerCase().startsWith('edit')) {
if (msg.guild && !msg.member.hasPermission("MANAGE_MESSAGES")) {
reportMessage += "**[EDIT]** Require Manage Messages.\n";
continue;
}
const editArg = value.slice('edit'.length).trim().split(/ +/); const editArg = value.slice('edit'.length).trim().split(/ +/);
if (editArg[0].length > 0) { if (editArg[0].length > 0) {
editSrc = await getChannelMessage(this.client, msg, editArg[0], editArg[1]); editSrc = await getChannelMessage(this.client, msg, editArg[0], editArg[1]);
@ -72,6 +78,7 @@ module.exports = class embmaker extends commando.Command {
} else { } else {
reportMessage += "**[EDIT]** No argument provided.\n"; reportMessage += "**[EDIT]** No argument provided.\n";
} }
continue;
} }
if (value.toLowerCase().startsWith('quote')) { if (value.toLowerCase().startsWith('quote')) {
const quoteargs = value.slice('quote'.length).toLowerCase().trim().split(/ +/); const quoteargs = value.slice('quote'.length).toLowerCase().trim().split(/ +/);
@ -104,6 +111,7 @@ module.exports = class embmaker extends commando.Command {
} else { } else {
reportMessage += "**[QUOTE]** No argument provided.\n"; reportMessage += "**[QUOTE]** No argument provided.\n";
} }
continue;
} }
if (value.toLowerCase().startsWith('remove')) { if (value.toLowerCase().startsWith('remove')) {
const remove = value.slice('remove'.length).toLowerCase().trim().split(/ +/); const remove = value.slice('remove'.length).toLowerCase().trim().split(/ +/);
@ -123,21 +131,26 @@ module.exports = class embmaker extends commando.Command {
embed.footer = null; embed.footer = null;
} }
} }
continue;
} }
if (value.toLowerCase().startsWith('title')) { if (value.toLowerCase().startsWith('title')) {
embed.setTitle(value.slice('title'.length).trim().replace(/\\(?!\\)/g,'')); embed.setTitle(value.slice('title'.length).trim().replace(/\\(?!\\)/g,''));
continue;
} }
if (value.toLowerCase().startsWith('desc')) { if (value.toLowerCase().startsWith('desc')) {
embed.setDescription(value.slice('desc'.length).trim().replace(/\\(?!\\)/g,'')); embed.setDescription(value.slice('desc'.length).trim().replace(/\\(?!\\)/g,''));
continue;
} }
if (value.toLowerCase().startsWith('description')) { if (value.toLowerCase().startsWith('description')) {
embed.setDescription(value.slice('description'.length).trim().replace(/\\(?!\\)/g,'')); embed.setDescription(value.slice('description'.length).trim().replace(/\\(?!\\)/g,''));
continue;
} }
if (value.toLowerCase().startsWith("author")) { if (value.toLowerCase().startsWith("author")) {
const autData = value.trim().split(/( \-)+/); const autData = value.trim().split(/( \-)+/);
for(const autVal of autData) { for(const autVal of autData) {
if (autVal.toLowerCase().startsWith('name')) { if (autVal.toLowerCase().startsWith('name')) {
autName = autVal.slice('name'.length).trim().replace(/\\(?!\\)/g,''); autName = autVal.slice('name'.length).trim().replace(/\\(?!\\)/g,'');
continue;
} }
if (autVal.toLowerCase().startsWith('icon')) { if (autVal.toLowerCase().startsWith('icon')) {
if (/^https?:\/\/\w+\.\w\w/.test(autVal.slice('icon'.length).trim())) { if (/^https?:\/\/\w+\.\w\w/.test(autVal.slice('icon'.length).trim())) {
@ -146,6 +159,7 @@ module.exports = class embmaker extends commando.Command {
reportMessage += "**[AUTHOR]** Invalid icon URL.\n"; reportMessage += "**[AUTHOR]** Invalid icon URL.\n";
autIcon = null; autIcon = null;
} }
continue;
} }
if (autVal.toLowerCase().startsWith('url')) { if (autVal.toLowerCase().startsWith('url')) {
if (/^https?:\/\/\w+\.\w\w/.test(autVal.slice('url'.length).trim())) { if (/^https?:\/\/\w+\.\w\w/.test(autVal.slice('url'.length).trim())) {
@ -154,8 +168,10 @@ module.exports = class embmaker extends commando.Command {
reportMessage += "**[AUTHOR]** Invalid URL.\n"; reportMessage += "**[AUTHOR]** Invalid URL.\n";
autUrl = null; autUrl = null;
} }
continue;
} }
} }
continue;
} }
if (value.toLowerCase().startsWith("color")) { if (value.toLowerCase().startsWith("color")) {
const colorName = value.slice("color".length).trim(); const colorName = value.slice("color".length).trim();
@ -163,6 +179,7 @@ module.exports = class embmaker extends commando.Command {
if (color) { if (color) {
embed.setColor(color); embed.setColor(color);
} }
continue;
} }
if (value.toLowerCase().startsWith("image")) { if (value.toLowerCase().startsWith("image")) {
if (/^https?:\/\/\w+\.\w\w/.test(value.slice("image".length).trim())) { if (/^https?:\/\/\w+\.\w\w/.test(value.slice("image".length).trim())) {
@ -171,6 +188,7 @@ module.exports = class embmaker extends commando.Command {
reportMessage += "**[IMAGE]** Invalid URL.\n"; reportMessage += "**[IMAGE]** Invalid URL.\n";
embed.setImage(null); embed.setImage(null);
} }
continue;
} }
if (value.toLowerCase().startsWith("thumbnail")) { if (value.toLowerCase().startsWith("thumbnail")) {
if (/^https?:\/\/\w+\.\w\w/.test(value.slice("thumbnail".length).trim())) { if (/^https?:\/\/\w+\.\w\w/.test(value.slice("thumbnail".length).trim())) {
@ -179,6 +197,7 @@ module.exports = class embmaker extends commando.Command {
reportMessage += "**[THUMBNAIL]** Invalid URL.\n"; reportMessage += "**[THUMBNAIL]** Invalid URL.\n";
embed.setThumbnail(null); embed.setThumbnail(null);
} }
continue;
} }
if (value.toLowerCase().startsWith('url')) { if (value.toLowerCase().startsWith('url')) {
if (/^https?:\/\/\w+\.\w\w/.test(value.slice("url".length).trim())) { if (/^https?:\/\/\w+\.\w\w/.test(value.slice("url".length).trim())) {
@ -187,6 +206,7 @@ module.exports = class embmaker extends commando.Command {
reportMessage += "**[URL]** Invalid URL.\n"; reportMessage += "**[URL]** Invalid URL.\n";
embed.setURL(null); embed.setURL(null);
} }
continue;
} }
if (value.toLowerCase().startsWith('attachment')) { if (value.toLowerCase().startsWith('attachment')) {
const attach = value.slice("attachments".length).trim().split(/ +/); const attach = value.slice("attachments".length).trim().split(/ +/);
@ -210,6 +230,7 @@ module.exports = class embmaker extends commando.Command {
} }
} }
} }
continue;
} }
if (value.toLowerCase().startsWith("timestamp")) { if (value.toLowerCase().startsWith("timestamp")) {
if(!/\D/.test(value.slice("timestamp".length).trim())) { if(!/\D/.test(value.slice("timestamp".length).trim())) {
@ -224,6 +245,7 @@ module.exports = class embmaker extends commando.Command {
if (!embed.timestamp) { if (!embed.timestamp) {
reportMessage += "**[TIMESTAMP]** Invalid format.\n"; reportMessage += "**[TIMESTAMP]** Invalid format.\n";
} }
continue;
} }
if (value.toLowerCase().startsWith('footer')) { if (value.toLowerCase().startsWith('footer')) {
const footerData = value.trim().split(/( \-)+/); const footerData = value.trim().split(/( \-)+/);
@ -240,6 +262,7 @@ module.exports = class embmaker extends commando.Command {
} }
} }
} }
continue;
} }
if (value.toLowerCase().startsWith('newfield')) { if (value.toLowerCase().startsWith('newfield')) {
const fieldData = value.trim().split(/( \-)+/); const fieldData = value.trim().split(/( \-)+/);
@ -265,9 +288,11 @@ module.exports = class embmaker extends commando.Command {
fieldValue = ''; fieldValue = '';
} }
embed.addField(fieldName,fieldValue,inline); embed.addField(fieldName,fieldValue,inline);
continue;
} }
if (value.toLowerCase().startsWith('content')) { if (value.toLowerCase().startsWith('content')) {
content = value.slice('content'.length).trim().replace(/\\(?!\\)/g,''); content = value.slice('content'.length).trim().replace(/\\(?!\\)/g,'');
continue;
} }
if (value.toLowerCase().startsWith('channel')) { if (value.toLowerCase().startsWith('channel')) {
let ID = cleanMentionID(value.slice('channel'.length).trim()); let ID = cleanMentionID(value.slice('channel'.length).trim());
@ -279,13 +304,21 @@ module.exports = class embmaker extends commando.Command {
if (!channel && this.client.owners.includes(msg.author.id)) { if (!channel && this.client.owners.includes(msg.author.id)) {
channel = this.client.channels.cache.get(ID); channel = this.client.channels.cache.get(ID);
} }
} else { }
if (!channel) {
channel = findChannelRegEx(msg, ID, ["category", "voice"])[0]; channel = findChannelRegEx(msg, ID, ["category", "voice"])[0];
} }
if (!channel) { if (!channel) {
reportMessage += "**[CHANNEL]** Unknown channel.\n"; reportMessage += "**[CHANNEL]** Unknown channel.\n";
} else {
const p = msg.guild?.channels.cache.get(channel)?.permissionsFor(msg.author);
if (!p || p.missing("SEND_MESSAGES") || p.missing("EMBED_LINKS") || p.missing("VIEW_CHANNEL")) {
channel = undefined;
reportMessage += "**[CHANNEL]** Missing permission.\n";
}
} }
} }
continue;
} }
} }
if(autIcon === false) { if(autIcon === false) {
@ -315,18 +348,29 @@ module.exports = class embmaker extends commando.Command {
if (embed.description === '' && (content || newAttach.length > 0)) { if (embed.description === '' && (content || newAttach.length > 0)) {
embed = null; embed = null;
} }
if (newAttach.length > 0) {
reportMessage += "**[ATTACHMENT]** Uploading attachments....\n";
}
let sent = []; let sent = [];
if (reportMessage.length > 0) { if (reportMessage.length > 0) {
sent.push(trySend(this.client, msg, reportMessage)); sent.push(trySend(this.client, msg, reportMessage));
} }
if (editSrc) { if (editSrc) {
if (channel) { if (channel) {
if (msg.guild?.channels.cache.get(channel)?.permissionsFor(msg.author).has("ATTACH_FILES") && newAttach.length > 0) {
reportMessage += "**[ATTACHMENT]** Uploading attachments....\n";
} else {
if (newAttach.length > 0) {
newAttach = [];
reportMessage += "**[ATTACHMENT]** Missing permission.\n";
}
}
sent.push(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 { } else {
channel = msg.channel; channel = msg.channel;
if (msg.guild && channel.permissionsFor(msg.author).missing("ATTACH_FILES")) {
if (newAttach.length > 0) {
newAttach = [];
reportMessage += "**[ATTACHMENT]** Missing permission.\n";
}
}
if (editSrc.author === this.client.user) { if (editSrc.author === this.client.user) {
sent.push(editSrc.edit({content:content,embed:embed,files:newAttach}).catch(e => { sent.push(editSrc.edit({content:content,embed:embed,files:newAttach}).catch(e => {
errLog(e, msg, this.client); errLog(e, msg, this.client);

View file

@ -1,24 +0,0 @@
'use strict';
const commando = require("@iceprod/discord.js-commando"),
{ fixChat } = require("../../resources/shaChat");
const { trySend } = require("../../resources/functions");
module.exports = class fixchat extends commando.Command {
constructor(client) {
super(client, {
name: "fixchat",
memberName: "fixchat",
group: "utility",
description: "Fix broken chat."
});
}
async run(msg) {
//const r = await fixChat();
if (r === 3) {
return trySend(this.client, msg, "Fixed!");
} else {
return trySend(this.client, msg, "Oopsie somethin's wrong...");
}
}
};

View file

@ -15,7 +15,6 @@ module.exports = class send extends commando.Command {
} }
async run(msg, args ) { async run(msg, args ) {
const comarg = args.trim().split(/ +/); const comarg = args.trim().split(/ +/);
let at = comarg[0];
if (!comarg[0]) { if (!comarg[0]) {
return trySend(this.client, msg, 'Where?!?'); return trySend(this.client, msg, 'Where?!?');
} }

View file

@ -1,10 +1,10 @@
{ {
"dependencies": { "dependencies": {
"@iceprod/discord.js-commando": "^0.14.3", "@iceprod/discord.js-commando": "^0.14.3",
"axios": "^0.21.1",
"bree": "^6.2.0", "bree": "^6.2.0",
"bufferutil": "^4.0.3", "bufferutil": "^4.0.3",
"cabin": "^9.0.4", "cabin": "^9.0.4",
"cleverbot-node": "^0.3.11",
"discord.js": "^12.5.2", "discord.js": "^12.5.2",
"discord.js-commando": "^0.12.3", "discord.js-commando": "^0.12.3",
"erlpack": "github:discord/erlpack", "erlpack": "github:discord/erlpack",
@ -12,8 +12,6 @@
"lodash": "^4.17.21", "lodash": "^4.17.21",
"mongodb": "^3.6.6", "mongodb": "^3.6.6",
"node": "^15.12.0", "node": "^15.12.0",
"node-fetch": "^2.6.1",
"puppeteer": "^9.0.0",
"sqlite": "^4.0.21", "sqlite": "^4.0.21",
"sqlite3": "^5.0.2", "sqlite3": "^5.0.2",
"utf-8-validate": "^5.0.4", "utf-8-validate": "^5.0.4",

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const { MessageEmbed, Message, GuildMember, User, Client, GuildChannel, Role, MessageOptions, Channel } = require('discord.js'); const { MessageEmbed, Message, GuildMember, User, Client, GuildChannel, Role, MessageOptions, TextChannel, DMChannel } = require('discord.js');
const { defaultErrorLogChannel, ranLogger } = require("../config.json"); const { defaultErrorLogChannel, ranLogger } = require("../config.json");
const { database } = require("../database/mongo"); const { database } = require("../database/mongo");
const { timestampAt } = require('./debug'); const { timestampAt } = require('./debug');
@ -172,26 +172,25 @@ function noPerm(msg) {
/** /**
* Send message * Send message
* @param {Client} client - (this.client) * @param {CommandoClient} client - (this.client)
* @param {Message | String | Channel} msg Message object | channel_ID * @param {Message | String | TextChannel | DMChannel} 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) * @param {Boolean} adCheck - Check source for Discord invite link (true)
* @returns {Promise<Message>} Sent message object * @returns {Promise<Message>} Sent message object
*/ */
async function trySend(client, msg, content, adCheck = true) { function trySend(client, msg, content, adCheck = true) {
if (!client || !msg) { if (!client || !msg) {
return; return;
} }
let msgOf; if (client.owners.includes(msg.author)) {
if (msg?.channel) { adCheck = false;
msgOf = msg.channel; if (content.disableMentions) {
} else { content.disableMentions = "none";
if (typeof msg === "string") {
msgOf = client.channels.cache.get(msg);
} else {
msgOf = msg;
} }
} }
if (typeof msg === "string") {
msg = client.channels.cache.get(msg);
}
if (adCheck) { if (adCheck) {
if (content.content) { if (content.content) {
content.content = sentAdCheck(content.content); content.content = sentAdCheck(content.content);
@ -201,15 +200,15 @@ async function trySend(client, msg, content, adCheck = true) {
} }
} }
} }
const sentMes = await msgOf.send(content) if (msg instanceof Message) {
.catch((e) => { return msg.channel.send(content).catch(() => {});
console.error(e); } else {
if (msg?.channel) { if (msg instanceof TextChannel || msg instanceof DMChannel) {
noPerm(msg); return msg.send(content).catch(() => {});
} else {
console.error("[TRYSEND] Unknown {msg} type.", msg);
} }
return }
});
return sentMes;
} }
/** /**
@ -403,6 +402,34 @@ function multipleChannelsFound(client, msg, arr, key, max = 4, withID) {
} }
} }
/**
* Standard
* @param {Client} client this.client
* @param {Message} msg - Message object
* @param {String} key - Channel ID | Mention | Name
* @returns
*/
function getChannelProchedure(client, msg, key) {
if (key.length === 0) {
return;
}
const search = cleanMentionID(key);
if (search.length === 0) {
return;
}
let channel;
if (/^\d{17,19}$/.test(search)) {
channel = msg.guild.channels.cache.get(search);
if (!channel && client.owners.includes(msg.author)) {
channel = client.channels.cache.get(search);
}
}
if (!channel) {
channel = findChannelRegEx(msg, search, ["category", "voice"])[0];
}
return channel;
}
module.exports = { module.exports = {
cleanMentionID, cleanMentionID,
multipleMembersFound, multipleRolesFound, multipleChannelsFound, multipleMembersFound, multipleRolesFound, multipleChannelsFound,
@ -410,5 +437,5 @@ module.exports = {
getChannelMessage, errLog, getChannelMessage, errLog,
execCB, ranLog, noPerm, execCB, ranLog, noPerm,
trySend, tryDelete, tryReact, trySend, tryDelete, tryReact,
sentAdCheck, defaultImageEmbed sentAdCheck, defaultImageEmbed, getChannelProchedure
} }

View file

@ -1,12 +1,13 @@
'use strict'; 'use strict';
const puppeteer = require('puppeteer'); //const puppeteer = require('puppeteer');
const { trySend, noPerm } = require('./functions'); const axios = require("axios").default;
const { errLog } = require('./functions');
const Commando = require("@iceprod/discord.js-commando"); const Commando = require("@iceprod/discord.js-commando");
require("discord.js"); //require("discord.js");
//'4, 15, 10, 11, 14, 17, 18' //'4, 15, 10, 11, 14, 17, 18'
/*
const URL = [ const URL = [
'https://rebot.me/simsimi', 'https://rebot.me/ryuko-matoi',//1 'https://rebot.me/simsimi', 'https://rebot.me/ryuko-matoi',//1
'https://rebot.me/xmonikax', 'https://rebot.me/futa-nun',//3 'https://rebot.me/xmonikax', 'https://rebot.me/futa-nun',//3
@ -20,7 +21,7 @@ const URL = [
'https://rebot.me/zacharie-1', 'https://rebot.me/natsuki-41',//19 'https://rebot.me/zacharie-1', 'https://rebot.me/natsuki-41',//19
'https://rebot.me/lea-7062078', 'https://rebot.me/bunny-exe',//21 'https://rebot.me/lea-7062078', 'https://rebot.me/bunny-exe',//21
'https://rebot.me/just-monika-56' 'https://rebot.me/just-monika-56'
]; ];/*
const browser = puppeteer.launch(); const browser = puppeteer.launch();
const page1 = browser.then(r => r.newPage()); const page1 = browser.then(r => r.newPage());
page1.then(r => r.goto(URL[1]).catch(console.error)); page1.then(r => r.goto(URL[1]).catch(console.error));
@ -31,7 +32,7 @@ page1.then(r => r.goto(URL[1]).catch(console.error));
* @param {Number} index - Index of answer * @param {Number} index - Index of answer
* @param {Commando.Message} question - Message object * @param {Commando.Message} question - Message object
* @returns {Promise<String | Boolean>} Reply * @returns {Promise<String | Boolean>} Reply
*/ *
async function shaChat(client, index, question) { async function shaChat(client, index, question) {
if (page1) { if (page1) {
let query = question.content.trim(); let query = question.content.trim();
@ -55,7 +56,7 @@ async function shaChat(client, index, question) {
* @param {puppeteer.Page} page * @param {puppeteer.Page} page
* @param {Number} index * @param {Number} index
* @returns {String} * @returns {String}
*/ *
async function fetchAnswer(page, index) { async function fetchAnswer(page, index) {
try { try {
await page.waitForSelector(`#answer > div:nth-child(${index})`).catch(() => {}); await page.waitForSelector(`#answer > div:nth-child(${index})`).catch(() => {});
@ -70,13 +71,15 @@ async function fetchAnswer(page, index) {
} }
let chatIndex = 3; let chatIndex = 3;
*/
/** /**
* @param {Commando.Client} client * @param {String} message - Query
* @param {Commando.CommandoMessage} message * @returns {Promise<String>} Answers
* @returns
*/ */
async function chatAnswer(client, message) { async function chatAnswer(message) {
const r = await axios.post("https://rebot.me/ask", { username: "muffin-6", question: message }).catch(() => {});
return r.data;
} /* {
//console.log(message.content); //console.log(message.content);
//console.log(chatIndex); //console.log(chatIndex);
if (message.content.trim().length === 0) { if (message.content.trim().length === 0) {
@ -106,10 +109,10 @@ let chatIndex = 3;
message.channel.stopTyping(); message.channel.stopTyping();
} }
} }
} }
async function fixChat() { async function fixChat() {
return page1.then(r => r.reload()).then(() => {return chatIndex = 3}).catch(e => {return console.log(e)}); return page1.then(r => r.reload()).then(() => {return chatIndex = 3}).catch(e => {return console.log(e)});
} } */
module.exports = { chatAnswer, fixChat } module.exports = { chatAnswer }

View file

@ -1,8 +1,8 @@
'use strict'; 'use strict';
const { Structures } = require("discord.js"), const { Structures } = require("discord.js"),
{ database } = require("../database/mongo"); { database } = require("../database/mongo"),
const { errLog } = require("./functions"); { errLog } = require("./functions");
Structures.extend("Guild", g => { Structures.extend("Guild", g => {
return class Guild extends g { return class Guild extends g {
@ -16,6 +16,9 @@ Structures.extend("Guild", g => {
this.infractions = r?.moderation?.infractions; this.infractions = r?.moderation?.infractions;
this.moderation = r?.moderation?.settings; this.moderation = r?.moderation?.settings;
this.defaultEmbed = r?.settings?.defaultEmbed; this.defaultEmbed = r?.settings?.defaultEmbed;
this.eventChannels = r?.settings?.eventChannels;
return this.dbLoaded = true; return this.dbLoaded = true;
}); });
return ret; return ret;
@ -42,6 +45,8 @@ Structures.extend("Guild", g => {
if (found.length > 0) { if (found.length > 0) {
return found; return found;
} }
} else {
return;
} }
} catch (e) { } } catch (e) { }
} }
@ -49,16 +54,22 @@ Structures.extend("Guild", g => {
try { try {
const r = await database.collection("Guild").findOne({ document: this.id }); const r = await database.collection("Guild").findOne({ document: this.id });
this.infractions = r?.moderation?.infractions; this.infractions = r?.moderation?.infractions;
const ret = database.collection("Guild").updateOne({document: this.id}, {$push:{"moderation.infractions":add}}, (e, r) => { const ret = database.collection("Guild").updateOne({document: this.id}, {$push:{"moderation.infractions":add}}, (e) => {
if (e) return errLog(e, null, this.client); if (e) return errLog(e, null, this.client);
if (r) { this.infractions.push(add);
this.infractions.push(add); return true;
return true;
};
}); });
return ret; return ret;
} catch (e) { } } catch (e) { }
} }
setEventChannels(set) {
const ret = database.collection("Guild").updateOne({document: this.id}, {$set: {"settings.eventChannels": set}}, {upsert: true}, (e) => {
if (e) return errLog(e, null, this.client);
this.eventChannels = set;
return true;
});
return ret;
}
setDefaultEmbed(set) { setDefaultEmbed(set) {
const ret = database.collection("Guild").updateOne({document: this.id}, {$set:{"settings.defaultEmbed": set}}, {upsert: true}, (e) => { const ret = database.collection("Guild").updateOne({document: this.id}, {$set:{"settings.defaultEmbed": set}}, {upsert: true}, (e) => {
if (e) return errLog(e, null, this.client); if (e) return errLog(e, null, this.client);
@ -83,6 +94,7 @@ Structures.extend("User", u => {
constructor(client, data) { constructor(client, data) {
super(client, data); super(client, data);
this.dbLoaded = false; this.dbLoaded = false;
this.giveHeart = "yes";
} }
async dbLoad() { async dbLoad() {
const ret = await database.collection("User").findOne({document: this.id}).then((r, j) => { const ret = await database.collection("User").findOne({document: this.id}).then((r, j) => {