This commit is contained in:
Neko-Life 2021-07-22 16:57:11 +07:00
parent c7745c17fd
commit bf43f30da9
19 changed files with 69 additions and 64 deletions

View file

@ -10,12 +10,12 @@ module.exports = class baka extends commando.Command {
name: "baka",
memberName: "baka",
group: "image",
description: "Say \"baka\" :/"
description: "Say \"baka\""
});
}
async run(msg) {
msg.channel.startTyping();
const title = `${msg.guild ? msg.member.displayName : msg.author.username} is getting dere-dere~ =>`;
const title = `${msg.guild ? msg.member.displayName : msg.author.username} is getting dere-dere~`;
const image = await fetchNeko("baka");
const emb = defaultImageEmbed(msg, image); emb.setAuthor(title, msg.author.displayAvatarURL({ size: 128, format: "png", dynamic: true }));
return trySend(this.client, msg, emb);

View file

@ -10,12 +10,12 @@ module.exports = class cry extends commando.Command {
name: "cry",
memberName: "cry",
group: "image",
description: "Are you sad? :("
description: "Are you sad?"
});
}
async run(msg) {
msg.channel.startTyping();
const title = `${msg.guild ? msg.member.displayName : msg.author.username} is crying :<`;
const title = `${msg.guild ? msg.member.displayName : msg.author.username} is crying`;
const image = await fetchNeko("cry");
const emb = defaultImageEmbed(msg, image); emb.setAuthor(title, msg.author.displayAvatarURL({ size: 128, format: "png", dynamic: true }));
return trySend(this.client, msg, emb);

View file

@ -10,12 +10,12 @@ module.exports = class dance extends commando.Command {
name: "dance",
memberName: "dance",
group: "image",
description: "Let's dance =]"
description: "Let's dance"
});
}
async run(msg) {
msg.channel.startTyping();
const title = `${msg.guild ? msg.member.displayName : msg.author.username} is dancin :>`;
const title = `${msg.guild ? msg.member.displayName : msg.author.username} is dancin`;
const image = await fetchNeko("dance");
const emb = defaultImageEmbed(msg, image); emb.setAuthor(title, msg.author.displayAvatarURL({ size: 128, format: "png", dynamic: true }));
return trySend(this.client, msg, emb);

View file

@ -15,6 +15,6 @@ module.exports = class feed extends commando.Command {
});
}
async run(msg, arg) {
return trySend(this.client, msg, await interactEmbed(msg, arg, "feed", "^^"));
return trySend(this.client, msg, await interactEmbed(msg, arg, "feed", ""));
}
};

View file

@ -10,12 +10,12 @@ module.exports = class laugh extends commando.Command {
name: "laugh",
memberName: "laugh",
group: "image",
description: "Show your laugh :D"
description: "Show your laugh"
});
}
async run(msg) {
msg.channel.startTyping();
const title = `${msg.guild ? msg.member.displayName : msg.author.username} is laughin XD`;
const title = `${msg.guild ? msg.member.displayName : msg.author.username} is laughin`;
const image = await fetchNeko("laugh");
const emb = defaultImageEmbed(msg, image); emb.setAuthor(title, msg.author.displayAvatarURL({ size: 128, format: "png", dynamic: true }));
return trySend(this.client, msg, emb);

View file

@ -10,12 +10,12 @@ module.exports = class neko extends commando.Command {
name: "neko",
memberName: "neko",
group: "image",
description: "Neko."
description: "Neko"
});
}
async run(msg) {
msg.channel.startTyping();
const title = `${msg.guild ? msg.member.displayName : msg.author.username} ~Nyann~ (UwU) <3`;
const title = `${msg.guild ? msg.member.displayName : msg.author.username} ~Nyann~`;
const image = await fetchNeko("nekos");
const emb = defaultImageEmbed(msg, image); emb.setAuthor(title, msg.author.displayAvatarURL({ size: 128, format: "png", dynamic: true }));
return trySend(this.client, msg, emb);

View file

@ -15,6 +15,6 @@ module.exports = class poke extends commando.Command {
});
}
async run(msg, arg) {
return trySend(this.client, msg, await interactEmbed(msg, arg, "poke", ":>"));
return trySend(this.client, msg, await interactEmbed(msg, arg, "poke", ""));
}
};

View file

@ -78,7 +78,7 @@ module.exports = async (msg, arg, name, endsaT = "") => {
target[d.i] += " twice";
break;
case 3:
target[d.i] += " thrice XD";
target[d.i] += " thrice!";
break;
default:
target[d.i] += ` ${d.l} times ❤️`;

View file

@ -15,6 +15,6 @@ module.exports = class slap extends commando.Command {
});
}
async run(msg, arg) {
return trySend(this.client, msg, await interactEmbed(msg, arg, "slap", ":["));
return trySend(this.client, msg, await interactEmbed(msg, arg, "slap", ""));
}
};

