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