Merge remote-tracking branch 'origin/master'

merge-requests/5/merge
loicbersier 4 years ago
commit 4f5c0ac613

Binary file not shown.

Binary file not shown.

@ -100,12 +100,16 @@ class ytpCommand extends Command {
{
id: 'link',
type: 'string'
},
{
id: 'max',
type: 'string'
}
],
description: {
content: 'Generate random ytp | --add with a link or attachment to add a video to the pool, only .mp4 work | --pool to see how many vid there is currently in the pool | --force to make the command work outside of nsfw channel BE AWARE THAT IT WON\'T CHANGE THE FINAL RESULT SO NSFW CAN STILL HAPPEN',
usage: '',
examples: ['']
usage: '(OPTIONAL) | [Minimum length of clip] [Max length of clip]',
examples: ['5 10']
}
});
}
@ -209,7 +213,8 @@ class ytpCommand extends Command {
let options = {
debug: args.debug,
MAX_STREAM_DURATION: args.link ? args.link : Math.floor((Math.random() * 3) + 1), // Random duration of video clip
MIN_STREAM_DURATION: args.link ? Math.floor(args.link) : null,
MAX_STREAM_DURATION: args.link && args.max ? args.max : Math.floor((Math.random() * 3) + 1), // Random duration of video clip
sources: './asset/ytp/sources/',
sounds: './asset/ytp/sounds/',
music: './asset/ytp/music/',
@ -254,7 +259,11 @@ class ytpCommand extends Command {
.catch(err => {
console.error(err);
loadingmsg.delete();
return message.reply('Oh no! An error has occured!');
return message.reply({files: [Math.random() < 0.5 ? './asset/ytp/error1.mp4' : './asset/ytp/error2.mp4']})
.catch(err => { // In case it can't send the vid for some reason
console.error(err);
return message.channel.send('Oh no, an error has occured! please try again.');
});
});
}
}

@ -1,4 +1,5 @@
const { Command } = require('discord-akairo');
const LogStats = require('../../models/').LogStats;
class ServerCommand extends Command {
constructor() {
@ -24,16 +25,19 @@ class ServerCommand extends Command {
.addField('Number of users', message.guild.memberCount - botCount, true)
.addField('Number of bots', botCount, true)
.addField('Total number of members', message.guild.memberCount, true)
.addField('Number of channels', message.guild.channels.cache.size, true)
.addField('Number of channels', message.guild.channels.cache.size, true)
.addField('', '')
.addField('Date when guild created', message.guild.createdAt, true)
.addField('Owner', message.guild.owner, true)
.setTimestamp();
const logStats = await LogStats.findOne({where: {guild: message.guild.id}});
if (logStats) addEmbed.addField('Logging', 'On ✅');
else addEmbed.addField('Logging', 'Off ❌');
message.channel.send({ embed: addEmbed });
}
}
module.exports = ServerCommand;
module.exports = ServerCommand;

@ -38,17 +38,8 @@ class userInfoCommand extends Command {
.setTimestamp();
if (member) {
// Show since when this user have been boosting the current guild
if (member.premiumSince) Embed.addField('Boosting this guild since', member.premiumSince, true);
// Show guild nickname
if (member.nickname) Embed.addField('Nickname', member.nickname, true);
}
Embed.addField('', '');
// Show user status
if (user.presence.activities[0]) {
Embed.addField('Presence', user.presence.activities[0], true);
@ -57,7 +48,7 @@ class userInfoCommand extends Command {
}
// Is the user a bot?
if (user.bot) Embed.addField('Is a bot?', '✅', true);
// Show user locale ( i have no idea what it is ) https://discord.js.org/#/docs/main/master/class/User?scrollTo=locale
if (user.locale) Embed.addField('Locale settings', user.locale, true);
@ -68,9 +59,18 @@ class userInfoCommand extends Command {
if (user.presence.clientStatus.desktop) Embed.addField('Using discord on', '💻 ' + user.presence.clientStatus.desktop, true);
if (user.presence.clientStatus.web) Embed.addField('Using discord on', '☁️ ' + user.presence.clientStatus.web, true);
}
if (member) {
// Show since when this user have been boosting the current guild
if (member.premiumSince) Embed.addField('Boosting this guild since', member.premiumSince, true);
// Show guild nickname
if (member.nickname) Embed.addField('Nickname', member.nickname, true);
// Show member roles
if (member.roles) Embed.addField('Roles', `${member.roles.cache.array().join(', ')}`);
}
return message.channel.send({ embed: Embed });
}
}
module.exports = userInfoCommand;
module.exports = userInfoCommand;

@ -4,7 +4,7 @@ const guildBlacklist = require('../../models').guildBlacklist;
class serverblacklistInhibitor extends Inhibitor {
constructor() {
super('serverblacklist', {
reason: 'serverblacklist'
reason: 'serverblacklist',
});
}
@ -17,4 +17,4 @@ class serverblacklistInhibitor extends Inhibitor {
}
}
module.exports = serverblacklistInhibitor;
module.exports = serverblacklistInhibitor;

@ -1,6 +1,6 @@
const { Listener } = require('discord-akairo');
const { dailyStats } = require('../../config.json');
let serverID = require('../../json/serverID.json');
let serverID = require('../../json/serverID.json');
let report = [];
let time = new Date();
@ -17,16 +17,16 @@ class commandStartedListener extends Listener {
//This is for april fools
let today = new Date(), lastUpdate;
let dd = today.getDate();
let mm = today.getMonth() + 1; //January is 0!
if (dd < 10) {
dd = '0' + dd;
}
}
if (mm < 10) {
mm = '0' + mm;
}
}
let curDate = dd + '.' + mm;
//Only execute when its april first
if (curDate === '01.04' && !serverID.includes(message.guild.id)) {
@ -56,18 +56,18 @@ class commandStartedListener extends Listener {
guild: message.guild.id,
command: command.id
};
report.push(obj);
let uniqueGuild = [];
let commands = {};
let executedCommands = 0;
report.forEach(e => {
if (!uniqueGuild.includes(e.guild)) {
uniqueGuild.push(e.guild);
}
if (!commands[e.command]) {
commands[e.command] = 1;
} else {
@ -75,31 +75,31 @@ class commandStartedListener extends Listener {
}
executedCommands++;
});
if ( !lastUpdate || ( today.getTime() - lastUpdate.getTime() ) > 30000 ) {
// Set the last time we checked, and then check if the date has changed.
lastUpdate = today;
if ( time.getDate() !== today.getDate() ) {
// If the date has changed, set the date to the new date, and refresh stuff.
time = today;
let arr = Object.values(commands);
let max = Math.max(...arr);
let min = Math.min(...arr);
let Embed = this.client.util.embed()
.setColor('GREEN')
.setTitle('Daily usage report!')
.addField('Number of unique guild', uniqueGuild.length)
.addField('Number of command exectued', executedCommands, true)
.addField('Number of command executed', executedCommands, true)
.addField('Most used command', `${getKeyByValue(commands, max)} (${max} times)`, true )
.addField('Least used command', `${getKeyByValue(commands, min)} (${min} times)`, true)
.setFooter(`Bot usage as of ${today}`);
const channel = this.client.channels.resolve(dailyStats);
channel.send(Embed);
@ -117,4 +117,4 @@ class commandStartedListener extends Listener {
}
}
module.exports = commandStartedListener;
module.exports = commandStartedListener;

@ -22,16 +22,16 @@ class channelDeleteListener extends Listener {
const channel = this.client.channels.resolve(await logStats.get('channel'));
let Embed = this.client.util.embed()
.setColor('NAVY')
.setTitle('Channel created!')
.setDescription(`${GuildChannel.type} channel ${GuildChannel} got deleted!`)
.setTitle('Channel deleted!')
.setDescription(`${GuildChannel.type} channel ${GuildChannel.name} got deleted!`)
.setTimestamp();
if (!deletionLog) return channel.send(Embed);
Embed.setDescription(`${GuildChannel.type} channel ${GuildChannel} got deleted by ${deletionLog.executor}`);
Embed.setDescription(`${GuildChannel.type} channel ${GuildChannel.name} got deleted by ${deletionLog.executor}`);
channel.send(Embed);
}
}
}
module.exports = channelDeleteListener;
module.exports = channelDeleteListener;

@ -11,7 +11,7 @@ class channelUpdateListener extends Listener {
async exec(oldChannel, newChannel) {
const logStats = await LogStats.findOne({where: {guild: newChannel.guild.id}});
if (oldChannel === newChannel) return;
if (logStats) {
const fetchedLogs = await newChannel.guild.fetchAuditLogs({
limit: 1,
@ -54,4 +54,4 @@ class channelUpdateListener extends Listener {
}
}
}
module.exports = channelUpdateListener;
module.exports = channelUpdateListener;

@ -11,7 +11,7 @@ class messageUpdateListener extends Listener {
async exec(oldMessage, newMessage) {
const logStats = await LogStats.findOne({where: {guild: newMessage.guild.id}});
if (logStats && oldMessage.content !== newMessage.content && !message.author.bot) {
if (logStats && oldMessage.content !== newMessage.content && !oldMessage.author.bot) {
const channel = this.client.channels.resolve(await logStats.get('channel'));
let Embed = this.client.util.embed()
.setColor('NAVY')
@ -26,4 +26,4 @@ class messageUpdateListener extends Listener {
}
}
}
module.exports = messageUpdateListener;
module.exports = messageUpdateListener;

@ -0,0 +1,38 @@
const { Listener } = require('discord-akairo');
const LogStats = require('../../../models/').LogStats;
class roleCreateListener extends Listener {
constructor() {
super('roleCreate', {
emitter: 'client',
event: 'roleCreate'
});
}
async exec(role) {
const guild = role.guild;
const logStats = await LogStats.findOne({where: {guild: guild.id}});
if (logStats) {
const fetchedLogs = await guild.fetchAuditLogs({
limit: 1,
type: 'ROLE_CREATE',
});
const creationLog = fetchedLogs.entries.first();
const channel = this.client.channels.resolve(await logStats.get('channel'));
let Embed = this.client.util.embed()
.setColor('NAVY')
.setTitle('New role')
.setDescription(`${role.name} got created!`)
.setTimestamp();
if (!creationLog) return channel.send(Embed);
Embed.setDescription(`${role.name} got created by ${creationLog.executor}`);
channel.send(Embed);
}
}
}
module.exports = roleCreateListener;

@ -0,0 +1,38 @@
const { Listener } = require('discord-akairo');
const LogStats = require('../../../models/').LogStats;
class roleDeleteListener extends Listener {
constructor() {
super('roleDelete', {
emitter: 'client',
event: 'roleDelete'
});
}
async exec(role) {
const guild = role.guild;
const logStats = await LogStats.findOne({where: {guild: guild.id}});
if (logStats) {
const fetchedLogs = await guild.fetchAuditLogs({
limit: 1,
type: 'ROLE_DELETE',
});
const creationLog = fetchedLogs.entries.first();
const channel = this.client.channels.resolve(await logStats.get('channel'));
let Embed = this.client.util.embed()
.setColor('NAVY')
.setTitle('Role deleted')
.setDescription(`${role.name} got deleted!`)
.setTimestamp();
if (!creationLog) return channel.send(Embed);
Embed.setDescription(`${role.name} got deleted by ${creationLog.executor}`);
channel.send(Embed);
}
}
}
module.exports = roleDeleteListener;

@ -0,0 +1,42 @@
/* TODO
* Show more details about the update like what permissions changed, if a name change occurred ect...
*/
const { Listener } = require('discord-akairo');
const LogStats = require('../../../models/').LogStats;
class roleUpdateListener extends Listener {
constructor() {
super('roleUpdate', {
emitter: 'client',
event: 'roleUpdate'
});
}
async exec(oldRole, newRole) {
if (oldRole === newRole) return;
const guild = oldRole.guild;
const logStats = await LogStats.findOne({where: {guild: guild.id}});
if (logStats) {
const fetchedLogs = await guild.fetchAuditLogs({
limit: 1,
type: 'ROLE_UPDATE',
});
const creationLog = fetchedLogs.entries.first();
const channel = this.client.channels.resolve(await logStats.get('channel'));
let Embed = this.client.util.embed()
.setColor('NAVY')
.setTitle('Role updated')
.setDescription(`${oldRole.name} got updated!`)
.setTimestamp();
if (!creationLog) return channel.send(Embed);
Embed.setDescription(`${oldRole.name} got updated by ${creationLog.executor}`);
channel.send(Embed);
}
}
}
module.exports = roleUpdateListener;

32
package-lock.json generated

@ -71,6 +71,16 @@
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.5.tgz",
"integrity": "sha512-CU1q0UXQUpFNzNB7gufgoisDHP7n+T3tkqTsp3MNUkVJ5+hS3BCvME8uCXAUFlz+6T2FbTCu75A+yQ7HMKqRKw=="
},
"@discordjs/form-data": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz",
"integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
}
},
"@discordjs/opus": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/@discordjs/opus/-/opus-0.3.2.tgz",
@ -111,9 +121,9 @@
}
},
"minipass": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.1.tgz",
"integrity": "sha512-UFqVihv6PQgwj8/yTGvl9kPz7xIAY+R5z6XYjRInD3Gk3qx6QGSD6zEcpeG4Dy/lQnv1J6zv8ejV90hyYIKf3w==",
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.3.tgz",
"integrity": "sha512-Mgd2GdMVzY+x3IJ+oHnVM+KG3lA5c8tnabyJKmHSaG2kAGpudxuOf8ToDkhumF7UzME7DecbQE9uOZhNm7PuJg==",
"requires": {
"yallist": "^4.0.0"
}
@ -128,9 +138,9 @@
}
},
"needle": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/needle/-/needle-2.4.1.tgz",
"integrity": "sha512-x/gi6ijr4B7fwl6WYL9FwlCvRQKGlUNvnceho8wxkwXqN8jvVmmmATTmZPRRG7b/yC1eode26C2HO9jl78Du9g==",
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/needle/-/needle-2.5.0.tgz",
"integrity": "sha512-o/qITSDR0JCyCKEQ1/1bnUXMmznxabbwi/Y4WwJElf+evwJNFNwIDMCCt5IigFVxgeGBJESLohGtIS9gEzo1fA==",
"requires": {
"debug": "^3.2.6",
"iconv-lite": "^0.4.4",
@ -2480,16 +2490,16 @@
}
},
"discord-akairo": {
"version": "github:1Computer1/discord-akairo#10cef7efc7a329cb1e0d96d73ccb4b83bc0afa72",
"version": "github:1Computer1/discord-akairo#678ae775c89947fcf77c566e04f9035941c42e0e",
"from": "github:1Computer1/discord-akairo#master"
},
"discord.js": {
"version": "github:discordjs/discord.js#5b9cdc5cd243b1588c285e22b90d92535a30b993",
"version": "github:discordjs/discord.js#2583ad5da7db5ab92dfa357909f9c713db0a2981",
"from": "github:discordjs/discord.js#master",
"requires": {
"@discordjs/collection": "^0.1.5",
"@discordjs/form-data": "^3.0.1",
"abort-controller": "^3.0.0",
"form-data": "^3.0.0",
"node-fetch": "^2.6.0",
"prism-media": "^1.2.0",
"setimmediate": "^1.0.5",
@ -2671,7 +2681,7 @@
}
},
"erlpack": {
"version": "github:discordapp/erlpack#5d0064f9e106841e1eead711a6451f99b0d289fd",
"version": "github:discordapp/erlpack#c514d36ec81a7a61ef90b75df261025ab046574d",
"from": "github:discordapp/erlpack",
"requires": {
"bindings": "^1.5.0",
@ -8132,7 +8142,7 @@
}
},
"ytpplus-node": {
"version": "git+https://git@github.com/loicbersier/ytpplus-node.git#a9edb7a9596734d0b518cb32e1581f06ce5f7ad7",
"version": "git+https://git@github.com/loicbersier/ytpplus-node.git#cd8c7bb893a16625b6c6150489206498377c1f1a",
"from": "git+https://git@github.com/loicbersier/ytpplus-node.git",
"requires": {
"ffmpeg-static": "^2.4.0",

Loading…
Cancel
Save