-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
71 lines (58 loc) · 2.41 KB
/
index.js
File metadata and controls
71 lines (58 loc) · 2.41 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
const { Client, GatewayIntentBits, EmbedBuilder } = require('discord.js');
const { joinVoiceChannel, createAudioPlayer, createAudioResource, AudioPlayerStatus, VoiceConnectionStatus } = require('@discordjs/voice');
const play = require('play-dl');
require('dotenv').config();
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
});
const express = require("express")
const app = express();
var listener = app.listen(process.env.PORT || 2000, function () {
console.log('Your app is listening on port ' + listener.address().port);
});
app.listen(() => console.log("I'm Ready To Work..! 24H"));
app.get('/', (req, res) => {
res.send(`
<body>
<center><h1>Bot 24H ON!</h1></center
</body>`)
});
const channelId = '1210233988699131946';
const guildId = '1011820688228765828';
const Url = 'https://youtu.be/fLkdQeeRtYs?si=02zwuFdQbytcD09f';
client.on('ready', () => {
console.log(`✅ | Logged in as ${client.user.tag}`);
joinAndPlayQuran(guildId, channelId);
});
async function playQuran(channel, message) {
const player = createAudioPlayer();
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
});
connection.subscribe(player);
const stream = await play.stream(Url);
const resource = createAudioResource(stream.stream, { inputType: stream.type });
player.play(resource);
player.on(AudioPlayerStatus.Playing, () => {
message.channel.send({ embeds: [new EmbedBuilder().setDescription('**تم تشغيل القرآن**').setColor(0x00ff00)] });
});
player.on('error', error => console.error(`Error: ${error.message}`));
}
async function joinAndPlayQuran(guildId, channelId) {
const channel = await client.channels.fetch(channelId);
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: guildId,
adapterCreator: channel.guild.voiceAdapterCreator,
});
const player = createAudioPlayer();
const stream = await play.stream(Url);
const resource = createAudioResource(stream.stream, { inputType: stream.type });
player.play(resource);
connection.subscribe(player);
player.on(AudioPlayerStatus.Playing, () => console.log('Playing Quran'));
player.on('error', error => console.error(`Error: ${error.message}`));
}
client.login(process.env.TOKEN);