-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmenuHandler.js
43 lines (39 loc) · 1.64 KB
/
menuHandler.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
require("dotenv").config();
/**
* @todo Finish updating code with FileLogger custom file logging builder
*/
class handler {
constructor(client,MessageEmbed,MessageActionRow,MessageSelectMenu,MessageButton,constructJSON){
this.client = client;
this.MessageEmbed = MessageEmbed;
this.MessageActionRow = MessageActionRow;
this.MessageSelectMenu = MessageSelectMenu;
this.MessageButton = MessageButton;
this.constructJSON = constructJSON;
}
async handle() {
const channel = this.client.channels.cache.get(`${process.env.MenuChannelID}`);
const embed = new this.MessageEmbed().setTitle("Select the server you wish to be white listed on");
//setTimeout(() => Message.delete(), 1);
let messages = await channel.messages.fetch({ limit: 5 })
let message = messages.find(m => m.embeds[0].title.includes("Select the server you wish to be white listed on"));
const row = new this.MessageActionRow().addComponents(
new this.MessageSelectMenu()
.setCustomId("whitelist")
.setPlaceholder("Select a server")
.addOptions(this.constructJSON()),
)
const row2 = new this.MessageActionRow().addComponents(
new this.MessageButton()
.setCustomId('fix')
.setLabel('Fix Whitelist')
.setStyle('PRIMARY'),
)
if(!message){
message = await channel.send({embeds : [embed] , components : [row,row2]});
}else{
message.edit({embeds : [embed] , components : [row, row2]});
}
}
}
module.exports = handler;