-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
284 lines (241 loc) · 9.14 KB
/
Copy pathindex.js
File metadata and controls
284 lines (241 loc) · 9.14 KB
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
const { executionAsyncResource } = require('async_hooks');
const Discord = require('discord.js');
const ytdl = require('ytdl-core');
//const config = require("./config.json");
const fetch = require("node-fetch");
const glitchyPing = require("glitchy-ping");
const { YTSearcher } = require('ytsearcher');
const searcher = new YTSearcher({
key: process.env.ytkey,
revealed: true
});
var http = require("http");
http
.createServer(function (req, res) {
res.write("I'm alive");
res.end();
})
.listen(8080);
const client = new Discord.Client();
const queue = new Map();
client.on("ready", () => {
console.log("I am online!");
})
client.on("message", async(message) => {
const prefix = 'z';
const serverQueue = queue.get(message.guild.id);
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
const name = message.content.length
const extraarg = message.content.slice(5, message.content.length).trim();
switch(command){
case 'play':
execute(message, serverQueue);
break;
case 'stop':
stop(message, serverQueue);
break;
case 'skip':
skip(message, serverQueue);
break;
case 'pause':
pause(serverQueue);
break;
case 'resume':
resume(serverQueue);
break;
case 'playlist':
playlist(serverQueue);
break;
case 'saveq':
saveq(serverQueue);
break;
case 'info':
info();
break;
case 'loadq':
loadq(name);
break;
case 'valo' :
valo(extraarg)
default:
}
async function execute(message, serverQueue){
let vc = message.member.voice.channel;
if(!vc){
return message.channel.send("Please join a voice chat first");
}else{
let result = await searcher.search(args.join(" "), { type: "video" })
const songInfo = await ytdl.getInfo(result.first.url)
let song = {
title: songInfo.videoDetails.title,
url: songInfo.videoDetails.video_url
};
if(!serverQueue){
const queueConstructor = {
txtChannel: message.channel,
vChannel: vc,
connection: null,
songs: [],
volume: 10,
playing: true
};
queue.set(message.guild.id, queueConstructor);
queueConstructor.songs.push(song);
try{
let connection = await vc.join();
queueConstructor.connection = connection;
play(message.guild, queueConstructor.songs[0]);
}catch (err){
console.error(err);
queue.delete(message.guild.id);
return message.channel.send(`Unable to join the voice chat ${err}`)
}
}else{
serverQueue.songs.push(song);
return message.channel.send(`The song has been added ${song.url}`);
}
}
}
function play(guild, song){
const serverQueue = queue.get(guild.id);
if(!song){
serverQueue.vChannel.leave();
queue.delete(guild.id);
return;
}
const dispatcher = serverQueue.connection
.play(ytdl(song.url))
.on('finish', () =>{
serverQueue.songs.shift();
play(guild, serverQueue.songs[0]);
})
serverQueue.txtChannel.send(`Now playing ${serverQueue.songs[0].url}`)
}
function stop (message, serverQueue){
if(!message.member.voice.channel)
return message.channel.send("You need to join the voice chat first!")
serverQueue.songs = [];
serverQueue.connection.dispatcher.end();
}
function skip (message, serverQueue){
if(!message.member.voice.channel)
return message.channel.send("You need to join the voice chat first");
if(!serverQueue)
return message.channel.send("There is nothing to skip!");
serverQueue.connection.dispatcher.end();
}
function pause (serverQueue){
if(!message.member.voice.channel)
return message.channel.send("You need to join the voice chat first");
if(!serverQueue.connection)
return message.channel.send("There is no songs being played");
if(serverQueue.connection.dispatcher.paused){
return message.channel.send("already paused!");
}
serverQueue.connection.dispatcher.pause();
message.channel.send("Paused the current song!");
}
function resume (serverQueue){
if(!message.member.voice.channel)
return message.channel.send("You need to join the voice chat first");
if(!serverQueue.connection)
return message.channel.send("There is no songs being played");
if(serverQueue.connection.dispatcher.resumed){
return message.channel.send("already resume!");
}
serverQueue.connection.dispatcher.resume();
message.channel.send("Resuming the current song!");
}
function playlist (serverQueue){
if(!message.member.voice.channel)
return message.channel.send("You need to join the voice chat first");
if(!serverQueue){
return message.channel.send("nothing to save! add a song first");
}else{
const qembed = new Discord.MessageEmbed();
qembed.setColor('#add8e6');
for(let i = 0; i< serverQueue.songs.length ; i++){
//console.log(serverQueue.songs[i]);
qembed.addField(`Song-[${i+1}]` , serverQueue.songs[i].title );
}
message.channel.send(qembed);
}
}
function info() {
const infoembed = new Discord.MessageEmbed();
infoembed
.setColor("#add8e6")
.setTitle("Some info on Zev Commands ", "\u200B")
.addField("Play any song - zplay <song name>", "\u200B")
.addField("Pause the current track - zpause", "\u200B")
.addField("Resume the current track - zresume", "\u200B")
.addField("Skip the currnt track - zskip", "\u200B")
.addField("Get the queue of songs - zplaylist", "\u200B")
.addField("Get information about your selected agent - zvalo <agent name>", "\u200B");
message.channel.send(infoembed);
}
function saveq (serverQueue){
const saveembed = new Discord.MessageEmbed()
.setColor('#add8e6')
.setAuthor(`${message.channel.author}`)
for(let i = 0; i< serverQueue.songs.length ; i++){
saveembed.addField(`Song-[${i+1}]` , serverQueue.songs[i].title );
}
//const json = {saveembed};
}
function loadq (name){}
function valo(name){
fetch("https://valorant-api.com/v1/agents")
.then((response) => response.json())
.then((data) => {
const valoembed = new Discord.MessageEmbed();
valoembed
.setColor("#add8e6")
.setTitle(`Some info on selected Valorant Agent`, "\u200B")
.setThumbnail(
"https://cdn.dribbble.com/users/2348/screenshots/10696082/valorant_1_4x.png"
);
for (let i = 0 ; i< data.data.length ; i++){
if (name == data.data[i].displayName.toLowerCase())
{
console.log("i am free");
valoembed
.addField(`Agent Number: ${i}`, "\u200B")
.setImage(`${data.data[i].displayIcon}`)
.addField(`Name: ${data.data[i].displayName}`, "\u200B")
.addField(
`Description: ${data.data[i].description}`,
"\u200B"
)
.addField(
`${data.data[i].role.displayName}: ${data.data[i].role.description}`,
"\u200B"
);
}
}
console.log("---")
message.channel.send(valoembed);
});
}
})
//let gg;
//if(gg === 5){
// gg = 0;
//}
//setInterval(async () => {
// await fetch("https://paint-functional-mistake.glitch.me").then(gg++)
//},240000)
glitchyPing.pingURL("https://paint-functional-mistake.glitch.me", 180000); // 180000ms == 180s == 3min
<<<<<<< HEAD
/* setInterval(async () => {
await fetch("https://paint-functional-mistake.glitch.me").then(
console.log("pinged!")
);
}, 240000);
*/ // for pinging in glitch
client.login(process.env.dskey);
// check uptimerobot pls for uptiming bot also glitch for deploying
=======
client.login(process.env.dskey);
>>>>>>> b1420f3388f2bcc3129e5e13f64bab1d1803c48a