mirror of
https://github.com/danbulant/Shasha
synced 2026-06-19 14:21:37 +00:00
refactor: changed operator ?? to ||
This commit is contained in:
parent
2dae3c4b96
commit
a181614181
16 changed files with 39 additions and 32 deletions
|
|
@ -80,7 +80,7 @@ module.exports = class avatar extends commando.Command {
|
|||
}
|
||||
} else {
|
||||
let emb = new MessageEmbed()
|
||||
.setTitle(user.displayName ?? user.username)
|
||||
.setTitle(user.displayName || user.username)
|
||||
.setImage(avatar)
|
||||
.setFooter(footerQuote);
|
||||
if (user.displayColor) emb.setColor(user.displayColor);
|
||||
|
|
|
|||
|
|
@ -18,19 +18,20 @@ module.exports = class profile extends commando.Command {
|
|||
});
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {Message} msg
|
||||
* @param {*} arg
|
||||
* @returns
|
||||
*/
|
||||
async run(msg, arg) {
|
||||
if (msg.guild && !msg.guild.DB) await msg.guild.dbLoad();
|
||||
if (!msg.author.DB) await msg.author.dbLoad();
|
||||
let TM, title = "";
|
||||
if (!arg) TM = msg.author; else TM = await getUser(msg, arg, true);
|
||||
if (!arg) TM = msg.author; else TM = await getUser(msg, arg, msg.guild);
|
||||
if (!TM) return trySend(msg.client, msg, "Bro stop lookin for yo imaginary gf");
|
||||
if (TM.bot) title += "`[BOT]` ";
|
||||
title += `\`${TM.tag}\`'s Profile`;
|
||||
|
||||
const MEM = msg.guild.member(TM),
|
||||
const MEM = msg.guild ? msg.guild.member(TM) : false,
|
||||
emb = defaultImageEmbed(msg, null, title),
|
||||
INT2 = Interval.fromDateTimes(DateTime.fromJSDate(TM.createdAt), DateTime.now());
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ module.exports = class cloneembed extends commando.Command {
|
|||
return trySend(this.client, msg, 'ypu don\'t know what an embed is? <:cathmmLife:772716381874946068>');
|
||||
}
|
||||
if (!args[0]) {
|
||||
return trySend(this.client, msg, 'Which message??');
|
||||
return trySend(this.client, msg, 'Which message||');
|
||||
}
|
||||
const sent = theMes.embeds.map(r => trySend(this.client, msg, {content:content,embed:r}));
|
||||
if (sent) {
|
||||
|
|
|
|||
|
|
@ -409,11 +409,11 @@ module.exports = class embmaker extends commando.Command {
|
|||
}
|
||||
}
|
||||
}
|
||||
sent.push(trySend(this.client, channel ?? msg.channel, { content: content, embed: embed, files: newAttach }).catch(e => noPerm(msg)));
|
||||
sent.push(trySend(this.client, channel || msg.channel, { content: content, embed: embed, files: newAttach }).catch(e => noPerm(msg)));
|
||||
}
|
||||
if (await sent[0]) {
|
||||
tryReact(msg, "a:yesLife:794788847996370945");
|
||||
ranLog(msg, ("```js\n" + JSON.stringify(embed, (k, v) => v ?? undefined, 2) + "```"));
|
||||
ranLog(msg, ("```js\n" + JSON.stringify(embed, (k, v) => v || undefined, 2) + "```"));
|
||||
} else {
|
||||
noPerm(msg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ module.exports = class mesemb extends commando.Command {
|
|||
if (!message) {
|
||||
return trySend(this.client, msg, "404 message not found!");
|
||||
}
|
||||
const mesemb = '```js\n' + JSON.stringify(message.embeds, (k, v) => v ?? undefined, 2).replace(/```/g,"`\\``") + '```';
|
||||
const mesemb = '```js\n' + JSON.stringify(message.embeds, (k, v) => v || undefined, 2).replace(/```/g,"`\\``") + '```';
|
||||
return trySend(this.client, msg, { content: 'Collected:' + mesemb, split: { maxLength: 2000, char: ",", append: ',```', prepend:'```js\n' }});
|
||||
}
|
||||
};
|
||||
|
|
@ -18,10 +18,10 @@ module.exports = class mesinfo extends commando.Command {
|
|||
if (!message) {
|
||||
return trySend(this.client, msg, "No message with that ID <:catstareLife:794930503076675584>")
|
||||
}
|
||||
const mesinfo = 'Collected:```js\n'+JSON.stringify(message, (k, v) => v ?? undefined, 2).replace(/```/g,"`\\``")+'```';
|
||||
const mesinfo = 'Collected:```js\n'+JSON.stringify(message, (k, v) => v || undefined, 2).replace(/```/g,"`\\``")+'```';
|
||||
const mentionJSON = message.mentions.toJSON();
|
||||
const sendMentionInfo = 'Mentions:```js\n'+JSON.stringify(mentionJSON, (k, v) => v ?? undefined, 2)+'```';
|
||||
const Attachments = 'Attachments:```js\n'+JSON.stringify(message.attachments, (k, v) => v ?? undefined, 2)+'```';
|
||||
const sendMentionInfo = 'Mentions:```js\n'+JSON.stringify(mentionJSON, (k, v) => v || undefined, 2)+'```';
|
||||
const Attachments = 'Attachments:```js\n'+JSON.stringify(message.attachments, (k, v) => v || undefined, 2)+'```';
|
||||
const sendmesinfo = mesinfo+sendMentionInfo+Attachments;
|
||||
return trySend(this.client, msg, {content:sendmesinfo,split:{ maxLength: 2000, char: ",",append: ',```', prepend: '```js\n' }});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ module.exports = class perms extends commando.Command {
|
|||
channel = getChannel(msg, use);
|
||||
if (!channel || !(channel instanceof GuildChannel)) {
|
||||
channel = undefined;
|
||||
mes += "Channel unexisted???\n";
|
||||
mes += "Channel unexisted||?\n";
|
||||
}
|
||||
}
|
||||
const find = arg.replace(/(?<!\\)--ch [^ ]*\s?/, "");
|
||||
|
|
|
|||
|
|
@ -31,10 +31,10 @@ module.exports = class uinfo extends commando.Command {
|
|||
const member = msg.guild.member(profile);
|
||||
let result = "";
|
||||
if (profile) {
|
||||
result += 'User: '+profile.tag+'```js\n' + JSON.stringify(profile, (k, v) => v ?? undefined, 2)+'```';
|
||||
result += 'User: '+profile.tag+'```js\n' + JSON.stringify(profile, (k, v) => v || undefined, 2)+'```';
|
||||
}
|
||||
if (member) {
|
||||
result += 'As member: '+member.displayName+'```js\n'+JSON.stringify(member, (k, v) => v ?? undefined, 2)+'```';
|
||||
result += 'As member: '+member.displayName+'```js\n'+JSON.stringify(member, (k, v) => v || undefined, 2)+'```';
|
||||
if ((member.displayColor)) {
|
||||
result += 'Display color:```js\n'+member.displayColor+'```';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ function timestampAt(client) {
|
|||
*/
|
||||
function makeJSONMessage(object) {
|
||||
console.log(typeof object, object);
|
||||
return { content: '```js\n' + JSON.stringify(object, (k, v) => v ?? undefined, 2) + '```', split: { maxLength: 2000, char: ",", append: ',```', prepend: '```js\n' } };
|
||||
return { content: '```js\n' + JSON.stringify(object, (k, v) => v || undefined, 2) + '```', split: { maxLength: 2000, char: ",", append: ',```', prepend: '```js\n' } };
|
||||
}
|
||||
|
||||
module.exports = { timestampAt, makeJSONMessage }
|
||||
|
|
@ -12,12 +12,12 @@ let blockChannelUpdate = false;
|
|||
* @param {GuildChannel} newChannel
|
||||
*/
|
||||
async function run(oldChannel, newChannel) {
|
||||
const dateNow = new Date();
|
||||
if (!newChannel.guild.DB) await newChannel.guild.dbLoad();
|
||||
if (!newChannel.guild.DB.eventChannels?.guild) return;
|
||||
const logChannel = newChannel.guild.channels.cache.get(newChannel.guild.DB.eventChannels.guild);
|
||||
if (!logChannel) return;
|
||||
|
||||
const dateNow = new Date();
|
||||
const diff = newChannel.permissionOverwrites.difference(oldChannel.permissionOverwrites),
|
||||
emb = defaultEventLogEmbed(newChannel.guild);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,9 +29,10 @@ module.exports = async (GUILD, USER) => {
|
|||
emb.setTitle(`${USER.bot ? "`[BOT]` " : ""}\`${USER.tag}\` banned` + (audit?.executor ? ` by ${audit.executor.bot ? "`[BOT]` " : ""}\`${audit.executor.tag}\`` : ""))
|
||||
.setColor(getColor("red"))
|
||||
.setThumbnail(USER.displayAvatarURL({ size: 4096, format: "png", dynamic: true }))
|
||||
.addField("User", `<@${USER.id}>\n(${USER.id})`);
|
||||
if (audit?.executor)
|
||||
emb.setAuthor(emb.author.name, audit.executor.displayAvatarURL({ size: 128, format: "png", dynamic: true }));
|
||||
return trySend(GUILD.client, log, emb);
|
||||
.addField("User", `<@${USER.id}>\n(${USER.id})`, true);
|
||||
if (audit?.executor) {
|
||||
emb.setAuthor(emb.author.name, audit.executor.displayAvatarURL({ size: 128, format: "png", dynamic: true }))
|
||||
.addField("Moderator", `<@${audit.executor.id}> (${audit.executor.id})`, true);
|
||||
} return trySend(GUILD.client, log, emb);
|
||||
}
|
||||
}
|
||||
|
|
@ -29,9 +29,10 @@ module.exports = async (GUILD, USER) => {
|
|||
emb.setTitle(`${USER.bot ? "`[BOT]` " : ""}\`${USER.tag}\` unbanned` + (audit?.executor ? ` by ${audit.executor.bot ? "`[BOT]` " : ""}\`${audit.executor.tag}\`` : ""))
|
||||
.setColor(getColor("red"))
|
||||
.setThumbnail(USER.displayAvatarURL({ size: 4096, format: "png", dynamic: true }))
|
||||
.addField("User", `<@${USER.id}>\n(${USER.id})`);
|
||||
if (audit.executor)
|
||||
emb.setAuthor(emb.author.name, audit.executor.displayAvatarURL({ size: 128, format: "png", dynamic: true }));
|
||||
return trySend(GUILD.client, log, emb);
|
||||
.addField("User", `<@${USER.id}>\n(${USER.id})`, true);
|
||||
if (audit.executor) {
|
||||
emb.setAuthor(emb.author.name, audit.executor.displayAvatarURL({ size: 128, format: "png", dynamic: true }))
|
||||
.addField("Moderator", `<@${audit.executor.id}> (${audit.executor.id})`, true);
|
||||
} return trySend(GUILD.client, log, emb);
|
||||
}
|
||||
}
|
||||
|
|
@ -46,7 +46,7 @@ module.exports = async (msg) => {
|
|||
for (const add of toField) emb.addField(emb.fields.length === 2 ? "Attachment" : "", add.join("\n"));
|
||||
}
|
||||
if (msg.embeds?.[0]) {
|
||||
const arr = JSON.stringify(msg.embeds[0], (k, v) => v ?? undefined, 2).replace(/```/g, "`\\``").split(",");
|
||||
const arr = JSON.stringify(msg.embeds[0], (k, v) => v || undefined, 2).replace(/```/g, "`\\``").split(",");
|
||||
const toField = splitOnLength(arr, 1010, ",\n");
|
||||
for (let i = 0; i < toField.length; i++) emb.addField(i === 0 ? "Embed" : "", "```js\n" + toField[i].join(",") + ((i !== toField.length - 1) ? "," : "") + "```");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ function multipleMembersFound(msg, arr, key, max = 4, withID, withNick) {
|
|||
function findMemberRegEx(base, key) {
|
||||
if (!base || !key) return;
|
||||
const re = new RegExp(key, "i");
|
||||
return (base.guild ?? base).members.cache.filter(r => re.test(r.displayName) || re.test(r.user.tag)).map(r => r);
|
||||
return (base.guild || base).members.cache.filter(r => re.test(r.displayName) || re.test(r.user.tag)).map(r => r);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -199,7 +199,7 @@ async function trySend(client, msgOrChannel, content, checkAd = true) {
|
|||
if (typeof content === "string") content = adCheck(content);
|
||||
}
|
||||
}
|
||||
if (!((msgOrChannel instanceof Message) || (msgOrChannel instanceof TextChannel) || (msgOrChannel instanceof DMChannel))) return errLog(e, null, client, false, "[TRYSEND] Invalid {msgOrChannel} type.```js\n" + JSON.stringify(msgOrChannel, (k, v) => v ?? undefined, 2) + "```");
|
||||
if (!((msgOrChannel instanceof Message) || (msgOrChannel instanceof TextChannel) || (msgOrChannel instanceof DMChannel))) return errLog(e, null, client, false, "[TRYSEND] Invalid {msgOrChannel} type.```js\n" + JSON.stringify(msgOrChannel, (k, v) => v || undefined, 2) + "```");
|
||||
let ret = await (msgOrChannel.channel || msgOrChannel).send(content).catch(/*msgOrChannel.channel ? noPerm(msgOrChannel) :*/ e => errLog(e, msgOrChannel, client));
|
||||
if (ret?.[0] instanceof Message) {
|
||||
// console.log(ret, typeof ret);
|
||||
|
|
@ -445,7 +445,7 @@ function defaultEventLogEmbed(guild) {
|
|||
.setColor(getColor(C.displayColor))
|
||||
.setAuthor(guild.name)
|
||||
.setFooter((guild.DB?.defaultEmbed?.footerQuote ?
|
||||
guild.DB.defaultEmbed.footerQuote : ""), guild.iconURL({ format: "png", size: 128, dynamic: true }))
|
||||
guild.DB.defaultEmbed.footerQuote : ""), guild.iconURL({ format: "png", size: 128, dynamic: true }))
|
||||
.setTimestamp(new Date());
|
||||
}
|
||||
|
||||
|
|
@ -507,10 +507,10 @@ const reValidURL = /^https?:\/\/[^\s\n]+\.[^\s\n][^\s\n]/;
|
|||
* Get user
|
||||
* @param {Message} msg
|
||||
* @param {string} key
|
||||
* @param {boolean} inGuild
|
||||
* @param {any} inGuild
|
||||
* @returns {User}
|
||||
*/
|
||||
async function getUser(msg, key, inGuild = false) {
|
||||
async function getUser(msg, key, inGuild) {
|
||||
if (!(msg || key)) return;
|
||||
const use = cleanMentionID(key);
|
||||
if (!use || use.length === 0) return;
|
||||
|
|
|
|||
|
|
@ -334,7 +334,11 @@ Structures.extend("User", u => {
|
|||
const CL = guild.member(this.client.user);
|
||||
if (!moderator.isAdmin || !CL.isAdmin) throw new Error("Missing permissions");
|
||||
let already = false, cant = false;
|
||||
await guild.members.unban(this, reason);
|
||||
await guild.members.unban(this, reason).catch(e => {
|
||||
if (!/Unknown Ban/.test(e.message)) {
|
||||
throw new Error(e.message);
|
||||
};
|
||||
});
|
||||
// .catch(e => {
|
||||
|
||||
// });
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ module.exports = {
|
|||
}
|
||||
console.log("Session:");
|
||||
for (let i = 0; i < C.length; i++) console.log(C[i].guild.name, C[i].guild.id, i + ":", C[i].name, C[i].id);
|
||||
} else if (C[num]) return C[num].send(emoteMessage(client, sl ? arg.slice(num?.toString().length).trim() ?? "hi" : arg)).catch(console.error); else {
|
||||
} else if (C[num]) return C[num].send(emoteMessage(client, sl ? arg.slice(num?.toString().length).trim() || "hi" : arg)).catch(console.error); else {
|
||||
console.log('No session. Available sessions:');
|
||||
for (let i = 0; i < C.length; i++) console.log(C[i].guild.name, C[i].guild.id, i + ":", C[i].name, C[i].id);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue