-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #329 from aternosorg/joinlogs
Add join logs
- Loading branch information
Showing
8 changed files
with
138 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const Command = require('../../Command'); | ||
const util = require('../../util.js'); | ||
const Discord = require('discord.js'); | ||
|
||
class JoinLogChannelCommand extends Command { | ||
|
||
static description = 'Configure the channel that joins will be logged in'; | ||
|
||
static usage = '<#channel|id>|off|status'; | ||
|
||
static names = ['joinlog','memberlog']; | ||
|
||
static userPerms = ['MANAGE_GUILD']; | ||
|
||
async execute() { | ||
if (this.args.length !== 1) { | ||
await this.sendUsage(); | ||
return; | ||
} | ||
|
||
switch (this.args[0].toLowerCase()) { | ||
case 'off': | ||
this.guildConfig.joinLogChannel = null; | ||
await this.guildConfig.save(); | ||
await this.message.channel.send(new Discord.MessageEmbed() | ||
.setDescription('Disabled join logs') | ||
.setColor(util.color.red) | ||
); | ||
break; | ||
case 'status': | ||
await this.message.channel.send(new Discord.MessageEmbed() | ||
.setDescription(`New members are currently ${this.guildConfig.joinLogChannel ? `logged to <#${this.guildConfig.joinLogChannel}>` : 'not logged'}.`) | ||
.setColor(this.guildConfig.joinLogChannel ? util.color.green : util.color.red) | ||
); | ||
break; | ||
default: { | ||
const channel = util.channelMentionToId(this.args[0]); | ||
if (channel === null || !await util.isChannel(this.message.guild, channel)) return this.sendUsage(); | ||
if (!this.message.guild.channels.resolve(/** @type {Snowflake} */channel).permissionsFor(this.bot.user).has(['SEND_MESSAGES', 'VIEW_CHANNEL'])) { | ||
return this.message.channel.send('I am missing the required permissions to send messages to that channel!'); | ||
} | ||
|
||
this.guildConfig.joinLogChannel = channel; | ||
await this.guildConfig.save(); | ||
await this.message.channel.send(new Discord.MessageEmbed() | ||
.setDescription(`Set join log channel to <#${channel}>.`) | ||
.setColor(util.color.green) | ||
); | ||
} | ||
} | ||
} | ||
} | ||
|
||
module.exports = JoinLogChannelCommand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const Log = require('../../Log'); | ||
const {MessageEmbed} = require('discord.js'); | ||
const util = require('../../util'); | ||
|
||
/** | ||
* @param options | ||
* @param {module:"discord.js".GuildMember} member | ||
* @return {Promise<void>} | ||
*/ | ||
exports.event = async (options, member) => { | ||
let description = `**ID:** ${member.id}\n` + | ||
`**Created Account:** <t:${Math.floor(member.user.createdTimestamp / 1000)}:R>\n`; | ||
|
||
await Log.joinLog(member.guild.id, '', new MessageEmbed() | ||
.setTitle(`${member.user.tag} joined this server`) | ||
.setColor(util.color.green) | ||
.setThumbnail(member.user.avatarURL()) | ||
.setDescription(description) | ||
.setTimestamp() | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const Log = require('../../Log'); | ||
const {MessageEmbed} = require('discord.js'); | ||
const util = require('../../util'); | ||
|
||
/** | ||
* @param options | ||
* @param {module:"discord.js".GuildMember} member | ||
* @return {Promise<void>} | ||
*/ | ||
exports.event = async (options, member) => { | ||
let description = `**ID:** ${member.id}\n` + | ||
`**Created Account:** <t:${Math.floor(member.user.createdTimestamp / 1000)}:R>\n`; | ||
|
||
if (member.joinedTimestamp) { | ||
description += `**Joined:** <t:${Math.floor(member.joinedTimestamp / 1000)}:R>`; | ||
} | ||
|
||
await Log.joinLog(member.guild.id, '', new MessageEmbed() | ||
.setTitle(`${member.user.tag} left this server`) | ||
.setColor(util.color.red) | ||
.setThumbnail(member.user.avatarURL()) | ||
.setDescription(description) | ||
.setTimestamp() | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters