mirror of
https://github.com/danbulant/Shasha
synced 2026-06-06 16:10:19 +00:00
Merge branch 'Neko-Life:main' into main
This commit is contained in:
commit
bca8ed27ff
12 changed files with 95 additions and 241 deletions
3
.gitignore
vendored
3
.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/
|
||||||
|
|
@ -119,5 +120,3 @@ dist
|
||||||
.yarn/build-state.yml
|
.yarn/build-state.yml
|
||||||
.yarn/install-state.gz
|
.yarn/install-state.gz
|
||||||
.pnp.*
|
.pnp.*
|
||||||
settings.sqlite3
|
|
||||||
settings.sqlite3
|
|
||||||
|
|
|
||||||
4
Main.js
4
Main.js
|
|
@ -68,6 +68,10 @@ client.on("guildMemberAdd", newMember => {
|
||||||
//console.log(`New member ${newMember.displayName} (${newMember.user.tag}) (${newMember.id}) joined ${newMember.guild.name} (${newMember.guild.id})! Now it has ${newMember.guild.memberCount} total members count.`);
|
//console.log(`New member ${newMember.displayName} (${newMember.user.tag}) (${newMember.id}) joined ${newMember.guild.name} (${newMember.guild.id})! Now it has ${newMember.guild.memberCount} total members count.`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
client.login(configFile.token);
|
client.login(configFile.token);
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const { trySend } = require("../../resources/functions");
|
|
||||||
|
|
||||||
const commando = require("@iceprod/discord.js-commando"),
|
|
||||||
{ database } = require("../../database/mongo"),
|
|
||||||
col = database.collection("Experiment");
|
|
||||||
|
|
||||||
module.exports = class dropexp extends commando.Command {
|
|
||||||
constructor(client) {
|
|
||||||
super(client, {
|
|
||||||
name: "dropexp",
|
|
||||||
memberName: "dropexp",
|
|
||||||
group: "experiment",
|
|
||||||
description: "description",
|
|
||||||
ownerOnly:true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
run(msg, arg) {
|
|
||||||
col.drop().then(trySend(this.client, msg, "cleared")).catch(e => trySend(this.client, msg, `\`\`\`js\n${e.stack}\`\`\``));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const commando = require("@iceprod/discord.js-commando");
|
|
||||||
const { errLog, trySend, ranLog } = require("../../resources/functions");
|
|
||||||
const { database } = require("../../database/mongo");
|
|
||||||
const exp = database.collection("Experiment");
|
|
||||||
|
|
||||||
module.exports = class mydatabase extends commando.Command {
|
|
||||||
constructor(client) {
|
|
||||||
super(client, {
|
|
||||||
name: "mydatabase",
|
|
||||||
memberName: "mydatabase",
|
|
||||||
group: "experiment",
|
|
||||||
description: "Show all document collection.",
|
|
||||||
ownerOnly:true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async run(msg) {
|
|
||||||
if (!msg.guild?.member(msg.author).hasPermission("MANAGE_GUILD")) {
|
|
||||||
return trySend(this.client, msg, "No");
|
|
||||||
}
|
|
||||||
const data = msg.guild ? "Guild" : "User";
|
|
||||||
const doc = msg.guild?.id ?? msg.author.id,
|
|
||||||
dbExp = await exp.find({}).toArray();
|
|
||||||
database.collection(data).find({document: doc}).toArray(async (e, fetched) => {
|
|
||||||
if (e) {
|
|
||||||
return errLog(e, msg, this.client);
|
|
||||||
}
|
|
||||||
let mes = `Fetched documents for ${msg.guild ? `server **${msg.guild.name}**` : `**${msg.author.tag}**`}`;
|
|
||||||
mes = `${mes}\`\`\`js\n${JSON.stringify(fetched, null, 2)}\`\`\`` + `\`\`\`js\n${JSON.stringify(dbExp, null, 2)}\`\`\``;
|
|
||||||
trySend(this.client, msg, {content:mes,split:{maxLength:2000,append:",```",prepend:"```js\n",char:","}});
|
|
||||||
return ranLog(msg, "mydatabase", fetched);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const { trySend, cleanMentionID } = require("../../resources/functions");
|
|
||||||
|
|
||||||
const commando = require("@iceprod/discord.js-commando"),
|
|
||||||
{ database } = require("../../database/mongo"),
|
|
||||||
col = database.collection("Experiment");
|
|
||||||
|
|
||||||
module.exports = class regive extends commando.Command {
|
|
||||||
constructor(client) {
|
|
||||||
super(client, {
|
|
||||||
name: "regive",
|
|
||||||
memberName: "regive",
|
|
||||||
group: "experiment",
|
|
||||||
description: "description"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {commando.CommandoMessage} msg
|
|
||||||
* @param {*} arg
|
|
||||||
*/
|
|
||||||
async run(msg, arg ) {
|
|
||||||
const args = arg.split(" "),
|
|
||||||
member = msg.guild.member(cleanMentionID(args[0])),
|
|
||||||
doc = await col.findOne({"rolesScreenshot.name":member.id}).catch(e => trySend(this.client, msg, "```js\n" + e.stack + "```")),
|
|
||||||
test = doc.rolesScreenshot.data;
|
|
||||||
await member.roles.add(test.map(r => r)).catch(e => trySend(this.client, msg, "```js\n" + e.stack + "```"));
|
|
||||||
await member.roles.remove("772114626720432128").catch(e => trySend(this.client, msg, "```js\n" + e.stack + "```"))
|
|
||||||
trySend(this.client, msg, "Success!"+"```js\n"+JSON.stringify(test, null, 2)+"```");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const commando = require("@iceprod/discord.js-commando");
|
|
||||||
const { cleanMentionID, trySend } = require("../../resources/functions");
|
|
||||||
|
|
||||||
module.exports = class replace extends commando.Command {
|
|
||||||
constructor(client) {
|
|
||||||
super(client, {
|
|
||||||
name: "replace",
|
|
||||||
memberName: "replace",
|
|
||||||
group: "experiment",
|
|
||||||
description: "replace test"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {commando.CommandoMessage} msg
|
|
||||||
* @param {*} arg
|
|
||||||
*/
|
|
||||||
async run(msg, arg) {
|
|
||||||
const args = arg.split(" "),
|
|
||||||
targetID = cleanMentionID(args[0]),
|
|
||||||
targetUser = msg.guild.member(targetID);
|
|
||||||
await targetUser.roles.remove(targetUser.roles.cache.array()).catch(e => trySend(this.client, msg, "```js\n" + e.stack + "```"));
|
|
||||||
await targetUser.roles.add("772114626720432128").catch(e => trySend(this.client, msg, "```js\n" + e.stack + "```"));
|
|
||||||
//trySend(this.client, msg, "```js\n"+JSON.stringify(mes, null, 2)+"```");
|
|
||||||
trySend(this.client, msg, "Replaced!");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const commando = require("@iceprod/discord.js-commando");
|
|
||||||
const { ranLog, trySend, errLog } = require("../../resources/functions");
|
|
||||||
const { database } = require("../../database/mongo");
|
|
||||||
|
|
||||||
module.exports = class resetdatabase extends commando.Command {
|
|
||||||
constructor(client) {
|
|
||||||
super(client, {
|
|
||||||
name: "resetdatabase",
|
|
||||||
memberName: "resetdatabase",
|
|
||||||
group: "experiment",
|
|
||||||
description: "Reset your server/private database.",
|
|
||||||
ownerOnly:true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
async run(msg) {
|
|
||||||
if (!msg.guild?.member(msg.author).hasPermission("MANAGE_GUILD")) {
|
|
||||||
return trySend(this.client, msg, "No");
|
|
||||||
}
|
|
||||||
const doc = msg.guild?.id ?? msg.author.id;
|
|
||||||
const col = database.collection(msg.guild ? "Guild" : "User");
|
|
||||||
trySend(this.client, msg, "Are you sure? You will lose every saved settings. This process can't be undone. Type `yes` in 30 seconds to confirm.");
|
|
||||||
const confirm = msg.channel.createMessageCollector(() => true, {time:30000});
|
|
||||||
confirm.on("collect", h => {
|
|
||||||
if (h.author === msg.author) {
|
|
||||||
if (h.content.trim() === "yes") {
|
|
||||||
col.findOneAndDelete({document: doc})
|
|
||||||
.then(
|
|
||||||
trySend(this.client, msg, "Wiped!"))
|
|
||||||
.catch(e => errLog(e, msg, this.client));
|
|
||||||
} else {
|
|
||||||
trySend(this.client, msg, "Request aborted.");
|
|
||||||
}
|
|
||||||
confirm.stop();
|
|
||||||
return ranLog(msg, "resetdatabase", h.content);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const commando = require("@iceprod/discord.js-commando"),
|
|
||||||
{ database } = require("../../database/mongo");
|
|
||||||
const { trySend } = require("../../resources/functions"),
|
|
||||||
col = database.collection("Guild");
|
|
||||||
|
|
||||||
module.exports = class resetinfractions extends commando.Command {
|
|
||||||
constructor(client) {
|
|
||||||
super(client, {
|
|
||||||
name: "resetinfractions",
|
|
||||||
memberName: "resetinfractions",
|
|
||||||
group: "experiment",
|
|
||||||
description: "description",
|
|
||||||
guildOnly:true,
|
|
||||||
ownerOnly:true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
run(msg) {
|
|
||||||
col.updateOne({document:msg.guild.id}, {$set:{"moderation.infractions":[]}}, {upsert:true}, (e, r) => {
|
|
||||||
if (e) {
|
|
||||||
return trySend(this.client, msg, "```js\n"+e.stack+"```");
|
|
||||||
}
|
|
||||||
col.updateOne({document:msg.guild.id}, {$set:{"moderation.settings.mute": {}}});
|
|
||||||
return trySend(this.client, msg, "Wiped!");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const { cleanMentionID, trySend } = require("../../resources/functions");
|
|
||||||
|
|
||||||
const commando = require("@iceprod/discord.js-commando"),
|
|
||||||
{ database } = require("../../database/mongo"),
|
|
||||||
dbExp = database.collection("Experiment");
|
|
||||||
|
|
||||||
module.exports = class screenshot extends commando.Command {
|
|
||||||
constructor(client) {
|
|
||||||
super(client, {
|
|
||||||
name: "screenshot",
|
|
||||||
memberName: "screenshot",
|
|
||||||
group: "experiment",
|
|
||||||
description: "description"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {commando.CommandoMessage} msg
|
|
||||||
* @param {*} arg
|
|
||||||
*/
|
|
||||||
async run(msg, arg) {
|
|
||||||
const args = arg.split(" "),
|
|
||||||
targetID = cleanMentionID(args[0]),
|
|
||||||
targetUser = msg.guild.member(targetID),
|
|
||||||
test = targetUser.roles.cache.map(r => r.id);
|
|
||||||
//trySend(this.client,msg,{content:`\`\`\`js\n${test}\`\`\``,split:true})
|
|
||||||
await dbExp.insertOne({ rolesScreenshot: { name: targetUser.id, data: test }}).catch(e => trySend(this.client, msg, "```js\n" + e.stack + "```"));
|
|
||||||
trySend(this.client, msg, "Sceenshoted!")
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -115,10 +115,10 @@ module.exports = class mute extends commando.Command {
|
||||||
const found = findChannelRegEx(msg, key);
|
const found = findChannelRegEx(msg, key);
|
||||||
logChannel = found[0];
|
logChannel = found[0];
|
||||||
}
|
}
|
||||||
if (/^none$/.test(key)) {
|
if (/^none$/i.test(key)) {
|
||||||
logChannel = undefined;
|
logChannel = undefined;
|
||||||
}
|
}
|
||||||
if (logChannel || /^none$/.test(key)) {
|
if (logChannel || /^none$/i.test(key)) {
|
||||||
theSettingUp.logChannel = logChannel?.id;
|
theSettingUp.logChannel = logChannel?.id;
|
||||||
} else {
|
} else {
|
||||||
resultMsg += `No channel found for: **${argument}**\n`;
|
resultMsg += `No channel found for: **${argument}**\n`;
|
||||||
|
|
@ -134,10 +134,10 @@ module.exports = class mute extends commando.Command {
|
||||||
const found = findRoleRegEx(msg, key);
|
const found = findRoleRegEx(msg, key);
|
||||||
role = found[0]?.id;
|
role = found[0]?.id;
|
||||||
}
|
}
|
||||||
if (/^none$/.test(key)) {
|
if (/^none$/i.test(key)) {
|
||||||
role = undefined;
|
role = undefined;
|
||||||
}
|
}
|
||||||
if (role || /^none$/.test(key)) {
|
if (role || /^none$/i.test(key)) {
|
||||||
theSettingUp.role = role;
|
theSettingUp.role = role;
|
||||||
} else {
|
} else {
|
||||||
resultMsg += `No role found for: **${argument}**\n`;
|
resultMsg += `No role found for: **${argument}**\n`;
|
||||||
|
|
@ -251,10 +251,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) {
|
if (!settingUp && mentions.length === 1 && mentions[0].length === 0) {
|
||||||
return trySend(this.client, msg, "Who are 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]]>`");
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
const commando = require("@iceprod/discord.js-commando");
|
const commando = require("@iceprod/discord.js-commando");
|
||||||
const { ranLog, errLog, trySend, sentAdCheck, tryReact } = require("../../resources/functions");
|
const { ranLog, errLog, trySend, sentAdCheck, tryReact, findChannelRegEx, cleanMentionID } = require("../../resources/functions");
|
||||||
|
|
||||||
module.exports = class send extends commando.Command {
|
module.exports = class send extends commando.Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
|
|
@ -9,36 +9,37 @@ module.exports = class send extends commando.Command {
|
||||||
memberName: "send",
|
memberName: "send",
|
||||||
group: "utility",
|
group: "utility",
|
||||||
description: "Send message to designated channel.",
|
description: "Send message to designated channel.",
|
||||||
userPermissions:["MANAGE_MESSAGES"]
|
guildOnly:true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
async run(msg, args ) {
|
async run(msg, args ) {
|
||||||
const comarg = args.trim().split(/ +/);
|
const comarg = args.trim().split(/ +/);
|
||||||
const bot = this.client;
|
|
||||||
let at = comarg[0];
|
let at = comarg[0];
|
||||||
if (!comarg[0]) {
|
if (!comarg[0]) {
|
||||||
return trySend(this.client, msg, 'Where?!?');
|
return trySend(this.client, msg, 'Where?!?');
|
||||||
}
|
}
|
||||||
if (comarg[0].startsWith('<#') && comarg[0].endsWith('>')) {
|
const search = cleanMentionID(comarg[0]),
|
||||||
at = comarg[0].slice(2, -1);
|
channel = findChannelRegEx(msg, search)[0],
|
||||||
}
|
sendTheMes = args.slice(comarg[0].length).trim();
|
||||||
const channel = bot.channels.cache.get(at);
|
|
||||||
const sendTheMes = args.slice(comarg[0].length).trim();
|
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
return trySend(this.client, msg, "Give me the right `channel_[mention, ID]` bruh");
|
return trySend(this.client, msg, "That channel is like your gf. Doesn't exist <:cathmmLife:772716381874946068>");
|
||||||
|
} else {
|
||||||
|
if (!channel.permissionsFor(msg.author).has("SEND_MESSAGES")) {
|
||||||
|
return trySend(this.client, msg, "No <:cathmmLife:772716381874946068>");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (sendTheMes.length === 0) {
|
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"};
|
const sendThis = {content:sendTheMes, disableMentions:"all"};
|
||||||
if (msg.member?.hasPermission("ADMINISTRATOR")) {
|
if (msg.member?.hasPermission("MENTION_EVERYONE")) {
|
||||||
sendThis.disableMentions = "none";
|
sendThis.disableMentions = "none";
|
||||||
}
|
}
|
||||||
const send = await trySend(this.client, channel, sendThis);
|
const send = await trySend(this.client, channel, sendThis);
|
||||||
sentAdCheck(send);
|
sentAdCheck(send);
|
||||||
const filter = () => true;
|
const filter = () => true,
|
||||||
const 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 => {
|
||||||
try {
|
try {
|
||||||
msg.react(r.emoji);
|
msg.react(r.emoji);
|
||||||
|
|
|
||||||
70
resources/structures.js
Normal file
70
resources/structures.js
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const { Structures } = require("discord.js");
|
||||||
|
|
||||||
|
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 {
|
||||||
|
constructor(client, data) {
|
||||||
|
super(client, data);
|
||||||
|
this.settings = new Settings(client, "Guild", this.id);
|
||||||
|
}
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Structures.extend("User", User => {
|
||||||
|
return class Settings extends User {
|
||||||
|
constructor(client, data) {
|
||||||
|
super(client, data);
|
||||||
|
this.settings = new Settings(client, User, this.id);
|
||||||
|
}
|
||||||
|
embed = {
|
||||||
|
footer: {
|
||||||
|
text: undefined,
|
||||||
|
icon: undefined
|
||||||
|
},
|
||||||
|
timestamp: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue