Skip to content

Commit

Permalink
New Music Temporary
Browse files Browse the repository at this point in the history
  • Loading branch information
inventionpro committed Sep 11, 2024
1 parent 735152d commit 821db46
Show file tree
Hide file tree
Showing 25 changed files with 1,913 additions and 604 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.replit
replit.nix

# Logs
logs
*.log
Expand Down
1 change: 1 addition & 0 deletions .replit
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
entrypoint = "index.js"
modules = ["nodejs-20:v8-20230920-bd784b9"]
run = "npm run start"

hidden = [".config", "package-lock.json", ".prettierignore"]
Expand Down
6 changes: 5 additions & 1 deletion databases/emojis.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,9 @@
"good": "<:checkmark:1151187114306834573>",
"blocker": "<:x_:1151187088037924954>",
"bad": "<:mid:1170361807999873204>",
"neutral": "<:neutral:1170361811556646933>"
"neutral": "<:neutral:1170361811556646933>",

"tl": "<:tl:1279765592060203028>",
"ti": "<:ti:1279765868972081152>",
"tr": "<:tr:1279765620216430622>"
}
1 change: 0 additions & 1 deletion newFsh/commands/eval.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const Discord = require("discord.js");
const os = require("node:os");
const https = require("https");
const crypto = require("crypto");
const ytstream = require('yt-stream');
const fs = require("node:fs");

// evel these vars for funnis
Expand Down
23 changes: 23 additions & 0 deletions newFsh/commands/music/filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const Discord = require("discord.js");
const { useQueue, useTimeline } = require("discord-player");

module.exports = {
name: "filter",
params: [],
info: "Adds a filter the song",
category: "hidden",

async execute(message, arguments2, fsh) {
if (true) return;
if (fsh.music.checkVoice(message)) return;
let queue = useQueue(message.guild.id);
if (fsh.music.checkQueue(message, queue)) return;
if (fsh.music.checkSameVoice(message, queue)) return;
if (!queue.filters.ffmpeg) {
message.reply('filters not available')
return;
}
queue.filters.ffmpeg.setFilters(false);
queue.filters.ffmpeg.toggle(arguments[0]);
}
}
11 changes: 9 additions & 2 deletions newFsh/commands/music/leave.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Discord = require("discord.js");
const { useQueue } = require("discord-player");

module.exports = {
name: ["leave", "stop"],
Expand All @@ -7,7 +8,13 @@ module.exports = {
category: "music",

async execute(message, arguments2, fsh) {
if (!message.member.voice?.channel) return message.channel.send('connect to a Voice Channel');
fsh.music.leave(message.guild.id)
if (fsh.music.checkVoice(message)) return;
let queue = useQueue(message.guild.id);
if (fsh.music.checkQueue(message, queue)) return;
if (fsh.music.checkSameVoice(message, queue)) return;
if (!queue.deleted) {
queue.delete();
message.reply('left');
}
}
}
28 changes: 21 additions & 7 deletions newFsh/commands/music/loop.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
const Discord = require("discord.js");
const { useQueue, QueueRepeatMode } = require("discord-player");

module.exports = {
name: "loop",
params: [],
info: "Set the current song to loop or not",
category: "music",
params: ['mode', false],
info: "Set the current song loop mode",
category: "hidden",

async execute(message, arguments2, fsh) {
if (!message.member.voice?.channel) return message.channel.send('connect to a Voice Channel');
if (fsh.music.looped.get(message.guild.id)) {
fsh.music.unloop(message.guild.id)
if (fsh.music.checkVoice(message)) return;
let queue = useQueue(message.guild.id);
if (fsh.music.checkQueue(message, queue)) return;
if (fsh.music.checkSameVoice(message, queue)) return;
if (!arguments2[0]) {
message.channel.send('current loop mode: '+ QueueRepeatMode[queue.repeatMode].toLowerCase())
} else {
fsh.music.loop(message.guild.id)
if (!['off','queue','track','autoplay'].includes(arguments2[0])) {
message.reply('available loop modes: off, queue, track and autoplay');
return;
}
let past = QueueRepeatMode[queue.repeatMode].toLowerCase();
if (past === arguments2[0]) {
message.reply('loop mode alredy is '+past)
return;
}
queue.setRepeatMode(QueueRepeatMode[arguments2[0].toUpperCase()]);
message.reply('changed loop mode from `'+past+'` to `'+arguments2[0]+'`')
}
}
}
42 changes: 42 additions & 0 deletions newFsh/commands/music/now-playing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const Discord = require("discord.js");
const { useQueue, useTimeline } = require("discord-player");

function prettyNumber(x) {
x = x.toString();
x = x.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
return x;
}

module.exports = {
name: ["now-playing", 'np'],
params: [],
info: "Get current song",
category: "music",

async execute(message, arguments2, fsh) {
let queue = useQueue(message.guild.id);
if (fsh.music.checkQueue(message, queue)) return;
const { timestamp, track } = useTimeline(message.guild.id);

let embed = new Discord.EmbedBuilder()
.setTitle(`${fsh.emojis.music} Now Playing: ${track.raw.source} - ${track.cleanTitle}`)
.setDescription(`Views: ${prettyNumber(track.views)}
${queue.node.createProgressBar({
leftChar: fsh.emojis.tl,
indicator: fsh.emojis.ti,
rightChar: fsh.emojis.tr
})} ${timestamp.progress}%`)
.setFooter({ text: `V${fsh.version}` })
.setTimestamp(new Date())
.setColor("#888888")
.setURL(track.url)
.setImage(track.thumbnail)
.setAuthor({
name: track.author.replace(' - Topic','')
});

message.channel.send({
embeds: [embed]
})
}
}
18 changes: 10 additions & 8 deletions newFsh/commands/music/pause.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
const Discord = require("discord.js");
const { useQueue } = require("discord-player");

module.exports = {
name: ["pause", "unpause", "resume"],
name: ["pause", "resume"],
params: [],
info: "Pauses or unpauses the current song",
info: "Pause or resume the current queue",
category: "music",

async execute(message, arguments2, fsh) {
if (!message.member.voice?.channel) return message.channel.send('connect to a Voice Channel');
if (fsh.music.paused.get(message.guild.id)) {
fsh.music.unpause(message.guild.id)
} else {
fsh.music.pause(message.guild.id)
}
if (fsh.music.checkVoice(message)) return;
let queue = useQueue(message.guild.id);
if (fsh.music.checkQueue(message, queue)) return;
if (fsh.music.checkSameVoice(message, queue)) return;
let state = (!queue.node.isPaused());
queue.node.setPaused(state);
message.reply((state ? 'paused' : 'resumed')+' queue')
}
}
17 changes: 14 additions & 3 deletions newFsh/commands/music/play.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
const Discord = require("discord.js");
const { useMainPlayer, useQueue } = require("discord-player");

module.exports = {
name: "play",
params: [],
params: ['song', true],
info: "Play a song in a vc",
category: "music",

async execute(message, arguments2, fsh) {
if (!message.member.voice?.channel) return message.channel.send('connect to a Voice Channel');
if (fsh.music.checkVoice(message)) return;
let queue = useQueue(message.guild.id);
if (fsh.music.checkSameVoice(message, queue)) return;
let player = useMainPlayer();
if (!arguments2.length) return message.channel.send('send a song to play')
fsh.music.play(message, message.member.voice.channel, message.content.split(' ').slice(1,message.content.split(' ').length).join(' '))
player.play(message.member.voice.channel, message.content.split(' ').slice(1,message.content.split(' ').length).join(' '), {
nodeOptions: {
metadata: {
text: message.channel,
voice: message.member.voice.channel
}
}
})
}
}
9 changes: 7 additions & 2 deletions newFsh/commands/music/queue.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
const Discord = require("discord.js");
const { useQueue } = require("discord-player");

module.exports = {
name: "queue",
params: [],
info: "Current music queue",
info: "Get the Current music queue",
category: "music",

async execute(message, arguments2, fsh) {
if (!message.member.voice?.channel) return message.channel.send('connect to a Voice Channel');
message.channel.send(fsh.music.userQueue.get(message.guild.id).length ? '**queue:**\n1. '+fsh.music.userQueue.get(message.guild.id).join('\n1. ') : 'Nothing in queue')
let queue = useQueue(message.guild.id);
if (!queue) {
message.reply('no queue in this server');
}
message.channel.send(queue.tracks.data.length ? '**queue:**\n'+queue.tracks.data.map(t=>`1. ${t.title} by ${t.author}`).join('\n') : 'nothing in queue')
}
}
8 changes: 6 additions & 2 deletions newFsh/commands/music/skip.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Discord = require("discord.js");
const { useQueue } = require("discord-player");

module.exports = {
name: "skip",
Expand All @@ -7,7 +8,10 @@ module.exports = {
category: "music",

async execute(message, arguments2, fsh) {
if (!message.member.voice?.channel) return message.channel.send('connect to a Voice Channel');
fsh.music.skip(message.guild.id)
if (fsh.music.checkVoice(message)) return;
let queue = useQueue(message.guild.id);
if (fsh.music.checkQueue(message, queue)) return;
if (fsh.music.checkSameVoice(message, queue)) return;
queue.node.skip();
}
}
31 changes: 31 additions & 0 deletions newFsh/commands/music/volume.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const Discord = require("discord.js");
const { useQueue, useTimeline } = require("discord-player");

module.exports = {
name: "volume",
params: ['volume', false],
info: "Changes the volume of the song",
category: "music",

async execute(message, arguments2, fsh) {
if (fsh.music.checkVoice(message)) return;
let queue = useQueue(message.guild.id);
if (fsh.music.checkQueue(message, queue)) return;
if (fsh.music.checkSameVoice(message, queue)) return;
let { volume, setVolume } = useTimeline(message.guild.id);
let num = Number(arguments2[0]);
if (!isNaN(num)) {
if (num < 0) {
message.reply('must be a positive integer')
return;
}
if (num > 1000) {
message.reply('a bit too loud keep it under 1000')
return;
}
queue.node.setVolume(num);
} else {
message.channel.send('current volume: '+volume)
}
}
}}
4 changes: 2 additions & 2 deletions newFsh/commands/util/activitys.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,5 @@ module.exports = {
} else {
message.channel.send({ embeds });
}
},
};
}
};
1 change: 0 additions & 1 deletion newFsh/commands/util/audio.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const Discord = require("discord.js");
const ytdl = require('ytdl-core');
const fs = require('fs');

