mirror of
https://github.com/danbulant/Shasha
synced 2026-05-19 03:58:38 +00:00
backup
This commit is contained in:
parent
d747c3bed6
commit
11a0fcb78d
9 changed files with 81 additions and 20 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -45,6 +45,7 @@ build/Release
|
|||
node_modules/
|
||||
jspm_packages/
|
||||
exp/
|
||||
cmds/experiment/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
|
|
|||
4
Main.js
4
Main.js
|
|
@ -52,7 +52,7 @@ client.on("message", async 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}`);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -78,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, timestampAt()));
|
||||
client.on("debug", (...args) => console.log(...args, timestampAt()));
|
||||
|
||||
client.login(configFile.token);
|
||||
|
|
@ -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,19 +180,19 @@ 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.`);
|
||||
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.`);
|
||||
}
|
||||
if (duration.year > 275500) {
|
||||
duration.year = 275500;
|
||||
}
|
||||
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?.toUTCString() === invokedAt.toUTCString() && !settingDuration) {
|
||||
if (defaultDurationDoc?.date?.valueOf() > 0) {
|
||||
untilDate = new Date(invokedAt.valueOf() + defaultDurationDoc.date.valueOf() - 1000);
|
||||
} else {
|
||||
untilDate = "Indefinite";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (untilDate !== "Indefinite") {
|
||||
timeForMessage = [];
|
||||
const elapsedTime = new Date(untilDate.valueOf() - invokedAt.valueOf() + 1000),
|
||||
|
|
@ -251,8 +283,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"`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
cmds/moderation/src/duration.js
Normal file
2
cmds/moderation/src/duration.js
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
'use strict';
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
const commando = require("@iceprod/discord.js-commando");
|
||||
const emoteMessage = require("../../resources/emoteMessage");
|
||||
const { ranLog, errLog, trySend, sentAdCheck, tryReact, findChannelRegEx, cleanMentionID } = require("../../resources/functions");
|
||||
const { ranLog, errLog, trySend, tryReact, findChannelRegEx, cleanMentionID } = require("../../resources/functions");
|
||||
|
||||
module.exports = class send extends commando.Command {
|
||||
constructor(client) {
|
||||
|
|
@ -48,7 +48,6 @@ module.exports = class send extends commando.Command {
|
|||
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 => {
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ function noPerm(msg) {
|
|||
* @param {MessageOptions} content - ({content:content,optionblabla})
|
||||
* @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) {
|
||||
|
|
@ -199,6 +199,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);
|
||||
|
|
@ -207,7 +216,6 @@ async function trySend(client, msg, content) {
|
|||
}
|
||||
return
|
||||
});
|
||||
sentAdCheck(sentMes);
|
||||
return sentMes;
|
||||
}
|
||||
|
||||
|
|
@ -234,13 +242,13 @@ 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)) {
|
||||
let newCont = content.replace(/(https:\/\/)?(www\.)?discord\.gg\/(?:\w{2,15}(?!\w)(?= *))/, '`Some invite link goes here`');
|
||||
return newCont;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,20 @@ Structures.extend("Guild", g => {
|
|||
}
|
||||
} 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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue