Repository navigation
Expand file tree
/
Copy pathmoderation.js
More file actions
88 lines (76 loc) · 3.3 KB
/
Copy pathmoderation.js
File metadata and controls
88 lines (76 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/// ///////////////////////////////////////////////////////////
// Filename: moderation.js //
// Author: Jake Roberts //
// Date: TBD //
// Updated: 6/4/2019 //
// Description: Used for execution of moderation actions //
// Dependencies: Discord.js library //
/// ///////////////////////////////////////////////////////////
// const Discord = require('discord.js') // for Discord library
// const client = new Discord.Client() // for Discord client
// deletes the number of messages specified
exports.delete1 = function(msg, num, msgInfo) {
console.log('Request:\n')
console.group()
console.log(`${msgInfo}Delete1`)
console.log(`Message: "${msg.content}"\nTimestamp: ${msg.createdTimestamp}`)
console.groupEnd()
}
// deletes a specified number of messages sent by a user
exports.delete2 = function(msg, ID, num, msgInfo) {
console.log('Request:\n')
console.group()
console.log(`${msgInfo}Delete2`)
console.log(`Message: "${msg.content}"\nTimestamp: ${msg.createdTimestamp}`)
console.groupEnd()
}
// kicks member
exports.kick = function(msg, msgInfo) {
console.log('kick was run\n\n')
const user = msg.mentions.users.first()
console.log(user)
if (!msg.member.highestRole.hasPermission('KICK_MEMBERS')) { msg.reply('you can\'t use that command!') } else {
const member = msg.guild.member(user)
if (member) {
member.kick({ reason: '' })
.then(() => { msg.reply(`Successfully kicked <@${user.tag}>!`) })
.catch(err => { msg.reply('I couldn\'t ban that person!'); console.err(err) })
} else { msg.reply('that person isn\'t in the server!') }
}
}
// bans, then unbans user (essentially kicks and deletes messages)
exports.softban = function(msg) {
const user = msg.mentions.users.first()
console.log('softban was run\n\n')
if (!msg.member.highestRole.hasPermission('BAN_MEMBERS') || !msg.guild.owner) { msg.reply('you cna\'t use that command!') } else {
const member = msg.guild.member(user)
if (member) {
msg.guild.ban(user, 7, { reason: '' })
.then(msg.guild.unban(user.id))
.then(() => { msg.reply(`Successfully softbanned ${user.tag}!`) })
.catch(err => { msg.reply('I couldn\'t softban that person!'); console.error(err) })
} else { msg.reply('That person isn\'t in ther server!') }
}
}
// bans member
exports.ban = (msg) => {
const user = msg.mentions.users.first()
console.log(user)
if (!msg.member.highestRole.hasPermission('BAN_MEMBERS') || !msg.guild.owner) { msg.reply('you can\'t use that command!') } else {
const member = msg.guild.member(user)
if (member) {
msg.guild.ban(user.id, 7, { reason: '' })
.then(() => { msg.reply(`Successfully banned ${user.tag}!`) })
.catch(err => { msg.reply('I couldn\'t ban that person!'); console.error(err) })
} else { msg.reply('That person isn\'t in the server!') }
}
}
// unbans member
exports.unban = function(msg) {
console.log('unban was run\n\n')
if (!msg.member.highestRole.hasPermission('BAN_MEMBERS') || !msg.guild.owner) { msg.reply('you can\'t use that command!') } else {
msg.guild.unban(msg.user.id)
.then(() => { msg.reply(`successfully unbanned ${msg.user.tag}!`) })
.catch(err => { msg.reply('that person is already unbanned!'); console.error(err) })
}
}