Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { Client, GatewayIntentBits, ChannelType, ActivityType } = require('discord.js');
- const { joinVoiceChannel, createAudioResource } = require('@discordjs/voice');
- const { createAudioPlayer } = require('@discordjs/voice');
- const player = createAudioPlayer();
- const ses = createAudioResource('./ses.mp3');
- const fs = require('fs');
- const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates] });
- client.once('ready', async () => {
- console.log(`Logged in as ${client.user.tag}`);
- client.user.setPresence({
- activities: [{ name: 'The Casino', type: ActivityType.Playing }],
- status: 'online',
- });
- try {
- const channel = await client.channels.fetch("1278792596101136435");
- console.log(`Found voice channel: ${channel.name}`);
- if(!channel) return console.error('Voice channel not found.');
- if (channel && channel.type === ChannelType.GuildVoice) {
- const connection = joinVoiceChannel({
- channelId: "1278792596101136435",
- guildId: "1278785780302479421",
- adapterCreator: channel.guild.voiceAdapterCreator,
- selfDeaf: true
- });
- const subscription = connection.subscribe(player);
- console.log(`Joined voice channel: ${channel.name}`);
- } else {
- console.error('Voice channel not found or not a voice channel.');
- }
- } catch (error) {
- console.error(`Could not join voice channel: ${error}`);
- }
- });
- client.on('voiceStateUpdate', async (oldState, newState) => {
- const giren = await client.users.fetch(newState.member.id)
- if(giren.bot) return;
- console.log("biri girdi")
- player.play(ses)
- })
- player.on('error', error => {
- console.error(`Error: ${error.message}`);
- player.play(getNextResource());
- });
- client.login();
Advertisement
Add Comment
Please, Sign In to add comment