module.exports = {
Expand Down
1 change: 0 additions & 1 deletion newFsh/commands/util/video.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const Discord = require("discord.js");
const ytdl = require('ytdl-core');
const fs = require('fs');

module.exports = {
Expand Down
40 changes: 18 additions & 22 deletions newFsh/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const version = "1.0.0 beta";

/* -- Imports -- */
const Discord = require("discord.js");
const logs = require("discord-logs");

const Database = require("easy-json-database");
const fs = require("fs");
Expand Down Expand Up @@ -45,17 +44,13 @@ let fsh = {
version,
reaquire
};

/* Music */
const MusicLogic = require('./music-logic.js');
fsh.music = new MusicLogic(fsh);

/* USRBG */
let USRBGinstance = new usrbg(2);
(async()=>{
await USRBGinstance.load()
fsh.usrbg = USRBGinstance;
})()
// Dev ids
fsh.devIds = [
"1068572316986003466", // Fsh
"816691475844694047", // Inv
"712342308565024818", // Frost
"1098211925495664751" // Inv alt
];

/* -- Make client -- */
fsh.client = new Discord.Client({
Expand All @@ -74,13 +69,16 @@ fsh.client = new Discord.Client({
],
});

/* -- Dev ids */
fsh.devIds = [
"1068572316986003466", // Fsh
"816691475844694047", // Inv
"712342308565024818", // Frost
"1098211925495664751", // Inv alt
];
/* -- Music -- */
const createMusic = require('./music.js');
createMusic(fsh);

/* -- USRBG -- */
let USRBGinstance = new usrbg(2);
(async()=>{
await USRBGinstance.load()
fsh.usrbg = USRBGinstance;
})()

/* -- Save dbs on fsh -- */
// User data
Expand All @@ -89,11 +87,11 @@ fsh.user_inventory = new Database("./databases/user_inventory.json");
fsh.user_badges = new Database("./databases/user_badges.json");
fsh.bank_fsh = new Database("./databases/bank_fsh.json");
fsh.bank_limit = new Database("./databases/bank_limit.json");
fsh.cooldown = new Database("./databases/cooldown.json");
// Server data
fsh.server_config = new Database("./databases/server_config.json");
// Other
fsh.items = new Database("./databases/items.json");
fsh.cooldown = new Database("./databases/cooldown.json");
fsh.coupon = new Database("./databases/coupon.json");
fsh.emojis = new Database("./databases/emojis.json").data;

Expand All @@ -117,8 +115,6 @@ const getAllJsFiles = function (dirPath, arrayOfFiles) {

function refresh(directory, collection) {
fsh.ws_api = reaquire('./ws-api.js')
fsh.z_music = reaquire('./z-music')
fsh.playSong = reaquire('./z-music/playSong.js')

fsh.client[collection] = new Discord.Collection();
const commandsPath = path.join(__dirname, directory);
Expand Down
Loading

0 comments on commit 821db46

Please sign in to comment.