Skip to content

Commit

Permalink
Merge pull request #12 from Simyon264/dev
Browse files Browse the repository at this point in the history
Version 3.8.9
  • Loading branch information
Simyon264 authored May 3, 2022
2 parents 13399f5 + 828111f commit 50facb4
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 22 deletions.
2 changes: 1 addition & 1 deletion commands/msearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = {
menu.addOptions([
{
label: `Song ${index + 1}`,
description: `Channel: ${searchResults.items[index].author.name}`,
description: `Channel: ${searchResults.items[index].author.name || "Keine Information"}`,
value: `${searchResults.items[index].id}`,
}
])
Expand Down
39 changes: 39 additions & 0 deletions commands/shuffle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const f = require('../functions.js');
const discord = require('discord.js');
const fs = require("fs")

module.exports = {
name: 'shuffle',
description: f.localization("commands","shuffle","exports").description,
category: 'music',
modcommand: false,
usage: f.localization("commands","shuffle","exports").usage,
perms: '',
alias: [],
cooldown: 1,
run: function (message, prefix, args, client) {
const serverQueue = queue.get(message.channel.guild.id);
const channel = message.member.voice.channel

if (!serverQueue) return message.reply("Ich bin nicht Verbunden.")
if (!serverQueue.playing) return message.reply("Ich spiele aktuell nichst.")

if (message.member.voice.channel.id != queue.get(message.channel.guild.id).voiceChannel.id) return message.reply("Du musst mit dem Bot in einem Sprachkanal sein.");

function shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
}


let curSong = serverQueue.songs.splice(0, 1)[0]
let newArray = serverQueue.songs
shuffleArray(newArray)
newArray.splice(0, 0, curSong)
serverQueue.songs = newArray;
queue.set(message.guild.id, serverQueue)
message.reply("Die Songliste wurde gemischt.");
}
}
4 changes: 2 additions & 2 deletions commands/song.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const f = require('../functions.js');
const discord = require('discord.js');
const fs = require("fs")

const fetch = require('node-fetch')
module.exports = {
name: 'song',
description: f.localization("commands","song","exports").description,
Expand Down Expand Up @@ -51,7 +51,7 @@ module.exports = {
.setDescription(`Zeit verbleibend: **${formatMilliseconds(timeLeft)}**`)
.addField('Kanal', `[${songInfo.raw.videoDetails.author.name}](${songInfo.raw.videoDetails.author.channel_url})`, true)
.addField('Likes und dislikes', `${data.likes} :thumbsup: ${data.dislikes} :thumbsdown: `, true)
.setFooter(`Requested by: ${songInfo.by.username}`, songInfo.by.avatarURL(true))
.setFooter(`Hinzugefügt von: ${songInfo.by.username}`, songInfo.by.avatarURL(true))
.setThumbnail(songInfo.raw.videoDetails.thumbnails[songInfo.raw.videoDetails.thumbnails.length - 1].url)
message.reply({content: "** **", embeds:[embed]})
});
Expand Down
5 changes: 4 additions & 1 deletion commands/stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ module.exports = {
const channel = message.member.voice.channel

if (!serverQueue) return message.reply("Ich bin nicht Verbunden.")
if (channel.id != queue.get(message.channel.guild.id).voiceChannel.id) return message.reply("Du musst mit dem Bot in einem Sprachkanal sein.");

const stopped = f.stop(message.guild)
if (stopped) {
message.reply(`Verbindung gestoppt.`)
} else {
message.reply("Fehler beim Stoppen.")
queue = new Map()
message.reply("Fehler beim Stoppen. (Kann aber trotzdem Funktioniert haben)")
}
}
}
31 changes: 31 additions & 0 deletions commands/volume.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const f = require('../functions.js');
const discord = require('discord.js');
const fs = require("fs")

