mirror of
https://github.com/danbulant/Shasha
synced 2026-05-24 12:22:00 +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/
|
node_modules/
|
||||||
jspm_packages/
|
jspm_packages/
|
||||||
exp/
|
exp/
|
||||||
|
cmds/experiment/
|
||||||
|
|
||||||
# Snowpack dependency directory (https://snowpack.dev/)
|
# Snowpack dependency directory (https://snowpack.dev/)
|
||||||
web_modules/
|
web_modules/
|
||||||
|
|
|
||||||
4
Main.js
4
Main.js
|
|
@ -52,7 +52,7 @@ client.on("message", async msg => {
|
||||||
}
|
}
|
||||||
|
|
||||||
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}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -78,6 +78,6 @@ process.on("uncaughtException", e => errLog(e, null, client));
|
||||||
process.on("unhandledRejection", e => errLog(e, null, client));
|
process.on("unhandledRejection", e => errLog(e, null, client));
|
||||||
process.on("warning", e => errLog(e, null, client));
|
process.on("warning", e => errLog(e, null, client));
|
||||||
|
|
||||||
//client.on("debug", (...args) => console.log(...args, timestampAt()));
|
client.on("debug", (...args) => console.log(...args, timestampAt()));
|
||||||
|
|
||||||
client.login(configFile.token);
|
client.login(configFile.token);
|
||||||
|
|
@ -7,6 +7,38 @@ const col = database.collection("Guild");
|
||||||
const schedule = database.collection("Schedule");
|
const schedule = database.collection("Schedule");
|
||||||
const { scheduler } = require("../../resources/scheduler");
|
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 {
|
module.exports = class mute extends commando.Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
super(client, {
|
super(client, {
|
||||||
|
|
@ -30,7 +62,7 @@ module.exports = class mute extends commando.Command {
|
||||||
defaultDurationDoc = muteSettingsDoc?.defaultDuration,
|
defaultDurationDoc = muteSettingsDoc?.defaultDuration,
|
||||||
infractionsDoc = modDoc?.infractions,
|
infractionsDoc = modDoc?.infractions,
|
||||||
args = arg.trim().split(/(?<!\\)(\-\-)+/),
|
args = arg.trim().split(/(?<!\\)(\-\-)+/),
|
||||||
mentions = args.shift().split(/(?<!\\),+/),
|
mentions = args.shift().split(/(?<!\\),+(?!\d*})/),
|
||||||
durationRegExp = /\d+(?![^ymwdhs])[ymwdhs]?o?/gi,
|
durationRegExp = /\d+(?![^ymwdhs])[ymwdhs]?o?/gi,
|
||||||
invokedAt = msg.createdAt,
|
invokedAt = msg.createdAt,
|
||||||
duration = {
|
duration = {
|
||||||
|
|
@ -148,13 +180,13 @@ module.exports = class mute extends commando.Command {
|
||||||
}
|
}
|
||||||
const roleConfCheck = msg.guild.roles.cache.get(muteSettingsDoc?.role);
|
const roleConfCheck = msg.guild.roles.cache.get(muteSettingsDoc?.role);
|
||||||
if (!roleConfCheck && !settingUp) {
|
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) {
|
if (duration.year > 275500) {
|
||||||
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));
|
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) {
|
if (defaultDurationDoc?.date?.valueOf() > 0) {
|
||||||
untilDate = new Date(invokedAt.valueOf() + defaultDurationDoc.date.valueOf() - 1000);
|
untilDate = new Date(invokedAt.valueOf() + defaultDurationDoc.date.valueOf() - 1000);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -251,8 +283,8 @@ module.exports = class mute extends commando.Command {
|
||||||
resultMsg += `Can't find user: **${usermention.trim()}**\n`;
|
resultMsg += `Can't find user: **${usermention.trim()}**\n`;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!settingUp && mentions.length === 1 && mentions[0].length === 0) {
|
if (!settingUp && mentions[0].length === 0) {
|
||||||
return trySend(this.client, msg, "Who do you wanna mute? Provide as first argument `<[RegExp | user_[mention | ID]]>`");
|
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';
|
'use strict';
|
||||||
const commando = require("@iceprod/discord.js-commando");
|
const commando = require("@iceprod/discord.js-commando");
|
||||||
const emoteMessage = require("../../resources/emoteMessage");
|
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 {
|
module.exports = class send extends commando.Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
|
|
@ -48,7 +48,6 @@ module.exports = class send extends commando.Command {
|
||||||
sendThis.disableMentions = "none";
|
sendThis.disableMentions = "none";
|
||||||
}
|
}
|
||||||
const send = await trySend(this.client, channel, sendThis);
|
const send = await trySend(this.client, channel, sendThis);
|
||||||
sentAdCheck(send);
|
|
||||||
const filter = () => true,
|
const filter = () => true,
|
||||||
collector = send.createReactionCollector(filter, {time: 15*6*1000, dispose:true});
|
collector = send.createReactionCollector(filter, {time: 15*6*1000, dispose:true});
|
||||||
collector.on('collect', r => {
|
collector.on('collect', r => {
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ function noPerm(msg) {
|
||||||
* @param {MessageOptions} content - ({content:content,optionblabla})
|
* @param {MessageOptions} content - ({content:content,optionblabla})
|
||||||
* @returns {Promise<Message>} Sent message object
|
* @returns {Promise<Message>} Sent message object
|
||||||
*/
|
*/
|
||||||
async function trySend(client, msg, content) {
|
async function trySend(client, msg, content, adCheck = true) {
|
||||||
//console.log(...content);
|
//console.log(...content);
|
||||||
let msgOf;
|
let msgOf;
|
||||||
if (msg?.channel) {
|
if (msg?.channel) {
|
||||||
|
|
@ -199,6 +199,15 @@ async function trySend(client, msg, content) {
|
||||||
msgOf = msg;
|
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)
|
const sentMes = await msgOf.send(content)
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|
@ -207,7 +216,6 @@ async function trySend(client, msg, content) {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
});
|
});
|
||||||
sentAdCheck(sentMes);
|
|
||||||
return sentMes;
|
return sentMes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -234,13 +242,13 @@ function tryReact(msg, reaction) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check a message sent by client for ads
|
* 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) {
|
function sentAdCheck(content) {
|
||||||
if (sent) {
|
if (content.length > 5) {
|
||||||
if (/(https:\/\/)?(www\.)?discord\.gg\/(?:\w{2,15}(?!\w)(?= *))/.test(sent.content)) {
|
if (/(https:\/\/)?(www\.)?discord\.gg\/(?:\w{2,15}(?!\w)(?= *))/.test(content)) {
|
||||||
let newCont = sent.content.replace(/(https:\/\/)?(www\.)?discord\.gg\/(?:\w{2,15}(?!\w)(?= *))/, '`Some invite link goes here`');
|
let newCont = content.replace(/(https:\/\/)?(www\.)?discord\.gg\/(?:\w{2,15}(?!\w)(?= *))/, '`Some invite link goes here`');
|
||||||
sent.edit(newCont, `Command abuse: Contain server invite link.`);
|
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 browser = puppeteer.launch();
|
||||||
const page1 = browser.then(r => r.newPage());
|
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
|
* Chat with Shasha
|
||||||
|
|
@ -59,7 +59,7 @@ async function shaChat(client, index, question) {
|
||||||
*/
|
*/
|
||||||
async function fetchAnswer(page, index) {
|
async function fetchAnswer(page, index) {
|
||||||
try {
|
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 result = await page.evaluate((index) => {
|
||||||
const res = document.querySelector(`#answer > div:nth-child(${index})`).childNodes[4].textContent;
|
const res = document.querySelector(`#answer > div:nth-child(${index})`).childNodes[4].textContent;
|
||||||
return res;
|
return res;
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,20 @@ Structures.extend("Guild", g => {
|
||||||
}
|
}
|
||||||
} catch (e) { }
|
} 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) {
|
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);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue