1 |
import { CommandInteraction, GuildMember, Interaction, Message, MessageActionRow, MessageButton } from 'discord.js'; |
import { CommandInteraction, InteractionCollector, Message, MessageActionRow, MessageButton } from 'discord.js'; |
2 |
import BaseCommand from '../../utils/structures/BaseCommand'; |
import BaseCommand from '../../utils/structures/BaseCommand'; |
3 |
import DiscordClient from '../../client/Client'; |
import DiscordClient from '../../client/Client'; |
|
import CommandOptions from '../../types/CommandOptions'; |
|
4 |
import InteractionOptions from '../../types/InteractionOptions'; |
import InteractionOptions from '../../types/InteractionOptions'; |
5 |
import MessageEmbed from '../../client/MessageEmbed'; |
import MessageEmbed from '../../client/MessageEmbed'; |
|
import Help from '../../utils/help'; |
|
6 |
import { MessageButtonStyles } from 'discord.js/typings/enums'; |
import { MessageButtonStyles } from 'discord.js/typings/enums'; |
7 |
import { fetchEmoji } from '../../utils/Emoji'; |
import { fetchEmoji } from '../../utils/Emoji'; |
8 |
|
|
55 |
|
|
56 |
const reply = <Message> await interaction.fetchReply(); |
const reply = <Message> await interaction.fetchReply(); |
57 |
|
|
58 |
reply.awaitMessageComponent({ |
const collector = new InteractionCollector(client, { |
59 |
|
channel: reply.channel, |
60 |
|
message: reply, |
61 |
componentType: 'BUTTON', |
componentType: 'BUTTON', |
62 |
filter(interaction) { |
interactionType: 'MESSAGE_COMPONENT', |
63 |
return interaction.customId.startsWith('restart'); |
filter(i) { |
64 |
|
return i.isButton() && i.customId.startsWith('restart'); |
65 |
}, |
}, |
66 |
time: 15000 |
time: 15000 |
67 |
}) |
}); |
68 |
.then(async i => { |
|
69 |
|
collector.on('collect', async i => { |
70 |
|
if (!i.isButton()) |
71 |
|
return; |
72 |
|
|
73 |
|
if (i.member!.user.id !== interaction.member!.user.id) { |
74 |
|
await i.reply({ |
75 |
|
content: 'That\'s not your button.', |
76 |
|
ephemeral: true |
77 |
|
}); |
78 |
|
|
79 |
|
return; |
80 |
|
} |
81 |
|
|
82 |
if (i.customId === 'restart:true') { |
if (i.customId === 'restart:true') { |
83 |
await i.update({ |
await i.update({ |
84 |
embeds: [ |
embeds: [ |
110 |
components: [disabledRow] |
components: [disabledRow] |
111 |
}); |
}); |
112 |
} |
} |
|
}) |
|
|
.catch(async e => { |
|
|
console.log(e); |
|
|
|
|
|
await reply.edit({ |
|
|
embeds: [ |
|
|
new MessageEmbed() |
|
|
.setColor('GREY') |
|
|
.setTitle('System Restart') |
|
|
.setDescription('This action has been canceled due to inactivity.') |
|
|
], |
|
|
components: [disabledRow] |
|
|
}); |
|
113 |
}); |
}); |
114 |
|
|
115 |
|
collector.on('end', async i => { |
116 |
|
if (reply.embeds[0].hexColor === '#007bff') { |
117 |
|
await reply.edit({ |
118 |
|
embeds: [ |
119 |
|
new MessageEmbed() |
120 |
|
.setColor('GREY') |
121 |
|
.setTitle('System Restart') |
122 |
|
.setDescription('This action has been canceled due to inactivity.') |
123 |
|
], |
124 |
|
components: [disabledRow] |
125 |
|
}); |
126 |
|
} |
127 |
|
}); |
128 |
|
|
129 |
|
// reply.awaitMessageComponent({ |
130 |
|
// componentType: 'BUTTON', |
131 |
|
// filter(i) { |
132 |
|
// return i.customId.startsWith('restart') && i.member!.user.id === interaction.member!.user.id; |
133 |
|
// }, |
134 |
|
// time: 15000 |
135 |
|
// }) |
136 |
|
// .then(async i => { |
137 |
|
// if (i.customId === 'restart:true') { |
138 |
|
// await i.update({ |
139 |
|
// embeds: [ |
140 |
|
// new MessageEmbed() |
141 |
|
// .setColor('#007bff') |
142 |
|
// .setTitle('System Restart') |
143 |
|
// .setDescription((await fetchEmoji('loading'))!.toString() + ' Restarting...') |
144 |
|
// ], |
145 |
|
// components: [disabledRow] |
146 |
|
// }); |
147 |
|
|
148 |
|
// await client.startupManager.createLockFile({ |
149 |
|
// date: new Date().toISOString(), |
150 |
|
// guild_id: i.guild!.id, |
151 |
|
// channel_id: i.channel!.id, |
152 |
|
// message_id: reply.id |
153 |
|
// }); |
154 |
|
|
155 |
|
// await process.exit(0); |
156 |
|
// } |
157 |
|
// else { |
158 |
|
// await i.update({ |
159 |
|
// embeds: [ |
160 |
|
// new MessageEmbed() |
161 |
|
// .setColor('GREY') |
162 |
|
// .setTitle('System Restart') |
163 |
|
// .setDescription('This action has been canceled.') |
164 |
|
// ], |
165 |
|
// components: [disabledRow] |
166 |
|
// }); |
167 |
|
// } |
168 |
|
// }) |
169 |
|
// .catch(async e => { |
170 |
|
// console.log(e); |
171 |
|
|
172 |
|
// await reply.edit({ |
173 |
|
// embeds: [ |
174 |
|
// new MessageEmbed() |
175 |
|
// .setColor('GREY') |
176 |
|
// .setTitle('System Restart') |
177 |
|
// .setDescription('This action has been canceled due to inactivity.') |
178 |
|
// ], |
179 |
|
// components: [disabledRow] |
180 |
|
// }); |
181 |
|
// }); |
182 |
} |
} |
183 |
} |
} |