mirror of
https://github.com/danbulant/Shasha
synced 2026-05-19 03:58:38 +00:00
No improvement on moderation cmds whatsoever
This commit is contained in:
parent
38af1b3e7c
commit
aef0bfbc5a
10 changed files with 69 additions and 37 deletions
6
Main.js
6
Main.js
|
|
@ -16,7 +16,7 @@ if (process.argv.includes("-d")) {
|
|||
|
||||
const sqlite = require('sqlite');
|
||||
const configFile = require('./config.json');
|
||||
const { errLog, trySend, noPerm, getUTCComparison, defaultEventLogEmbed } = require('./resources/functions');
|
||||
const { errLog, trySend, noPerm, getUTCComparison, defaultEventLogEmbed, getChannel } = require('./resources/functions');
|
||||
const { join } = require('path');
|
||||
const getColor = require("./resources/getColor");
|
||||
const { timestampAt } = require("./resources/debug");
|
||||
|
|
@ -102,6 +102,10 @@ client.on("guildMemberAdd", async (member) => {
|
|||
lgr.guildMemberAdd(member);
|
||||
});
|
||||
|
||||
client.on("guildBanAdd", async (GUILD, USER) => {
|
||||
lgr.guildBanAdd(GUILD, USER);
|
||||
});
|
||||
|
||||
client.on("messageDelete", async (msg) => {
|
||||
if (msg.author && !msg.author.dbLoaded && !msg.author.bot) await msg.author.dbLoad();
|
||||
if (msg.guild) {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ module.exports = class EvalCommand extends Command {
|
|||
description: 'Executes JavaScript code.',
|
||||
details: 'Only the bot owner(s) may use this command.',
|
||||
ownerOnly: true,
|
||||
hidden: true,
|
||||
|
||||
args: [
|
||||
{
|
||||
|
|
@ -30,7 +31,7 @@ module.exports = class EvalCommand extends Command {
|
|||
Object.defineProperty(this, '_sensitivePattern', { value: null, configurable: true });
|
||||
}
|
||||
|
||||
run(msg, args) {
|
||||
async run(msg, args) {
|
||||
// Make a bunch of helpers
|
||||
/* eslint-disable no-unused-vars */
|
||||
const message = msg;
|
||||
|
|
@ -59,7 +60,7 @@ module.exports = class EvalCommand extends Command {
|
|||
let hrDiff;
|
||||
try {
|
||||
const hrStart = process.hrtime();
|
||||
this.lastResult = eval(args.script);
|
||||
this.lastResult = await eval(args.script);
|
||||
hrDiff = process.hrtime(hrStart);
|
||||
} catch (err) {
|
||||
return msg.reply(`Error while evaluating: \`${err}\``);
|
||||
|
|
|
|||
|
|
@ -319,20 +319,16 @@ module.exports = class embmaker extends commando.Command {
|
|||
}
|
||||
if (value.startsWith("ch ")) {
|
||||
let ID = cleanMentionID(value.slice("ch ".length).trim());
|
||||
if (ID === "here") {
|
||||
channel = msg.channel;
|
||||
channel = getChannel(msg, ID, ["category", "voice"])
|
||||
if (!channel) {
|
||||
reportMessage += "**[CHANNEL]** Unknown channel.\n";
|
||||
} else {
|
||||
channel = getChannel(msg, ID, ["category", "voice"])
|
||||
if (!channel) {
|
||||
reportMessage += "**[CHANNEL]** Unknown channel.\n";
|
||||
} else {
|
||||
if ((channel instanceof GuildChannel) && !this.client.owners.includes(msg.author)) {
|
||||
const p = channel.permissionsFor(msg.author).serialize(),
|
||||
f = channel.permissionsFor(this.client.user).serialize();
|
||||
if (!p.EMBED_LINKS || !p.SEND_MESSAGES || !p.VIEW_CHANNEL || !f.EMBED_LINKS || !f.SEND_MESSAGES) {
|
||||
channel = undefined;
|
||||
reportMessage += "**[CHANNEL]** Missing permission.\n";
|
||||
}
|
||||
if ((channel instanceof GuildChannel) && !this.client.owners.includes(msg.author)) {
|
||||
const p = channel.permissionsFor(msg.author).serialize(),
|
||||
f = channel.permissionsFor(this.client.user).serialize();
|
||||
if (!p.EMBED_LINKS || !p.SEND_MESSAGES || !p.VIEW_CHANNEL || !f.EMBED_LINKS || !f.SEND_MESSAGES) {
|
||||
channel = undefined;
|
||||
reportMessage += "**[CHANNEL]** Missing permission.\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const commando = require("@iceprod/discord.js-commando"),
|
||||
{ getMember, trySend, defaultImageEmbed, getChannel } = require("../../resources/functions");
|
||||
{ getMember, trySend, defaultImageEmbed, getChannel } = require("../../resources/functions");
|
||||
const { Message, GuildChannel } = require("discord.js");
|
||||
const getColor = require("../../resources/getColor");
|
||||
|
||||
|
|
@ -28,17 +28,13 @@ module.exports = class perms extends commando.Command {
|
|||
const forC = arg.match(/(?<!\\)--c [^ ]*/)?.[0];
|
||||
if (forC) {
|
||||
const use = forC.slice(4).trim();
|
||||
if (use === "here") {
|
||||
channel = msg.channel;
|
||||
} else {
|
||||
channel = getChannel(msg, use);
|
||||
}
|
||||
channel = getChannel(msg, use);
|
||||
if (!channel || !(channel instanceof GuildChannel)) {
|
||||
channel = undefined;
|
||||
mes += "Channel unexisted???\n";
|
||||
}
|
||||
}
|
||||
const find = arg.replace(/(?<!\\)--c [^ ]*\s?/, "");
|
||||
const find = arg.replace(/(?<!\\)--ch [^ ]*\s?/, "");
|
||||
if (find.length > 0) {
|
||||
member = getMember(msg.guild, find)?.[0];
|
||||
} else {
|
||||
|
|
@ -46,7 +42,7 @@ module.exports = class perms extends commando.Command {
|
|||
}
|
||||
} else {
|
||||
member = msg.member;
|
||||
mes += `Args:\n\`user_[mention|ID|name]\` \`--c\` \`[channel_[name|ID]|here]\`\n`;
|
||||
mes += `Args:\n\`user_[mention|ID|name]\` \`--ch\` \`[channel_[name|ID]|here]\`\n\n`;
|
||||
}
|
||||
if (!member) {
|
||||
return trySend(this.client, msg, "Is that your gf?");
|
||||
|
|
@ -80,8 +76,8 @@ module.exports = class perms extends commando.Command {
|
|||
emb.addField(`In channel: \`${channel.name}\``, `\`\`\`js\n${chanres.join(", ")}\`\`\``);
|
||||
}
|
||||
emb.setDescription(mes)
|
||||
.setColor(getColor(member.displayColor))
|
||||
.setThumbnail(member.user.displayAvatarURL({size: 4096, format: "png", dynamic: true}));
|
||||
.setColor(getColor(member.displayColor))
|
||||
.setThumbnail(member.user.displayAvatarURL({ size: 4096, format: "png", dynamic: true }));
|
||||
return trySend(this.client, msg, emb);
|
||||
}
|
||||
};
|
||||
17
resources/eventsLogger/guildBanAdd.js
Normal file
17
resources/eventsLogger/guildBanAdd.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = async (GUILD, USER) => {
|
||||
if (GUILD.eventChannels?.ban) {
|
||||
if (USER.partial) USER = await USER.fetch();
|
||||
const log = getChannel(GUILD, GUILD.eventChannels.ban);
|
||||
if (!log) return;
|
||||
const emb = defaultEventLogEmbed(GUILD);
|
||||
const rea = (await GUILD.fetchBan(USER)).reason;
|
||||
emb.setDescription(rea ?? "No reason provided.")
|
||||
.setTitle(`User \`${USER.tag}\` banned`)
|
||||
.setColor(getColor("red"))
|
||||
.setThumbnail(USER.displayAvatarURL({ size: 4096, format: "png", dynamic: true }))
|
||||
.addField("User", `<@${USER.id}>\n(${USER.id})`);
|
||||
return trySend(GUILD.client, log, emb);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const { GuildMember } = require("discord.js");
|
||||
const { getChannel, defaultEventLogEmbed, trySend } = require("../functions");
|
||||
const { getChannel, defaultEventLogEmbed, trySend, splitOnLength } = require("../functions");
|
||||
const getColor = require("../getColor");
|
||||
|
||||
/**
|
||||
|
|
@ -15,14 +15,19 @@ module.exports = (member) => {
|
|||
if (!log) return;
|
||||
const days = Math.floor(new Date(new Date().valueOf() + member.client.matchTimestamp - member.joinedAt.valueOf()).valueOf() / 86400000),
|
||||
emb = defaultEventLogEmbed(member.guild);
|
||||
const RO = member.roles.cache.sort((a, b) => b.position - a.position).map(r => r.id).slice(0, -1),
|
||||
RU = splitOnLength(RO, 1010, ">, <@&");
|
||||
emb
|
||||
.setTitle("Member `" + member.user.tag + "` left")
|
||||
.setThumbnail(member.user.displayAvatarURL({ format: "png", size: 4096, dynamic: true }))
|
||||
.setColor(getColor("yellow"))
|
||||
.addField("Registered", "**" + member.user.createdAt.toUTCString().slice(0, -4) + "**", true)
|
||||
.addField("Joined", "**" + member.joinedAt.toUTCString().slice(0, -4) + "**" + `\n(${days > 0 ? `${days} day${days > 1 ? "s" : ""} ago` : "Today"})`, true)
|
||||
.addField("Roles", member.roles.cache.size > 1 ? "<@&" + member.roles.cache.sort((a, b) => b.position - a.position).map(r => r.id).slice(0, -1).join(">, <@&") + ">" : "`[NONE]`")
|
||||
.addField("Nick", "`" + member.displayName + "`")
|
||||
.setDescription(`<@!${member.id}> (${member.id}) just left.\nWe have ${member.guild.memberCount} total members now.`);
|
||||
for (const U of RU) {
|
||||
emb.addField(emb.fields.length === 3 ? "Roles" : "", U.length > 0 ? "<@&" + U.join(">, <@&") + ">" : "`[NONE]`");
|
||||
}
|
||||
return trySend(member.client, log, emb);
|
||||
}
|
||||
}
|
||||
|
|
@ -366,6 +366,7 @@ function getChannel(msg, key, exclude) {
|
|||
if (!key || key.length === 0 || !msg) return;
|
||||
const search = cleanMentionID(key);
|
||||
if (search.length === 0) return;
|
||||
if ((msg instanceof Message) && search === "here") return msg.channel;
|
||||
let channel;
|
||||
if (/^\d{17,19}$/.test(search)) {
|
||||
channel = (msg.guild || msg).channels.cache.get(search);
|
||||
|
|
@ -382,10 +383,10 @@ function getChannel(msg, key, exclude) {
|
|||
* @returns {GuildMember[]}
|
||||
*/
|
||||
function getMember(guild, key) {
|
||||
if (!guild) return;
|
||||
if (!(guild || key)) return;
|
||||
const use = cleanMentionID(key);
|
||||
let found = [];
|
||||
if (!use || use.length === 0) return;
|
||||
let found = [];
|
||||
if (/^\d{17,19}$/.test(use)) {
|
||||
found.push(guild.member(use));
|
||||
} else {
|
||||
|
|
@ -476,10 +477,9 @@ const reValidURL = /^https?:\/\/\w+\.\w\w/;
|
|||
function getUser(msg, key) {
|
||||
if (!(msg || key)) return;
|
||||
const use = cleanMentionID(key);
|
||||
if (!use || use.length === 0) return;
|
||||
let u;
|
||||
if (/^\d{17,19}$/.test(use)) u = msg.client.users.cache.get(use);
|
||||
console.log(u);
|
||||
if (!u) u = getMember(msg.guild, use)?.[0].user;
|
||||
if (/^\d{17,19}$/.test(use)) u = msg.client.users.cache.get(use); else u = getMember(msg.guild, use)?.[0].user;
|
||||
return u;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const axios = require("axios").default;
|
||||
const axios = require("axios").default,
|
||||
U = ["Yo", "Yyo", "Hello my friend", "Hey cutie <3", "What", "Wat", "Watchu want", "Hewwo", "UwU hwee", "OwO whats this", "Yoooooooooo", "Supp", "Whats good mein frien", "Iyo", "Hows doin", "Wassup", "Whats good", "Wanna chat?"];
|
||||
|
||||
//'4, 15, 10, 11, 14, 17, 18'
|
||||
|
||||
|
|
@ -29,7 +30,7 @@ async function chatAnswer(message) {
|
|||
text: u,
|
||||
lang: "en"
|
||||
}
|
||||
}).then(r => r.data.success.replace(/Sim doesn't know what you are talking about. Please teach me/, "Sorry but i don't speak gibberish")).catch(() => { });
|
||||
}).then(r => r.data.success.replace(/Sim doesn't know what you are talking about. Please teach me/, "Sorry but i don't speak gibberish").replace(/kemon acho babu/, U[Math.floor(Math.random() * U.length)])).catch(() => { });
|
||||
}
|
||||
|
||||
module.exports = { chatAnswer }
|
||||
|
|
|
|||
|
|
@ -196,4 +196,16 @@ Structures.extend("Message", e => {
|
|||
this.previousMessageID = channel.lastMessageID;
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Structures.extend("GuildMember", e => {
|
||||
return class GuildMember extends e {
|
||||
constructor(client, data, guild) {
|
||||
super(client, data, guild);
|
||||
}
|
||||
|
||||
async getInfractions() {
|
||||
return this.guild.getInfractions(this.id);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -4,7 +4,7 @@ const { join } = require("path");
|
|||
const requireAll = require("require-all");
|
||||
|
||||
module.exports = (client) => {
|
||||
client.tCmds = requireAll({dirname: join(__dirname, "tCmds")});
|
||||
client.tCmds = requireAll({ dirname: join(__dirname, "tCmds") });
|
||||
delete client.tCmds.resources;
|
||||
process.stdin.on("data", stdinBuffer => {
|
||||
// console.log(stdinBuffer.toJSON().data[0]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue