-
Notifications
You must be signed in to change notification settings - Fork 0
/
member_events.js
88 lines (88 loc) · 2.7 KB
/
member_events.js
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
const G = require("./Generators/GenerateSimpleEmbed");
const embedlogger = require("./sendToLogChannel");
const logger = require("./logger");
const {ADDUSER,SUBTRACT} = require("./DataHandlers/socialCredit");
const customwelcome = require("./DataHandlers/welcome_message_data_collector");
module.exports = {
async guildjoin(member, client, con) {
let custommessage = await createCustomMessage(member);
var embed = G.GenerateEmbed(
"#006400",
false,
false,
false,
true,
false,
"Hello",
false,
member.user.avatarURL({ dynamic: true, format: "png", size: 64 })
);
if (custommessage == false) {
embed.setDescription(`welcome, ${member.displayName}`);
} else {
embed.setDescription(`${custommessage}`);
}
try {
await embedlogger.log_new_user(member, embed, member.guild.id, client);
await logger.LEAVE_JOINLOG(undefined, member.guild, "USER JOINED SERVER");
} catch (err) {
console.log(err);
await logger.LEAVE_JOINLOG(err, member.guild, "USER JOINED SERVER");
}
ADDUSER(con, member);
},
async guildleave(member, con) {
let banned = await member.guild.bans.fetch(member).catch((error) => {
if (error.code != 10026) {
console.log(error);
} else {
return false;
}
});
var embed = G.GenerateEmbed(
false,
false,
false,
false,
true,
false,
false,
false,
member.user.avatarURL({ dynamic: true, format: "png", size: 64 })
);
if (banned) {
let fields=[]
if (banned.reason == null) {
fields=[{name: ":warning: **BANNED** :warning:",value:`\`\`\`no reason provided\`\`\``},]
} else {
fields=[{name:":warning: **BANNED** :warning:",value:`\`\`\`${banned.reason}\`\`\``}]
}
embed.addFields(fields);
embed
.setTitle("good riddance!")
.setDescription(`${member.displayName} won't be missed.`)
.setColor("#FF0000");
await logger.LEAVE_JOINLOG(undefined, member.guild, "USER BANNED");
SUBTRACT(con, 500, member.id);
} else {
embed
.setTitle("oh no")
.setDescription(`${member.displayName} left`)
.setColor("#FFA500");
await logger.LEAVE_JOINLOG(undefined, member.guild, "USER LEFT SERVER");
}
try {
await embedlogger.embedWithLog(member, embed, false);
} catch (err) {
console.log(err);
}
},
};
async function createCustomMessage(member) {
let message = await customwelcome.GET(member.guild.id);
if (message == false) return false;
message = await message
.replace("{user}", "" + member.displayName + "")
.replace("{server}", "" + member.guild.name + "");
return message;
}