Compare commits

29 Commits

Author SHA1 Message Date
Lukas Blacha
fadb42bbf6 Removed help-Command 2023-02-07 23:18:57 +01:00
Lukas Blacha
5fddad561d Removed help-Command 2023-02-07 23:16:02 +01:00
Lukas Blacha
651cf70885 Removed help-Command 2023-02-07 23:14:07 +01:00
Lukas Blacha
02609a65e5 Added Shutdown-Command with cleanup 2023-02-07 23:12:03 +01:00
Lukas Blacha
837686c71d Added Shutdown-Command with cleanup 2023-02-07 23:10:05 +01:00
Lukas Blacha
6b8a8a0dfc Added Shutdown-Command with cleanup 2023-02-07 23:05:31 +01:00
Lukas Blacha
9540f37d06 Added Shutdown-Command 2023-02-07 23:02:51 +01:00
Lukas Blacha
f87f878ca4 Added threads flag 2023-02-07 22:58:10 +01:00
Gitea
52cf259c20 Made the bot working again... 2023-02-07 21:55:41 +00:00
Gitea
3893e6ddc0 Removed maxrate flag 2023-02-07 21:48:25 +00:00
Gitea
de2779b61f Removed OPUS decoder 2023-02-07 21:47:20 +00:00
Lukas Blacha
6070780b0a Added threads flag 2023-02-07 22:45:19 +01:00
Lukas Blacha
c2e3081995 Added threads flag 2023-02-07 22:42:04 +01:00
Lukas Blacha
7e0a927c2b Added threads flag 2023-02-07 22:35:48 +01:00
Lukas Blacha
ba14c23ed9 Switched back to ffmepgPCM 2023-02-07 22:32:28 +01:00
Lukas Blacha
e770272bc4 Switched back to ffmepgPCM 2023-02-07 22:31:08 +01:00
Lukas Blacha
f6439245c6 Switched back to ffmepgPCM 2023-02-07 22:27:45 +01:00
Lukas Blacha
3496e0e5a7 Switched to OpusVoice 2023-02-07 22:24:06 +01:00
Lukas Blacha
22e74ff829 Switched to OpusVoice 2023-02-07 22:23:01 +01:00
Lukas Blacha
467f2dd00b Switched to OpusVoice 2023-02-07 22:21:01 +01:00
Lukas Blacha
dec4be3d1b Switched to OpusVoice 2023-02-07 22:14:00 +01:00
Lukas Blacha
7a09c752e9 Switched to OpusVoice 2023-02-07 22:09:38 +01:00
Lukas Blacha
93ec9ca2ec Switched to OpusVoice 2023-02-07 22:08:20 +01:00
Lukas Blacha
9f61462777 Switched to OpusVoice 2023-02-07 22:07:41 +01:00
Lukas Blacha
1d5e32eec0 Switched to OpusVoice 2023-02-07 22:04:51 +01:00
Lukas Blacha
b286d8338e Switched to OpusVoice 2023-02-07 22:01:19 +01:00
Lukas Blacha
9735a408c9 Added bot=True, reconnect=True 2023-02-07 21:37:27 +01:00
Lukas
e9bcaa210c Deleted compiled version 2023-02-07 15:42:23 +00:00
Lukas Blacha
ede2a02bb7 Fixes 2023-02-07 16:38:48 +01:00
3 changed files with 31 additions and 17 deletions

View File

@@ -4,6 +4,7 @@ import yt_dlp
import discord import discord
import logging import logging
import argparse import argparse
import os
from discord.ext import commands from discord.ext import commands
from discord import Embed from discord import Embed
@@ -17,6 +18,7 @@ version = "0.1"
success = "**Success ✅**\n" success = "**Success ✅**\n"
warning = "**Warning **\n" warning = "**Warning **\n"
error = "**Error ❗️**\n" error = "**Error ❗️**\n"
cache_dir = "cache"
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("-t", "--token", help="Bot TOKEN") parser.add_argument("-t", "--token", help="Bot TOKEN")
@@ -33,7 +35,7 @@ else:
ytdl_format_options = { ytdl_format_options = {
"format": "bestaudio/mp3", "format": "bestaudio/mp3",
"outtmpl": "cache/%(extractor)s-%(id)s-%(title)s.mp3", "outtmpl": f"{cache_dir}/%(extractor)s-%(id)s-%(title)s.mp3",
"restrictfilenames": True, "restrictfilenames": True,
"noplaylist": True, "noplaylist": True,
"nocheckcertificate": True, "nocheckcertificate": True,
@@ -76,7 +78,8 @@ else:
data = data["entries"][0] data = data["entries"][0]
filename = data["url"] if stream else ytdl.prepare_filename(data) filename = data["url"] if stream else ytdl.prepare_filename(data)
return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data) return cls(discord.FFmpegPCMAudio(source=filename, executable="ffmpeg", pipe=False, stderr=False,
before_options="-threads 2", options=ffmpeg_options), data=data)
intents = discord.Intents.default() intents = discord.Intents.default()
@@ -85,7 +88,7 @@ else:
bot = commands.Bot( bot = commands.Bot(
command_prefix=commands.when_mentioned_or("!"), command_prefix=commands.when_mentioned_or("!"),
description="Relatively simple music bot example", description="Relatively simple music bot example",
intents=intents, intents=intents, help_command=None
) )
@@ -99,12 +102,21 @@ else:
print("------") print("------")
@bot.command(name="shutdown")
@commands.is_owner()
async def _shutdown(ctx):
files = os.listdir(cache_dir)
async with ctx.channel.typing():
for file in files:
os.remove(f"{cache_dir}/{file}")
await ctx.send(f"{warning}Cleaned up {len(files)} Files...\n\n{success}Shutting down...")
await bot.close()
@bot.slash_command(name="join", description="Summon the bot into your channel") @bot.slash_command(name="join", description="Summon the bot into your channel")
async def join(ctx: commands.Context): async def join(ctx: commands.Context):
try: try:
channel = ctx.author.voice.channel channel = ctx.author.voice.channel
except Exception as err:
print(err)
if channel is None: if channel is None:
await ctx.send(f"{error}You are not in a voice-channel! Could not join...") await ctx.send(f"{error}You are not in a voice-channel! Could not join...")
if ctx.voice_client is not None: if ctx.voice_client is not None:
@@ -112,6 +124,8 @@ else:
await ctx.respond(f"{success}Connected to `{channel.name}`") await ctx.respond(f"{success}Connected to `{channel.name}`")
await channel.connect() await channel.connect()
except Exception as err:
print(err)
@bot.slash_command(name="nowplaying", descriprion="Show details what the bot is currently playing") @bot.slash_command(name="nowplaying", descriprion="Show details what the bot is currently playing")
@@ -200,15 +214,16 @@ else:
async def on_application_command_error(ctx, error): async def on_application_command_error(ctx, error):
print(f"[on_application_command_error]\n{ctx.author}\n{error}") print(f"[on_application_command_error]\n{ctx.author}\n{error}")
if isinstance(error, discord.ext.commands.CommandError): if isinstance(error, discord.ext.commands.CommandError):
cool_down_time = int(error.cooldown.get_retry_after()) embed = Embed(title=f"{warning}{error}",
td = timedelta(seconds=cool_down_time)
embed = Embed(title=f"{warning}Dieser Command befindet sich im Cool Down!\n Versuche es in `{td}` nochmal!",
color=15158332) color=15158332)
elif isinstance(error, discord.ext.commands.CommandOnCooldown): elif isinstance(error, discord.ext.commands.CommandOnCooldown):
cool_down_time = int(error.cooldown.get_retry_after()) cool_down_time = int(error.cooldown.get_retry_after())
td = timedelta(seconds=cool_down_time) td = timedelta(seconds=cool_down_time)
embed = Embed(title=f"{warning}Dieser Command befindet sich im Cool Down!\n Versuche es in `{td}` nochmal!", embed = Embed(title=f"{warning}Dieser Command befindet sich im Cool Down!\n Versuche es in `{td}` nochmal!",
color=15158332) color=15158332)
elif isinstance(error, discord.ext.commands.is_owner()):
embed = Embed(title=f"{warning}{error}",
color=15158332)
else: else:
embed = Embed(title=f"{error}", color=15158332) embed = Embed(title=f"{error}", color=15158332)
await ctx.respond(embed=embed) await ctx.respond(embed=embed)
@@ -220,5 +235,4 @@ else:
embed = Embed(title=f"{error}", color=15158332) embed = Embed(title=f"{error}", color=15158332)
await ctx.send(embed=embed) await ctx.send(embed=embed)
bot.run(token=args.token, reconnect=True)
bot.run(args.token)

Binary file not shown.

View File

@@ -10,7 +10,7 @@ Simple Music-Bot for Discord written in Python with <3
## How to start ## How to start
1. Clone the repository 1. Clone the repository
2. cd into it 2. cd into it
3. Run the **compiled** version: python3 Music-Bot.pyc -t TOKEN 3. Run : python3 Music-Bot.pyc -t TOKEN
4. Click on the invitation-Link in the terminal 4. Click on the invitation-Link in the terminal
5. DONE <3 5. DONE <3