const Discord = require('discord.js');
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({ intents:
[
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates,
]
});
const config = require('./config.json');
const { joinVoiceChannel, createAudioPlayer, NoSubscriberBehavior, createAudioResource, AudioPlayerStatus, VoiceConnectionStatus, StreamType } = require('@discordjs/voice');
const { join } = require('path');
client.once('ready', async() => {
console.log("connected");
const channels = client.guilds.cache.find(f => f.name==="Riverside").channels;
let channel= channels.cache.find(r => r.name === "General");
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guildId,
adapterCreator: channel.guild.voiceAdapterCreator,
});
console.log("joined voice channel");
const player = createAudioPlayer();
let resource = createAudioResource("https://streams.ilovemusic.de/iloveradio2.mp3", { inlineVolume: true,
inputType: StreamType.Arbitrary});
resource.volume.setVolume(1)
connection.subscribe(player);
player.play(resource);
});
client.login(config.token);