Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vKxni committed May 11, 2021
0 parents commit 98b9a0b
Show file tree
Hide file tree
Showing 3,340 changed files with 423,926 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/config.json
Empty file added 24/cap-setup.js
Empty file.
Empty file added 24/icloud.t
Empty file.
Empty file added 24/main.ss
Empty file.
Empty file added 24/radio.stations.yml
Empty file.
Binary file added data/enmap.sqlite
Binary file not shown.
Binary file added data/enmap.sqlite-shm
Binary file not shown.
Binary file added data/enmap.sqlite-wal
Binary file not shown.
32 changes: 32 additions & 0 deletions distube-handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = (client, Discord, ee) => {
client.distube
.on("error", (message, error) => {
console.log(error)
})
.on("playSong", (message, queue, song) => {
if(!client.playcmd) return;
client.playcmd = false;
message.channel.send(`Started Playing \`${song.name}\` - \`${song.formattedDuration}\`\nRequested by: ${song.user}`)
})
.on("playList", (message, queue, song) => {
if(!client.playcmd) return;
client.playcmd = false;
message.channel.send(`Started Playing \`${playlist.name}\` playlist (${playlist.songs.length} songs).\nRequested by: ${song.user}\nNow playing \`${song.name}\` - \`${song.formattedDuration}\``)
})
.on("addSong", (message, queue, song) => {
if(!client.playcmd) return;
client.playcmd = false;
message.channel.send(`Added track: \`${song.name}\` - \`${song.formattedDuration}\`\nRequested by: ${song.user}`)
})
.on("addList", (message, queue, song) => {
if(!client.playcmd) return;
client.playcmd = false;
message.channel.send(`Added Playlist: \`${playlist.name}\` (${playlist.songs.length} songs).\nRequested by: ${song.user}`)
})
.on("initQueue", queue => {
console.log("STARTED PLAYING A WAITINGROOM TRACK")
queue.autoplay = false;
queue.loop = 2;
queue.volume = 20;
})
}
277 changes: 277 additions & 0 deletions events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
module.exports = (client, Discord, ee) => {
var prefix = require("./config.json").prefix;


client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}`)
client.user.setActivity(`${client.guilds.cache.map(s => s.memberCount).reduce((a, b) => a + b)} Servers || *setup`, { type: 'WATCHING' })

setInterval(async ()=>{
for(const guild of client.guilds.cache.array()){
client.db.ensure(guild.id, {
song: "https://www.youtube.com/watch?v=-ObdvMkCKws",
channel: "no",
})
var data = client.db.get(guild.id)
if(data.channel == "no") continue;
var channel = guild.channels.cache.get(data.channel)
if(channel.members.array().length > 2) continue;
var txtchannel = guild.channels.cache.find(
channel =>
channel.type === "text" &&
channel.permissionsFor(guild.me).has("SEND_MESSAGES")
);
var message = await txtchannel.send("✳️ Joining voice channel...").then(msg=>msg.delete())
const botchannel = message.guild.me.voice.channel;
if(botchannel) continue;
message.member.voice.channel = channel;
try{
var voicechannel = message.guild.channels.cache.get(data.channel);
if(!voicechannel) continue;
if(voicechannel.type == "voice") {
setTimeout(async()=>{
await voicechannel.join().catch(e=>console.log(e))
client.distube.play(message, data.song);
}, 400)
}
}catch (e){
console.log(e)
}
}
}, 60000)
})


client.on("message", async (message) => {
if(!message.guild || message.author.bot) return;
if(!message.content.startsWith(prefix)) return;

// "!play a b c d" --> "play a b c d" --> ["a", "b", "c", "d"] && cmd == "play".toLowerCase()
var args = message.content.slice(prefix.length).trim().split(" ");
var cmd = args.shift().toLowerCase();

client.db.ensure(message.guild.id, {
song: "https://www.youtube.com/watch?v=-ObdvMkCKws",
channel: "no",
})


if(cmd == "setup"){
const { channel } = message.member.voice;
if(!channel) return message.reply("📛 Please join a VC first, then re-run this command!")

if(!args[0]) return message.reply("📛 Please enter a valid Youtube/soundcloud TRACK/PLAYLIST")
// ["a", "n"] --> "a n"
client.db.set(message.guild.id, args.join(" ") ,"song")
client.db.set(message.guild.id, channel.id, "channel");
message.reply("✅ Success!")
var data = client.db.get(message.guild.id);
try {
var vc = message.guild.channels.cache.get(data.channel)
if(!vc) return message.reply("📛 I could not find your wished Channel")
if(vc.type == "voice"){
await vc.join().catch(e=>console.log(e))
await client.distube.play(message, data.song)
client.distube.shuffle(message);
return message.reply("✅ Joined and started playing!")
}
}catch (e){
message.channel.send(e.message, {code: "js"});
console.log(e)
}
}
if(cmd == "join") {
const botchannel = message.guild.me.voice.channel;
if(botchannel) return message.reply("⚠️ I am already connected somewhere");

var data = client.db.get(message.guild.id);
if(data.channel == "no") return message.reply(`⚠️ No setup done yet! do it with: ${prefix}setup`)

try{
var vc = message.guild.channels.cache.get(data.channel)
if(!vc) return message.reply("⚠️ I could not find your wished Channel")
if(vc.type == "voice"){
await vc.join().catch(e=>console.log(e))
await client.distube.play(message, data.song)
client.distube.shuffle(message);
return message.reply("✅ Joined and started playing in the setup Channel!")
}
}catch (e){
message.channel.send(e.message, {code: "js"});
console.log(e)
}
}
if(cmd == "rejoin") {
const botchannel = message.guild.me.voice.channel;
if(botchannel) await message.guild.me.voice.kick().catch(e=>console.log(e))

var data = client.db.get(message.guild.id);
if(data.channel == "no") return message.reply(`⚠️ No setup done yet! do it with: ${prefix}setup`)

try{
var vc = message.guild.channels.cache.get(data.channel)
if(!vc) return message.reply("⚠️ I could not find your wished Channel")
if(vc.type == "voice"){
await vc.join().catch(e=>console.log(e))
await client.distube.play(message, data.song)
client.distube.shuffle(message);
return message.reply("✅ Rejoined and started playing in the setup Channel!")
}
}catch (e){
message.channel.send(e.message, {code: "js"});
console.log(e)
}
}
if(cmd == "stop" || cmd == "leave" || cmd == "disconnect" || cmd == "dis" ) {
const botchannel = message.guild.me.voice.channel;
if(!botchannel) return message.reply("⚠️ I am not connected somewhere");
message.guild.me.voice.kick().catch(e=>console.log(e));
return message.reply("✅ Stopped and leaft the Channel!")
}
if(cmd == "play"){
const botchannel = message.guild.me.voice.channel;
const { channel } = message.member.voice;
if(!channel) return message.reply("⚠️ Please join a Voice Channel first!")
if(botchannel && client.distube.getQueue(message) && channel.id != botchannel.id) return message.reply("⚠️ I am already playing somewhere");
client.playcmd = true;
client.distube.play(message, args.join(" "));
}
if(cmd == "help"){
message.reply(`
Here are my Commands:
1️⃣ **setup** (Setup the Bot for your Server)
2️⃣ **play** [Song] (Play any song you like in your VC)
3️⃣ **rejoin** (Something went wrong? Let the bot rejoin!)
4️⃣ **join** (Should the bot really join your voice channel? :D)
5️⃣ **stop/leave/dis** (Stop/disconnect the bot playing music)
`)
}
})


client.on("voiceStateUpdate", async (oldState, newState) => {
let user = newState.member.user.tag;
if(newState.member.user.bot) return;
if(!oldState.streaming && newState.streaming) return;
if(oldState.streaming && !newState.streaming) return;

if(!oldState.serverDeaf && newState.serverDeaf) return;
if(oldState.serverDeaf && !newState.serverDeaf) return;

if(!oldState.serverMute && newState.serverMute) return;
if(oldState.serverMute && !newState.serverMute) return;

if(!oldState.selfDeaf && newState.selfDeaf) return;
if(oldState.selfDeaf && !newState.selfDeaf) return;

if(!oldState.selfMute && newState.selfMute) return;
if(oldState.selfMute && !newState.selfMute) return;

if(!oldState.selfVideo && newState.selfVideo) return;
if(oldState.selfVideo && !newState.selfVideo) return;

//JOINED VOICE CHANNEL
if(!oldState.channelID && newState.channelID){
var data = client.db.get(newState.guild.id);
if(data.channel == "no") return;
if(data.channel == newState.channelID){
if(newState.channel.members.array().length > 2) return;
var channel = newState.guild.channels.cache.find(channel =>
channel.type === "text" &&
(channel.permissionsFor(newState.guild.id).has("SEND_MESSAGES") || channel.permissionsFor(newState.guild.me).has("SEND_MESSAGES")))

if(!channel) return;
var message = await channel.send("Joining Voice Channel ...").then(msg=>msg.delete())
const botchannel = message.guild.me.voice.channel;
if(botchannel) await message.guild.me.voice.kick().catch(e=>console.log(e))

message.member = newState.member;
message.member.voice.channel = newState.channel;

try{
var vc = message.guild.channels.cache.get(data.channel)
if(!vc) return;
if(vc.type == "voice"){
setTimeout(async ()=>{
await vc.join().catch(e=>console.log(e))
await client.distube.play(message, data.song)
client.distube.shuffle(message);
}, 400)
}
}catch (e){
console.log(e)
}
}
}

//SWITCH VOICE CHANNEL
if(oldState.channelID && newState.channelID){
var data = client.db.get(newState.guild.id);
if(data.channel == "no") return;
if(data.channel == newState.channelID){
if(newState.channel.members.array().length > 2) return;
var channel = newState.guild.channels.cache.find(channel =>
channel.type === "text" &&
(channel.permissionsFor(newState.guild.id).has("SEND_MESSAGES") || channel.permissionsFor(newState.guild.me).has("SEND_MESSAGES")))

if(!channel) return;
var message = await channel.send("✳️ Joining Voice Channel ...").then(msg=>msg.delete())
const botchannel = message.guild.me.voice.channel;
if(botchannel) await message.guild.me.voice.kick().catch(e=>console.log(e))

message.member = newState.member;
message.member.voice.channel = newState.channel;

try{
var vc = message.guild.channels.cache.get(data.channel)
if(!vc) return;
if(vc.type == "voice"){
setTimeout(async ()=>{
await vc.join().catch(e=>console.log(e))
await client.distube.play(message, data.song)
client.distube.shuffle(message);
}, 400)
}
}catch (e){
console.log(e)
}
}
if(data.channel == oldState.channelID){
try{
if(oldState.channel.members.array().length >= 2) return;
const botchannel = newState.guild.me.voice.channel;
if(botchannel){
await newState.guild.me.voice.kick().catch(e=>console.log(e))
}
setTimeout(async () => {
await oldState.channel.join().catch(e=>console.log(e))
})
}catch (e){
console.log(e)
}
}
}

//LEAVE VOICE CHANNEL
if(oldState.channelID && !newState.channelID){
var data = client.db.get(newState.guild.id);
if(data.channel == "no") return;
if(data.channel == oldState.channelID){
try{
if(oldState.channel.members.array().length >= 2) return;
const botchannel = newState.guild.me.voice.channel;
if(botchannel){
await newState.guild.me.voice.kick().catch(e=>console.log(e))
}
setTimeout(async () => {
await oldState.channel.join().catch(e=>console.log(e))
})
}catch (e){
console.log(e)
}
}
}
})


}
34 changes: 34 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const Discord = require("discord.js");
const client = new Discord.Client({
restTimeOffset: 0,
disableEveryone: true,
partials: ["MESSAGE", "CHANNEL", "REACTION"]
})
const Distube = require("distube");
client.playcmd = false;
client.distube = new Distube(client, {
searchSongs: false,
emitNewSongOnly: false,
highWaterMark: 1024 * 1024 * 64,
leaveOnEmpty: false,
leaveOnFinish: false,
leaveOnStop: true,
youtubeDL: true,
updateYoutubeDL: true,
// cOoKiEs from youtube
})

const embedsettings = {
color: "#12ff56",
wrongcolor: "#e01e01",
footertext: "24/7 Musik - powered by Fairfight",
footericon: "https://img.icons8.com/color/452/discord-logo.png"
}

require("./distube-handler")(client, Discord, embedsettings)
require("./events")(client, Discord, embedsettings)

const enmap = require("enmap");
client.db = new enmap({name: "mydatabase"})

client.login(require("./config.json").token)
15 changes: 15 additions & 0 deletions node_modules/.bin/detect-libc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/.bin/detect-libc.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 98b9a0b

Please sign in to comment.