-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommand.js
More file actions
69 lines (57 loc) · 2.35 KB
/
command.js
File metadata and controls
69 lines (57 loc) · 2.35 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
const gif = require("./commands/gif.js");
const booboo = require("./commands/booboo.js");
const test = require("./commands/test.js");
const music = require("./commands/music/music.js");
const commands = {booboo, gif, test};
const ytdl = require('ytdl-core');
const {
AudioPlayerStatus,
StreamType,
createAudioPlayer,
createAudioResource,
joinVoiceChannel,
} = require('@discordjs/voice');
const axios = require('axios');
const cherrio = require('cheerio');
module.exports = async function (msg){
if(msg.channel.id == process.env.CHANNEL){
let tokens = msg.content.split(" ");
let command = tokens.shift();
// gif command prefix !
if(command.charAt(0) == '!'){
command = command.substring(1);
commands[command](msg, tokens);
}
// music command prefix $
else if(command.charAt(0) == '$'){
command = command.substring(1);
music(msg, command, tokens);
}
// music player testing command prefix %
else if(command.charAt(0) == '%'){
voiceChannel = msg.member.voice.channel;
guild = msg.member.guild;
const connection = joinVoiceChannel({
channelId: voiceChannel.id,
guildId: guild.id,
adapterCreator: guild.voiceAdapterCreator,
});
const stream = ytdl('https://www.youtube.com/watch?v=6NYeMlyBP4M', { filter: 'audioonly' });
const resource = createAudioResource(stream, { inputType: StreamType.Arbitrary });
const player = createAudioPlayer();
player.play(resource);
connection.subscribe(player);
console.log(player);
player.on(AudioPlayerStatus.Idle, () => connection.destroy());
}
// arknights command prefix *
// webscraper that pulls up image of character searched (need to figure out how to use url search index)
else if (command.charAt(0) == '*'){
/* const page_url = 'https://gamepress.gg/arknights/operator/skadi-corrupting-heart';
const {data} = await axios.get(page_url);
const $ = cherrio.load(data);
const image = $('.operator-image.current-tab').find('a').attr('href');
msg.channel.send(image); */
}
}
}