module.exports = {
name: 'volume',
description: f.localization("commands","volume","exports").description,
category: 'music',
modcommand: false,
usage: f.localization("commands","volume","exports").usage,
perms: '',
alias: ["v"],
cooldown: 1,
run: function (message, prefix, args, client) {
const serverQueue = queue.get(message.channel.guild.id);
const channel = message.member.voice.channel

if (!serverQueue) return message.reply("Ich bin nicht Verbunden.")
if (channel.id != queue.get(message.channel.guild.id).voiceChannel.id) return message.reply("Du musst mit dem Bot in einem Sprachkanal sein.");
if (args.length <= 1) return message.reply("Bitte gebe eine neue Lautstärke an.")

let newVolume = parseInt(args[1])
if (newVolume == NaN || newVolume == undefined || newVolume == 0) newVolume = 50;
if (newVolume > 200 || newVolume < 1) newVolume = 50

serverQueue.source.volume?.setVolume(newVolume / 100)
serverQueue.volume = newVolume
queue.set(message.guild.id, serverQueue)
message.reply(`Lautstärke auf ${newVolume} gesetzt.`)
}
}
2 changes: 1 addition & 1 deletion eventhandler/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ module.exports = {
const AuditLogFetch = await guildMember.guild.fetchAuditLogs({ limit: 1, type: "MEMBER_KICK"})

let kicked = false;
console.log(AuditLogFetch.entries.first())

if (AuditLogFetch.entries.first()) {
const Entry = AuditLogFetch.entries.first()
const timestamp = new Date().getTime()
Expand Down
5 changes: 2 additions & 3 deletions files/important files/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
Version 3.7.9
- Nickname log gefixt
- Musik bot funktion hinzugefügt.
Version 3.8.9
- Shuffle hinzugefügt
2 changes: 1 addition & 1 deletion files/important files/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.7.9
3.8.9
68 changes: 56 additions & 12 deletions functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,57 @@ exports.handleConnection = function(guild) {
*/
exports.addSong = async function(guild, query, message) {
let serverQueue = queue.get(guild.id)
const botMsg = message.reply("Suche... :mag:")
const botMsg = await message.reply("Suche... :mag:")
let song = {}
try {
const songInfo = await ytdl.getInfo(query)
song = {
title: songInfo.videoDetails.title,
url: songInfo.videoDetails.video_url,
raw: songInfo,
by: message.author,
};
try {
const playlistID = await ytpl.getPlaylistID(query)
const playlist = await ytpl(playlistID, {
limit: 50,
})
botMsg.edit("Playlist wird hinzugefügt, dies kann etwas länger dauern. :notes:")
for (let index = 0; index < playlist.items.length; index++) {
serverQueue = queue.get(guild.id);
let curSong = await ytdl.getInfo(playlist.items[index].shortUrl)
let curSongInfo = {
title: curSong.videoDetails.title,
url: curSong.videoDetails.video_url,
raw: curSong,
by: message.author
}
serverQueue.songs.push(curSongInfo)
if (index == 0) {
song = curSongInfo
}
await f.sleep(50)
}
queue.set(guild.id, serverQueue)
if (!serverQueue.playing) {
f.play(guild)
serverQueue.playing = true
queue.set(guild.id, serverQueue)
const embed = new discord.MessageEmbed()
.setTitle("Spielt gerade:")
.setURL(song.url)
.setColor(0x00AE86)
.setDescription(`**${song.title}**`)
.addField('Länge', `\`${formatMilliseconds(song.raw.videoDetails.lengthSeconds * 1000)}\``, true)
.addField('Kanal', `[${song.raw.videoDetails.author.name}](${song.raw.videoDetails.author.channel_url})`, true)
.setFooter(`Hinzugefügt von: ${song.by.username}`, song.by.avatarURL(true))
.setThumbnail(song.raw.videoDetails.thumbnails[song.raw.videoDetails.thumbnails.length - 1].url)
message.channel.send({embeds: [embed]})
}
botMsg.edit(`${playlist.items.length} Lieder hinzugefügt.`)
return
} catch (error) {
const songInfo = await ytdl.getInfo(query)
song = {
title: songInfo.videoDetails.title,
url: songInfo.videoDetails.video_url,
raw: songInfo,
by: message.author,
};
}
} catch (error) {
try {
const filters1 = await ytsr.getFilters(query)
Expand All @@ -130,7 +171,7 @@ exports.addSong = async function(guild, query, message) {
};
} catch (error) {
f.error(error)
botMsg.edit("Lied konnte nicht hinzugefügt werden.")
botMsg.edit("Lied konnte nicht hinzugefügt werden. Möglicherweise wurde nichts gefunden.")
}
}
const embed = new discord.MessageEmbed()
Expand Down Expand Up @@ -182,7 +223,6 @@ exports.play = function(guild) {
})

let source = voice.createAudioResource(stream, {
inputType: voice.StreamType.WebmOpus,
inlineVolume: true,
})
source.volume.setVolume(serverQueue.volume / 100)
Expand All @@ -194,6 +234,7 @@ exports.play = function(guild) {
player.on('stateChange', (oldState, newState) => {
if (newState.status == 'idle') {
serverQueue = queue.get(guild.id);
if (!serverQueue.source) return;
if (!serverQueue.source.ended) return f.log("Idle, stream still playing");
if (serverQueue.songs.length != 1 || serverQueue.loop != "none") {
if (serverQueue.loop == "queue") {
Expand All @@ -208,10 +249,10 @@ exports.play = function(guild) {
highWaterMark: 1 << 25,
})
let source = voice.createAudioResource(stream, {
inputType: voice.StreamType.WebmOpus,
inlineVolume: true
})
source.volume.setVolume(serverQueue.volume / 100)
source.volume?.setVolume(serverQueue.volume / 100)
serverQueue.source = source;
songInfo = serverQueue.songs[0]
serverQueue.player.play(source)
// Generating the embed
Expand Down Expand Up @@ -251,6 +292,9 @@ exports.stop = function(guild) {
if (!guild) return false;
const serverQueue = queue.get(guild.id)
if (!serverQueue) return false;
if (serverQueue.player) {
serverQueue.player.stop()
}
voice.getVoiceConnection(guild.id).destroy()
queue.delete(guild.id)
return true;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dlgmwarn",
"version": "3.7.9",
"version": "3.8.9",
"description": "",
"main": "bot.js",
"scripts": {
Expand Down

0 comments on commit 50facb4

Please sign in to comment.