mirror of
https://github.com/danbulant/Shasha
synced 2026-06-05 07:31:22 +00:00
ranlog
This commit is contained in:
parent
81c0ea6a7b
commit
b338b6622f
12 changed files with 47 additions and 48 deletions
|
|
@ -13,11 +13,9 @@ module.exports = class neko extends commando.Command {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
async run(msg) {
|
async run(msg) {
|
||||||
const aut = msg.guild ? msg.guild.member(msg.author) : msg.author;
|
const title = `${msg.guild ? msg.member.displayName : msg.author.username}! ~Nyann~ (UwU) <3`;
|
||||||
const title = `${msg.guild ? aut.displayName : aut.username}! ~Nyann~ (UwU) <3`;
|
|
||||||
const image = `https://nekos.best/nekos/${String(Math.floor(Math.random() * 314)).padStart(4, '0')}.png`;
|
const image = `https://nekos.best/nekos/${String(Math.floor(Math.random() * 314)).padStart(4, '0')}.png`;
|
||||||
const emb = await defaultImageEmbed(this.client, msg, aut, image, title);
|
const emb = await defaultImageEmbed(msg, image, title);
|
||||||
trySend(this.client, msg, emb);
|
return trySend(this.client, msg, emb);
|
||||||
return ranLog(msg, "neko");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -245,7 +245,7 @@ module.exports = class mute extends commando.Command {
|
||||||
defaultDurationDoc = muteSettingsDoc?.defaultDuration,
|
defaultDurationDoc = muteSettingsDoc?.defaultDuration,
|
||||||
logChannelDoc = muteSettingsDoc?.logChannel,
|
logChannelDoc = muteSettingsDoc?.logChannel,
|
||||||
roleDoc = muteSettingsDoc?.role;
|
roleDoc = muteSettingsDoc?.role;
|
||||||
let settings = await defaultImageEmbed(this.client, msg, msg.member);
|
let settings = await defaultImageEmbed(msg);
|
||||||
settings
|
settings
|
||||||
.setTitle("Mute Configuration")
|
.setTitle("Mute Configuration")
|
||||||
.addField("Role", roleDoc ? "<@&"+roleDoc+">" : "Not set")
|
.addField("Role", roleDoc ? "<@&"+roleDoc+">" : "Not set")
|
||||||
|
|
|
||||||
|
|
@ -355,6 +355,7 @@ module.exports = class embmaker extends commando.Command {
|
||||||
if (sent.length > 0) {
|
if (sent.length > 0) {
|
||||||
tryReact(msg, "a:yesLife:794788847996370945");
|
tryReact(msg, "a:yesLife:794788847996370945");
|
||||||
}
|
}
|
||||||
|
ranLog(this.client, msg, ("```js\n" + JSON.stringify(embed, null, 2) + "```").slice(0, 2048));
|
||||||
return sent;
|
return sent;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return errLog(e, msg, this.client, true, "", true);
|
return errLog(e, msg, this.client, true, "", true);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const commando = require("@iceprod/discord.js-commando");
|
const commando = require("@iceprod/discord.js-commando");
|
||||||
const { getChannelMessage, ranLog, errLog, noPerm, trySend } = require("../../resources/functions");
|
const { getChannelMessage, trySend } = require("../../resources/functions");
|
||||||
|
|
||||||
module.exports = class mesemb extends commando.Command {
|
module.exports = class mesemb extends commando.Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const commando = require("@iceprod/discord.js-commando");
|
const commando = require("@iceprod/discord.js-commando");
|
||||||
const { errLog, getChannelMessage, ranLog, noPerm, trySend } = require("../../resources/functions");
|
const { getChannelMessage, trySend } = require("../../resources/functions");
|
||||||
|
|
||||||
module.exports = class mesinfo extends commando.Command {
|
module.exports = class mesinfo extends commando.Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const commando = require("@iceprod/discord.js-commando");
|
const commando = require("@iceprod/discord.js-commando");
|
||||||
const { MessageEmbed } = require("discord.js");
|
const { MessageEmbed } = require("discord.js");
|
||||||
const { getChannelMessage, ranLog, errLog, noPerm, tryReact, trySend } = require("../../resources/functions");
|
const { getChannelMessage, errLog, noPerm, tryReact, trySend, ranLog } = require("../../resources/functions");
|
||||||
const { database } = require("../../database/mongo");
|
const { database } = require("../../database/mongo");
|
||||||
const col = database.collection("Guild");
|
const col = database.collection("Guild");
|
||||||
|
|
||||||
|
|
@ -57,6 +57,7 @@ module.exports = class newquoteotd extends commando.Command {
|
||||||
}
|
}
|
||||||
return sent;
|
return sent;
|
||||||
}
|
}
|
||||||
|
ranLog(this.client, msg, "New quote: " + msg.content + "\nBy: " + mes.author.tag + ` (${mes.author.id})`);
|
||||||
return trySend(this.client, msg, 'No message with that ID from this channel. Use `[<channel_[mention, ID]> <message_ID>, message_link]` if it\'s in another channel.');
|
return trySend(this.client, msg, 'No message with that ID from this channel. Use `[<channel_[mention, ID]> <message_ID>, message_link]` if it\'s in another channel.');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
noPerm(msg);
|
noPerm(msg);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const commando = require("@iceprod/discord.js-commando");
|
const commando = require("@iceprod/discord.js-commando");
|
||||||
const { writeJSONSync } = require("fs-extra");
|
const { trySend, ranLog } = require("../../resources/functions");
|
||||||
const { join } = require("path");
|
|
||||||
const { ranLog, trySend } = require("../../resources/functions");
|
|
||||||
const { database } = require("../../database/mongo");
|
const { database } = require("../../database/mongo");
|
||||||
const col = database.collection("Guild");
|
const col = database.collection("Guild");
|
||||||
|
|
||||||
|
|
@ -56,6 +54,7 @@ module.exports = class quoteotd extends commando.Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (result.length > 0) {
|
if (result.length > 0) {
|
||||||
|
ranLog(this.client, msg, result);
|
||||||
return trySend(this.client, msg, result);
|
return trySend(this.client, msg, result);
|
||||||
} else {
|
} else {
|
||||||
return trySend(this.client, msg, `Provide argument: \`--channel [mention, ID], --text [footer text], --icon [url footer icon]\``);
|
return trySend(this.client, msg, `Provide argument: \`--channel [mention, ID], --text [footer text], --icon [url footer icon]\``);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ module.exports = class say extends commando.Command {
|
||||||
description: "Say."
|
description: "Say."
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
run(msg, args) {
|
async run(msg, args) {
|
||||||
let noArgs = '';
|
let noArgs = '';
|
||||||
if (!args) {
|
if (!args) {
|
||||||
args = noArgs;
|
args = noArgs;
|
||||||
|
|
@ -23,10 +23,11 @@ module.exports = class say extends commando.Command {
|
||||||
if (msg.member?.hasPermission('MENTION_EVERYONE')) {
|
if (msg.member?.hasPermission('MENTION_EVERYONE')) {
|
||||||
sendThis.disableMentions = "none";
|
sendThis.disableMentions = "none";
|
||||||
}
|
}
|
||||||
const sent = trySend(this.client, msg, sendThis);
|
const sent = await trySend(this.client, msg, sendThis);
|
||||||
if (args !== noArgs && msg.channel.guild && msg.member.hasPermission("MANAGE_MESSAGES")) {
|
if (args !== noArgs && msg.channel.guild && msg.member.hasPermission("MANAGE_MESSAGES")) {
|
||||||
tryDelete(msg);
|
tryDelete(msg);
|
||||||
}
|
}
|
||||||
|
ranLog(this.client, msg, sent.content);
|
||||||
return sent;
|
return sent;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -57,6 +57,7 @@ module.exports = class send extends commando.Command {
|
||||||
if (send) {
|
if (send) {
|
||||||
tryReact(msg, 'yeLife:796401669188354090');
|
tryReact(msg, 'yeLife:796401669188354090');
|
||||||
}
|
}
|
||||||
|
ranLog(this.client, msg, send.content);
|
||||||
return send;
|
return send;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return errLog(e, msg, this.client);
|
return errLog(e, msg, this.client);
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ module.exports = class setfootq extends commando.Command {
|
||||||
return errLog(e, msg, this.client);
|
return errLog(e, msg, this.client);
|
||||||
}
|
}
|
||||||
const result = await trySend(this.client, msg, `Changed from \`${oldQ?.["settings"]?.defaultEmbed?.footerQuote}\` to \`${args.trim()}\``);
|
const result = await trySend(this.client, msg, `Changed from \`${oldQ?.["settings"]?.defaultEmbed?.footerQuote}\` to \`${args.trim()}\``);
|
||||||
|
ranLog(this.client, msg, result.content);
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ module.exports = class uinfo extends commando.Command {
|
||||||
result += 'Display color:```js\n'+member.displayColor+'```';
|
result += 'Display color:```js\n'+member.displayColor+'```';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return trySend(this.client, msg, result, {split:{maxLength:2000,char: ",",append:',```',prepend:'```js\n'}});
|
return trySend(this.client, msg, {content: result, split:{maxLength:2000,char: ",",append:',```',prepend:'```js\n'}});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return trySend(this.client, msg, "404 ERROR not found~");
|
return trySend(this.client, msg, "404 ERROR not found~");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,17 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { MessageEmbed, Message, GuildMember, User, Client, GuildChannel, Role, MessageOptions, Channel } = require('discord.js');
|
const { MessageEmbed, Message, GuildMember, User, Client, GuildChannel, Role, MessageOptions, Channel } = require('discord.js');
|
||||||
const { defaultErrorLogChannel } = require("../config.json");
|
const { defaultErrorLogChannel, ranLogger } = require("../config.json");
|
||||||
const { database } = require("../database/mongo");
|
const { database } = require("../database/mongo");
|
||||||
const { timestampAt } = require('./debug');
|
const { timestampAt } = require('./debug');
|
||||||
const getColor = require('./getColor');
|
const getColor = require('./getColor');
|
||||||
|
const { randomColors } = require("../config.json");
|
||||||
|
const { CommandoMessage, CommandoClient } = require('@iceprod/discord.js-commando');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log an error. If second argument, third argument is required
|
* Log an error. If second argument, third argument is required
|
||||||
* @param {Error} theError - Catched error (error)
|
* @param {Error} theError - Catched error (error)
|
||||||
* @param {Message} msg - Message object (msg)
|
* @param {CommandoMessage} msg - Message object (msg)
|
||||||
* @param {Client} client - This client (this.client)
|
* @param {Client} client - This client (this.client)
|
||||||
* @param {Boolean} sendTheError - Add error content to notify message (true | false)
|
* @param {Boolean} sendTheError - Add error content to notify message (true | false)
|
||||||
* @param {String} errorMessage - Error message ("You don't have enough permission to use that command!")
|
* @param {String} errorMessage - Error message ("You don't have enough permission to use that command!")
|
||||||
|
|
@ -18,8 +20,7 @@ const getColor = require('./getColor');
|
||||||
async function errLog(theError, msg, client, sendTheError, errorMessage, notify) {
|
async function errLog(theError, msg, client, sendTheError, errorMessage, notify) {
|
||||||
let errLogPath, [logThis, inLogChannel, sendErr] = ['', '', ''];
|
let errLogPath, [logThis, inLogChannel, sendErr] = ['', '', ''];
|
||||||
if (msg) {
|
if (msg) {
|
||||||
const comErr = msg.content.trim().split(/ +/)[0];
|
logThis = `\`${msg.command.name}\` (${msg.id}) ${msg.url} in ${msg.guild ? `**${msg.channel.name}** (${msg.channel.id}) of **${msg.guild.name}** (${msg.guild.id})` : `**DM**`} ran by **${msg.author.tag}** (${msg.author.id}) \n\n`;
|
||||||
logThis = `\`${comErr}\` (${msg.id}) ${msg.url} in ${msg.guild ? `**${msg.channel.name}** (${msg.channel.id}) of **${msg.guild.name}** (${msg.guild.id})` : `**DM**`} ran by **${msg.author.tag}** (${msg.author.id}) \n\n`;
|
|
||||||
msg.guild ? errLogPath = `../Guilds/${msg.guild.id}/Log/` : errLogPath = '../Log/';
|
msg.guild ? errLogPath = `../Guilds/${msg.guild.id}/Log/` : errLogPath = '../Log/';
|
||||||
if (errorMessage) {
|
if (errorMessage) {
|
||||||
if (errorMessage.length > 0) {
|
if (errorMessage.length > 0) {
|
||||||
|
|
@ -96,17 +97,22 @@ function execCB(error, stdout, stderr) {
|
||||||
console.log('stdout:\n'+stdout);
|
console.log('stdout:\n'+stdout);
|
||||||
console.log('stderr:\n'+stderr);
|
console.log('stderr:\n'+stderr);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
async function ranLog(msg, cmd, addition) { return /*
|
* Command usage logger
|
||||||
let errLogPath;
|
* @param {CommandoClient} client
|
||||||
if (msg.guild) {
|
* @param {CommandoMessage} msg
|
||||||
errLogPath = `../Guilds/${msg.guild.id}/Log/`;
|
* @param {String} addition
|
||||||
} else {
|
*/
|
||||||
errLogPath = '../Log/';
|
async function ranLog(client, msg, addition) {
|
||||||
}
|
const channel = client.channels.cache.get(ranLogger);
|
||||||
let add = '\n'+addition;
|
const embed = await defaultImageEmbed(msg, null, msg.command.name.toLocaleUpperCase() + ` (${msg.id})`);
|
||||||
const b = new Date().toUTCString();
|
embed.setAuthor(msg.author.tag + ` (${msg.author.id})`, msg.author.displayAvatarURL({"size": 4096, "dynamic": true}))
|
||||||
return //console.log(inLog); */
|
.setURL(msg.url)
|
||||||
|
.setDescription(addition)
|
||||||
|
.setFooter(timestampAt(), msg.guild?.iconURL({"size": 4096, "dynamic": true}))
|
||||||
|
.addField("Guild", `**${msg.guild?.name}** (${msg.guild?.id})`, true)
|
||||||
|
.addField("Channel", `**${msg.channel?.name}** (${msg.channel.id})`, true);
|
||||||
|
trySend(client, channel, {embed: embed});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -247,32 +253,23 @@ function sentAdCheck(content) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make default image embed
|
* Make default image embed
|
||||||
* @param {Client} client
|
|
||||||
* @param {Message} msg
|
* @param {Message} msg
|
||||||
* @param {URL} image
|
* @param {String} image
|
||||||
* @param {GuildMember | User} author
|
* @param {GuildMember | User} author
|
||||||
* @param {String} title
|
* @param {String} title
|
||||||
* @param {String} footerText
|
* @param {String} footerQuote
|
||||||
* @returns {Promise<MessageEmbed>}
|
* @returns {Promise<MessageEmbed>}
|
||||||
*/
|
*/
|
||||||
async function defaultImageEmbed(client, msg, author, image, title, footerText) {
|
async function defaultImageEmbed(msg, image, title, footerQuote) {
|
||||||
const { randomColors } = require("../config.json");
|
|
||||||
let footerQuote = footerText;
|
|
||||||
if (!footerQuote) {
|
if (!footerQuote) {
|
||||||
const r = await database.collection(msg.guild ? "Guild" : "User").findOne({document: msg.guild?.id ?? msg.author.id});
|
const r = await database.collection(msg.guild ? "Guild" : "User").findOne({document: msg.guild?.id ?? msg.author.id}).catch(() => {});
|
||||||
footerQuote = r?.["settings"]?.defaultEmbed?.footerQuote || "";
|
footerQuote = r?.["settings"]?.defaultEmbed?.footerQuote || "";
|
||||||
}
|
}
|
||||||
let emb = new MessageEmbed();
|
return new MessageEmbed()
|
||||||
try {
|
.setTitle(title)
|
||||||
emb
|
.setImage(image)
|
||||||
.setTitle(title)
|
.setColor(msg.guild ? getColor(msg.member.displayColor) : randomColors[Math.floor(Math.random() * randomColors.length)])
|
||||||
.setImage(image)
|
.setFooter(footerQuote);
|
||||||
.setColor(msg.guild ? getColor(author?.displayColor) : randomColors[Math.floor(Math.random() * randomColors.length)])
|
|
||||||
.setFooter(footerQuote);
|
|
||||||
} catch (e) {
|
|
||||||
return errLog(e, msg, client);
|
|
||||||
}
|
|
||||||
return emb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue