-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.js
230 lines (199 loc) · 9.05 KB
/
index.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
//Discord Client
const { Client, Intents, MessageActionRow, MessageButton } = require('discord.js')
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] })
//Importing Rest & api-types
const { REST } = require('@discordjs/rest')
const { Routes } = require('discord-api-types/v9')
//Loading Config
const config = require('./config.json')
console.log('Config Loaded')
var owners = config.owners
//Ready Event
client.on('ready', async () => {
console.log(`${client.user.tag} is Ready!`)
client.user.setPresence({
status: "online",
activities: [{
name: config.status,
type: "LISTENING",
}]
})
//Registering Slash
if (config.enable_slash) {
const rest = new REST({ version: '9' }).setToken(config.token)
const commands = [{
name: 'create',
description: 'Replies with Help Embed!'
}]
try {
console.log('Started refreshing application (/) commands.')
await rest.put(
Routes.applicationCommands(client.user.id),
{ body: commands },
);
console.log('Successfully reloaded application (/) commands.')
}
catch (error) {
console.error(error)
}
}
})
/**
* @author Abdul$5464 <https://github.com/Abdul1810/>
*/
client.on("interactionCreate", async (interaction) => {
var SupportEmbed =
{
author: { name: config.embed_content.title, icon_url: client.user.displayAvatarURL({ size: 2048, dynamic: false, format:"png"}) },
timestamp: new Date(),
color: `0x${config.embed_content.color}`,
thumbnail: { url: config.thumbnail ? config.thumbnail_url : client.user.displayAvatarURL({ size: 2048, format: "png", dynamic: false}) },
description: `\u200b\n1️⃣ ${config.embed_content.question_1}\n\u200b\n2️⃣ ${config.embed_content.question_2}\n\u200b\n3️⃣ ${config.embed_content.question_3}\n\u200b\n4️⃣ ${config.embed_content.question_4}\n\u200b\n5️⃣ ${config.embed_content.question_5}\n\u200b\n> **None Of The Above**\nIf Your Question is not in the Above List.(Further Assistance)\n\u200b\n`,
footer:{
text: interaction.guild.name
}
}
let button1 = new MessageButton()
.setStyle("SECONDARY")
.setEmoji("1️⃣")
.setCustomId("button_one")
let button2 = new MessageButton()
.setEmoji("2️⃣")
.setStyle("SECONDARY")
.setCustomId("button_two")
let button3 = new MessageButton()
.setEmoji("3️⃣")
.setStyle("SECONDARY")
.setCustomId("button_three")
let button4 = new MessageButton()
.setEmoji("4️⃣")
.setStyle("SECONDARY")
.setCustomId("button_four")
//If You Don't Need 5th Button Remove The 4 Lines Below and Remove Line 67
let button5 = new MessageButton()
.setEmoji("5️⃣")
.setStyle("SECONDARY")
.setCustomId("button_five")
let button6 = new MessageButton()
.setLabel("None Of The Above")
.setStyle("SUCCESS")
//.setEmoji("🤷🏻♂️")
.setCustomId("none_of_the_above")
let buttonRow1 = new MessageActionRow()
.addComponents([button1, button2, button3, button4, button5])
let buttonRow2 = new MessageActionRow()
.addComponents([button6])
if (interaction.isCommand()) {
if (!owners.includes(interaction.user.id)) {
await interaction.reply({ content: "You aren\'t Authorized To use This Command!", ephemeral: true })
}
await interaction.reply({ embeds: [SupportEmbed], components: [buttonRow1, buttonRow2] })
}
else if (interaction.isButton()) {
let responseembed =
{
author:{ name: config.title, icon_url: config.thumbnail ? config.thumbnail_url : client.user.displayAvatarURL({ size: 2048, format: "png", dynamic: false}) },
color: `0x${config.embed_content.color}`,
description: null,
timestamp: new Date(),
footer:{
text: interaction.guild.name
}
}
const logchannel = interaction.guild.channels.cache.get(config.log_channel_id)
if (interaction.customId === "button_one") {
responseembed.description = `\u200b\n**${config.responses.response_1}**\n\u200b\n`
logchannel.send(`> **${interaction.user.username + "#" + interaction.user.discriminator}**(${interaction.user.id}) Used ${interaction.customId}\nTimeStamp: ${new Date()}`)
// let invitecutie = new MessageButton()
// .setLabel("Invite Link")
// .setStyle("url")
// .setURL("Link")
// let buttonRow = new MessageActionRow()
// .addComponent(invitecutie)
//!If You Want Button in the Response remove // from the the Above 6 lines
return interaction.reply({ embeds: [responseembed], ephemeral: true })//If you want to send link button add ,component: buttonRow after the ephermeral: true declaration
}
if (interaction.customId === "button_two") {
responseembed.description = `**${config.responses.response_2}**\n\u200b\n`
logchannel.send(`> **${interaction.user.username + "#" + interaction.user.discriminator}**(${interaction.user.id}) Used ${interaction.customId}\nTimeStamp: ${new Date()}`)
return interaction.reply({ embeds: [responseembed], ephemeral: true })
}
if (interaction.customId === "button_three") {
responseembed.description = `**${config.responses.response_3}**`
logchannel.send(`> **${interaction.user.username + "#" + interaction.user.discriminator}**(${interaction.user.id}) Used ${interaction.customId}\nTimeStamp: ${new Date()}`)
return interaction.reply({ embeds: [responseembed], ephemeral: true })
}
if (interaction.customId === "button_four") {
responseembed.description = `**${config.responses.response_4}**`
logchannel.send(`> **${interaction.user.username + "#" + interaction.user.discriminator}**(${interaction.user.id}) Used ${interaction.customId}\nTimeStamp: ${new Date()}`)
return interaction.reply({ embeds: [responseembed], ephemeral: true })
}
if (interaction.customId === "button_five") {
responseembed.description = `**${config.responses.response_5}**`
logchannel.send(`> **${interaction.user.username + "#" + interaction.user.discriminator}**(${interaction.user.id}) Used ${interaction.customId}\nTimeStamp: ${new Date()}`)
return interaction.reply({ embeds: [responseembed], ephemeral: true })
}
if (interaction.customId === "none_of_the_above") {
responseembed.description = `**Go to <#${config.assistance_channel_id}> Channel and ask Your Questions.**`
interaction.guild.members.cache.get(interaction.user.id).roles.add(config.assistance_role_id)
interaction.guild.channels.cache.get(config.assistance_channel_id).send(`<@${interaction.user.id}> Here you can Ask your Further Questions.`)
logchannel.send(`> **${interaction.user.username + "#" + interaction.user.discriminator}**(${interaction.user.id}) Used ${interaction.customId}\nTimeStamp: ${new Date()}`)
return interaction.reply({ embeds: [responseembed], ephemeral: true })
}
}
})
//Message Event only Listen to owners so make sure to fill the owner array in config
client.on("messageCreate", async (msg) => {
if (msg.author.bot) return
if (msg.channel.type === "dm") return
if (!owners.includes(msg.author.id)) return
if (msg.content !== `${config.prefix}create`) return
if (msg.content = `${config.prefix}create`) {
await msg.delete().catch(() => {})
let button1 = new MessageButton()
.setStyle("SECONDARY")
.setEmoji("1️⃣")
.setCustomId("button_one")
let button2 = new MessageButton()
.setEmoji("2️⃣")
.setStyle("SECONDARY")
.setCustomId("button_two")
let button3 = new MessageButton()
.setEmoji("3️⃣")
.setStyle("SECONDARY")
.setCustomId("button_three")
let button4 = new MessageButton()
.setEmoji("4️⃣")
.setStyle("SECONDARY")
.setCustomId("button_four")
//If You Don't Need 5th Button Remove The 4 Lines Below and Remove Line 67
let button5 = new MessageButton()
.setEmoji("5️⃣")
.setStyle("SECONDARY")
.setCustomId("button_five")
let button6 = new MessageButton()
.setLabel("None Of The Above")
.setStyle("SUCCESS")
//.setEmoji("🤷🏻♂️")
.setCustomId("none_of_the_above")
let buttonRow1 = new MessageActionRow()
.addComponents([button1, button2, button3, button4, button5])
let buttonRow2 = new MessageActionRow()
.addComponents([button6])
const supportembed = {
author: { name: config.embed_content.title, icon_url: client.user.displayAvatarURL({ size: 2048, dynamic: false, format:"png"}) },
timestamp: new Date(),
color: `0x${config.embed_content.color}`,
thumbnail: { url: config.thumbnail ? config.thumbnail_url : client.user.displayAvatarURL({ size: 2048, format: "png", dynamic: false}) },
description: `\u200b\n1️⃣ ${config.embed_content.question_1}\n\u200b\n2️⃣ ${config.embed_content.question_2}\n\u200b\n3️⃣ ${config.embed_content.question_3}\n\u200b\n4️⃣ ${config.embed_content.question_4}\n\u200b\n5️⃣ ${config.embed_content.question_5}\n\u200b\n> **None Of The Above**\nIf Your Question is not in the Above List.(Further Assistance)\n\u200b\n`,
footer:{
text: msg.guild.name
}
}
return msg.channel.send({ embeds: [supportembed], components: [buttonRow1, buttonRow2] })
} else return
})
//Bot Coded By Abdul#5464
//For Support Join Support Server https://discord.gg/sAMznQK2NG
//For Feature Request Open a Pull Request
client.login(config.token).catch(() => console.log('Invalid Token.Make Sure To Fill config.json'))