View file

@ -10,12 +10,12 @@ module.exports = class smile extends commando.Command {
name: "smile",
memberName: "smile",
group: "image",
description: "Show your smile <3"
description: "Show your smile"
});
}
async run(msg) {
msg.channel.startTyping();
const title = `${msg.guild ? msg.member.displayName : msg.author.username} is smilin :D`;
const title = `${msg.guild ? msg.member.displayName : msg.author.username} is smilin`;
const image = await fetchNeko("smile");
const emb = defaultImageEmbed(msg, image); emb.setAuthor(title, msg.author.displayAvatarURL({ size: 128, format: "png", dynamic: true }));
return trySend(this.client, msg, emb);

View file

@ -10,12 +10,12 @@ module.exports = class smug extends commando.Command {
name: "smug",
memberName: "smug",
group: "image",
description: "Show your smug :]"
description: "Show your smug"
});
}
async run(msg) {
msg.channel.startTyping();
const title = `${msg.guild ? msg.member.displayName : msg.author.username} got a smug face >:]`;
const title = `${msg.guild ? msg.member.displayName : msg.author.username} got a smug face`;
const image = await fetchNeko("smug");
const emb = defaultImageEmbed(msg, image); emb.setAuthor(title, msg.author.displayAvatarURL({ size: 128, format: "png", dynamic: true }));
return trySend(this.client, msg, emb);

View file

@ -15,6 +15,6 @@ module.exports = class tickle extends commando.Command {
});
}
async run(msg, arg) {
return trySend(this.client, msg, await interactEmbed(msg, arg, "tickle", "XD"));
return trySend(this.client, msg, await interactEmbed(msg, arg, "tickle", ""));
}
};

View file

