-
Notifications
You must be signed in to change notification settings - Fork 3
/
controlMusic.lua
85 lines (78 loc) · 1.73 KB
/
controlMusic.lua
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
-- usage:
-- !music
local discordia = require("discordia")
require("discordia-components")
local client = discordia.Client()
local musicalControls = discordia.Components {
{
id = "skip_backwards",
type = "button",
label = "Previous Song",
emoji = "⏪",
},
{
id = "resume",
type = "button",
label = "Resume Song",
emoji = "▶️",
},
{
id = "pause",
type = "button",
label = "Pause Song",
emoji = "⏸️",
},
{
id = "skip_forward",
type = "button",
label = "Next Song",
style = "secondary",
emoji = "⏩",
},
{
id = "abort",
type = "button",
label = "Abort Song",
style = "danger",
actionRow = 2,
},
}
local action_map = {
skip_backwards = function (intr)
intr:reply("Skipped to previous song", true)
end,
resume = function (intr)
intr:update("Song is currently playing!")
end,
pause = function (intr)
intr:update("Song is currently paused!")
end,
skip_forward = function (intr)
intr:reply("Skipped to next song", true)
end,
abort = function (intr, msg)
msg:setComponents(false)
intr:reply {
embed = {
title = "Aborted",
color = 0xf20000,
}
}
end,
}
client:on("messageCreate", function(message)
if message.content == "!music" then
local sent_msg = message:replyComponents("Here your music controls!", musicalControls)
local success, interaction
local pressed_button
repeat
success, interaction = sent_msg:waitComponent("button")
if not success then
break
end
pressed_button = interaction.data.custom_id
action_map[pressed_button](interaction, sent_msg)
until pressed_button == "abort"
end
end)
client:run("Bot [TOKEN]")