forked from commandblockguy/EigenBot
-
Notifications
You must be signed in to change notification settings - Fork 3
/
utils.js
31 lines (28 loc) · 1.07 KB
/
utils.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
export function replyNoMention(interaction, response) {
if (typeof response === 'object') {
response.allowedMentions = {repliedUser: false}
} else {
response = {content: response, allowedMentions: {repliedUser: false}}
}
return interaction.deferred ? interaction.editReply(response) : interaction.reply(response)
}
export function editNoMention(msg, response) {
if (typeof response === 'object') {
response.allowedMentions = {repliedUser: false}
} else {
response = {content: response, allowedMentions: {repliedUser: false}}
}
return msg.edit(response)
}
export function reformatUUID(uuid) {
if (uuid.includes('-')) return reformatUUID(uuid.replace(/-/g, ''))
return uuid.slice(0, 8) + '-' + uuid.slice(8, 12) + '-' + uuid.slice(12, 16) + '-' + uuid.slice(16, 20) + '-' + uuid.slice(20)
}
export function readFully(stream) {
return new Promise((resolve, reject) => {
let data = ''
stream.on('data', d => data += d)
stream.on('end', () => resolve(data))
stream.on('err', reject)
})
}