@ -15,7 +15,7 @@ module.exports = class wave extends commando.Command {
}
async run(msg) {
msg.channel.startTyping();
const title = `${msg.guild ? msg.member.displayName : msg.author.username} is waving :)`;
const title = `${msg.guild ? msg.member.displayName : msg.author.username} is waving`;
const image = await fetchNeko("wave");
const emb = defaultImageEmbed(msg, image); emb.setAuthor(title, msg.author.displayAvatarURL({ size: 128, format: "png", dynamic: true }));
return trySend(this.client, msg, emb);

View file

@ -2,8 +2,10 @@
const commando = require("@iceprod/discord.js-commando");
const { MessageEmbed, User, Message } = require("discord.js");
const { DateTime } = require("luxon");
const { errLog, trySend, getUser, defaultImageEmbed, splitOnLength } = require("../../resources/functions");
const getColor = require("../../resources/getColor");
const { DT_PRINT_FORMAT } = require("../moderation/src/duration");
module.exports = class profile extends commando.Command {
constructor(client) {
@ -29,13 +31,13 @@ module.exports = class profile extends commando.Command {
emb = defaultImageEmbed(msg, null, `\`${TM.tag}\`'s Profile`);
emb
.setThumbnail(TM.displayAvatarURL({ format: "png", size: 4096, dynamic: true }))
.addField("Registered", TM.createdAt.toUTCString().slice(0, -4), true)
.addField("Registered", DateTime.fromJSDate(TM.createdAt).toFormat(DT_PRINT_FORMAT), true)
.addField("ID", TM.id, true);
if (TM.description) emb.setDescription(TM.description);
if (MEM) {
const RI = MEM.roles.cache.sort((a, b) => b.position - a.position).map(r => r.id).slice(0, -1),
RFS = splitOnLength(RI, 1010, ">, <@&");
emb.addField("Joined", MEM.joinedAt.toUTCString().slice(0, -4))
emb.addField("Joined", DateTime.fromJSDate(MEM.joinedAt).toFormat(DT_PRINT_FORMAT))
.addField("Nick", `\`${MEM.displayName}\``);
if (RFS[0]?.length > 0) {
for (const p of RFS) {

View file

@ -1,9 +1,8 @@
'use strict';
const commando = require("@iceprod/discord.js-commando");
const { trySend, ranLog, parseDoubleDash } = require("../../resources/functions");
const { database } = require("../../database/mongo");
const col = database.collection("Guild");
const commando = require("@iceprod/discord.js-commando"),
{ trySend, ranLog, parseDoubleDash, getChannel, reValidURL } = require("../../resources/functions"),
ARGS_TEXT = `Provide argument: \`--c channel_[mention|ID], --t text_[footer_text], --i [footer_icon_URL]\``;
module.exports = class quoteotd extends commando.Command {
constructor(client) {
@ -12,52 +11,52 @@ module.exports = class quoteotd extends commando.Command {
memberName: "quoteotd",
group: "utility",
description: "Set Quote of the day channel and settings.",
details:"```\n--channel\n--text\n--icon```",
details: "```\n--channel\n--text\n--icon```",
guildOnly: true,
userPermissions:["ADMINISTRATOR"]
userPermissions: ["ADMINISTRATOR"]
});
}
async run(msg, arg) {
if (!msg.guild.DB) await msg.guild.DB.dbLoad();
const args = parseDoubleDash(arg);
if (args.length < 2) {
return trySend(this.client, msg, `Provide argument: \`--channel [mention, ID], --text [footer text], --icon [url footer icon]\``);
if (!args || args.length < 2) {
return trySend(this.client, msg, ARGS_TEXT);
}
let result = '';
for(const arr of args) {
for (const arr of args) {
const startW = arr.toLowerCase();
let data;
if (startW.startsWith('channel')) {
data = arr.slice('channel'.length).trim();
if (data.startsWith('<')) {
data = data.slice(2,-1);
}
if (!this.client.channels.cache.get(data)) {
return trySend(this.client, msg, 'Invalid/unknown channel provided! Try mentioning a channel or use `ChannelID`');
} else {
col.updateOne({document: msg.guild.id}, {$set: {"settings.quoteOTD.channel": data}, $setOnInsert: { document: msg.guild.id }}, { upsert: true });
result = result+`Channel set to \`${this.client.channels.cache.get(data).name}\`\n`;
}
if (startW.startsWith('c ')) {
data = arr.slice('c '.length).trim();
const CHAN = getChannel(msg, data, ["category", "voice"]);
msg.guild.DB.settings.quoteOTD.channel = CHAN.id;
result += `Channel set: **${CHAN.name}**\n`;
continue;
}
if (startW.startsWith('text')) {
data = arr.slice('text'.length).trim();
col.updateOne({document: msg.guild.id}, {$set: {"settings.quoteOTD.footerText": data}, $setOnInsert: { document: msg.guild.id }}, { upsert: true });
result = result+`Footer text set to \`${data}\`\n`;
if (startW.startsWith('t ')) {
data = arr.slice('t '.length).trim();
msg.guild.DB.settings.quoteOTD.footerText = data;
result += `Footer text set: \`${data}\`\n`;
continue;
}
if (startW.startsWith('icon')) {
data = arr.slice('icon'.length).trim();
if (!/^http/.test(data)) {
return trySend(this.client, msg, 'Invalid icon url provided!');
if (!reValidURL.test(data)) {
result += 'Invalid icon URL provided!\n';
continue;
} else {
col.updateOne({document: msg.guild.id}, {$set: {"settings.quoteOTD.footerIcon": data}, $setOnInsert: { document: msg.guild.id }}, { upsert: true });
result = result+`Footer icon set!\n`;
msg.guild.DB.settings.quoteOTD.footerIcon = data;
result += `Footer icon set!\n`;
continue;
}
}
}
if (result.length > 0) {
if (result !== 'Invalid icon URL provided!\n') msg.guild.DB.setDb(msg.guild.DB);
ranLog(msg, result);
return trySend(this.client, msg, result);
} else {
return trySend(this.client, msg, `Provide argument: \`--channel [mention, ID], --text [footer text], --icon [url footer icon]\``);
return trySend(this.client, msg, ARGS_TEXT);
}
}
};

View file

@ -20,7 +20,7 @@ module.exports = (member) => {
.setTitle("`" + member.user.tag + "` joined")
.setThumbnail(member.user.displayAvatarURL({ format: "png", size: 4096, dynamic: true }))
.setColor(getColor("cyan"))
.addField("Registered", "**" + DateTime.fromJSDate(member.user.createdAt).toFormat(DT_PRINT_FORMAT) + "**", true)
.addField("Registered", DateTime.fromJSDate(member.user.createdAt).toFormat(DT_PRINT_FORMAT), true)
.setDescription(`<@!${member.id}> (${member.id}) just joined.\nWe have ${member.guild.memberCount} total members now.`);
return trySend(member.client, log, emb);
}

View file

@ -15,16 +15,18 @@ module.exports = (member) => {
if (member.guild.DB.settings.eventChannels?.leave) {
const log = getChannel(member, member.guild.DB.settings.eventChannels.leave);
if (!log) return;
const days = intervalToDuration(Interval.fromDateTimes(DateTime.fromJSDate(member.joinedAt), DateTime.now())).strings.join(" "),
emb = defaultEventLogEmbed(member.guild),
const emb = defaultEventLogEmbed(member.guild),
RO = member.roles.cache.sort((a, b) => b.position - a.position).map(r => r.id).slice(0, -1),
RU = splitOnLength(RO, 1010, ">, <@&");
RU = splitOnLength(RO, 1010, ">, <@&"),
JO = DateTime.fromJSDate(member.user.createdAt),
LE = DateTime.fromJSDate(member.joinedAt),
INT = Interval.fromDateTimes(LE, DateTime.now());
emb
.setTitle("`" + member.user.tag + "` left")
.setThumbnail(member.user.displayAvatarURL({ format: "png", size: 4096, dynamic: true }))
.setColor(getColor("yellow"))
.addField("Registered", "**" + DateTime.fromJSDate(member.user.createdAt).toFormat(DT_PRINT_FORMAT) + "**", true)
.addField("Joined", "**" + DateTime.fromJSDate(member.joinedAt).toFormat(DT_PRINT_FORMAT) + "**" + `\n(${days > 0 ? `${days} day${days > 1 ? "s" : ""} ago` : "Today"})`, true)
.addField("Registered", JO.toFormat(DT_PRINT_FORMAT), true)
.addField("Joined", LE.toFormat(DT_PRINT_FORMAT) + `\n(${intervalToDuration(INT).strings.join(" ")} ago)`, true)
.addField("Nick", "`" + member.displayName + "`")
.setDescription(`<@!${member.id}> (${member.id}) just left.\nWe have ${member.guild.memberCount} total members now.`);
for (const U of RU) {

View file

@ -5,7 +5,6 @@ const { defaultEventLogEmbed, getChannel, trySend } = require("../functions");
const getColor = require("../getColor");
/**
*
* @param {GuildMember} memberold
* @param {GuildMember} membernew
* @returns
@ -19,9 +18,10 @@ module.exports = (memberold, membernew) => {
}
let log, thumbMes = "";
const emb = defaultEventLogEmbed(membernew.guild), oldT = memberold.toJSON().displayAvatarURL;
const oldAV = membernew.user.DB.cachedAvatarURL || oldT;
emb.setTitle("Profile `" + memberold.user.tag + "` updated")
.setColor(getColor("blue"));
if (membernew.user.DB.cachedAvatarURL || oldT) thumbMes += "This embed's thumbnail is the user's old avatar.\n";
if (oldAV) thumbMes += "This embed's thumbnail is the user's old avatar.\n";
if (membernew.guild.DB.settings.eventChannels?.memberRole) {
log = getChannel(membernew, membernew.guild.DB.settings.eventChannels.memberRole);
if (membernew.roles.cache.size > memberold.roles.cache.size) {
@ -35,16 +35,18 @@ module.exports = (memberold, membernew) => {
}
if (membernew.guild.DB.settings.eventChannels?.member && membernew.roles.cache.size === memberold.roles.cache.size) {
log = getChannel(membernew, membernew.guild.DB.settings.eventChannels.member);
if (membernew.displayName != memberold.displayName) {
if (membernew.displayName !== memberold.displayName) {
emb.addField("Nickname", "Changed from `" + memberold.displayName + "` to `" + membernew.displayName + "`");
}
if (membernew.user.DB.cachedAvatarURL != membernew.user.displayAvatarURL({ format: "png", size: 4096, dynamic: true })) {
if (membernew.user.DB.cachedAvatarURL !== membernew.user.displayAvatarURL({ format: "png", size: 4096, dynamic: true })) {
emb
.setImage(membernew.user.displayAvatarURL({ format: "png", size: 4096, dynamic: true }))
.addField("Avatar", thumbMes + "The image below is the user's new avatar.");
if (oldAV) emb.setThumbnail(oldAV);
}
}
membernew.user.refreshDb({ cachedAvatarURL: membernew.user.displayAvatarURL({ format: "png", size: "4096", dynamic: true }) });
membernew.user.DB.cachedAvatarURL = membernew.user.displayAvatarURL({ format: "png", size: 4096, dynamic: true });
membernew.user.setDb(membernew.user.DB);
if (!emb.fields || emb.fields.length === 0) return;
return trySend(membernew.client, log, emb);
}

View file

@ -288,7 +288,7 @@ function cleanMentionID(key) {
* Get channel object wit RegExp
* @param {Message | GuildMember | Guild} msg Object of the guild being searched
* @param {string} name Keyword
* @param {ChannelType[]} exclude Exclude channel type
* @param {["text"|"dm"|"voice"|"group"|"category"|"news"|"store"|"unknown"]} exclude Exclude channel type
* @returns {GuildChannel[]} Channels object found
*/
function findChannelRegEx(msg, name, exclude) {
@ -381,7 +381,7 @@ function multipleRolesFound(msg, arr, key, max = 4, withID) {
* Standard
* @param {Message | Guild} msg - Message object
* @param {string} key - Channel ID | Mention | Name
* @param {ChannelType[]} exclude - Exclude channel type
* @param {["text"|"voice"|"category"|"news"|"store"|"unknown"]} exclude - Exclude channel type
* @returns {GuildChannel | Channel} Channel object
*/
function getChannel(msg, key, exclude) {