const { Client, GatewayIntentBits, Partials } = require("discord.js");
const ayarlar = require("./ayarlar.json");
const { joinVoiceChannel, createAudioPlayer, createAudioResource, NoSubscriberBehavior } = require('@discordjs/voice');
const fs = require('fs');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.MessageContent
],
partials: [Partials.Channel, Partials.Message, Partials.User, Partials.GuildMember, Partials.Reaction]
});
module.exports = client;
require("./events/message.js");
require("./events/ready.js");
const express = require("express");
const app = express();
const http = require("http");
app.get("/", (request, response) => {
response.sendStatus(200);
});
app.listen(process.env.PORT);
client.login(process.env.TOKEN || ayarlar.token);
// Ses dosyalarının bulunduğu dizin
const sesDizini = './sesler/';
// Ses dosyası çalma fonksiyonu
async function rastgeleSesCal(kanalId) {
try {
const sesDosyalari = fs.readdirSync(sesDizini).filter(dosya => dosya.endsWith('.ogg'));
if (sesDosyalari.length === 0) {
console.error('Ses dosyası bulunamadı!');
return;
}
const rastgeleDosya = sesDosyalari[Math.floor(Math.random() * sesDosyalari.length)];
const baglanti = joinVoiceChannel({
channelId: kanalId,
guildId: ''x", // Sunucu kimliğinizi buraya girin
adapterCreator: client.guilds.cache.get('x').voiceAdapterCreator,
});
const player = createAudioPlayer({
behaviors: {
noSubscriber: NoSubscriberBehavior.Pause
}
});
const kaynak = createAudioResource(sesDizini + rastgeleDosya);
player.play(kaynak);
// Oynatıcıyı başlatma
baglanti.subscribe(player);
} catch (hata) {
console.error('Ses dosyası çalınırken bir hata oluştu:', hata);
}
}
// Rastgele mesaj gönderme fonksiyonu
function rastgeleMesajGonder() {
const channelId = 'x'; // Metin kanalı kimliğinizi buraya girin
const mesajlar = [
"x"
// İstediğiniz kadar mesaj ekleyebilirsiniz
];
const randomIndex = Math.floor(Math.random() * mesajlar.length);
const mesaj = mesajlar[randomIndex];
const kanal = client.channels.cache.get(channelId);
if (kanal) {
kanal.send(mesaj);
} else {
console.error("Kanal bulunamadı!");
}
}
client.once('ready', () => {
console.log('Bot başarıyla bağlandı.');
// Her dakikada bir rastgeleSesCal fonksiyonunu çağır
setInterval(rastgeleSesCal, 15000, ''); // Ses kanalı kimliğinizi buraya girin
// Her saat başında rastgeleMesajGonder fonksiyonunu çağır
setInterval(rastgeleMesajGonder, 3600000); // 3600000 milisaniye = 1 saat
});