commit 7b11736164f9620570d73bf5fc7b7ed53bc85c6f Author: = <=> Date: Sun Apr 6 10:54:53 2025 +0700 Initial diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/SquogBot.iml b/.idea/SquogBot.iml new file mode 100644 index 0000000..0974f4d --- /dev/null +++ b/.idea/SquogBot.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..46eb974 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..cf12e40 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/LittleJayneyCakes_「Cover」Again ( Crusher-P )【Jayn】.mp3 b/LittleJayneyCakes_「Cover」Again ( Crusher-P )【Jayn】.mp3 new file mode 100644 index 0000000..c4a1131 Binary files /dev/null and b/LittleJayneyCakes_「Cover」Again ( Crusher-P )【Jayn】.mp3 differ diff --git a/MRK_Dadbattle [MRK mix].mp3 b/MRK_Dadbattle [MRK mix].mp3 new file mode 100644 index 0000000..a34fa6b Binary files /dev/null and b/MRK_Dadbattle [MRK mix].mp3 differ diff --git a/MrLololoshka (Роман Фильченков)_Lp. Точка Невозврата #43 ПАРАДОКС ВРЕМЕНИ [Поломка] • Майнкрафт.mp3 b/MrLololoshka (Роман Фильченков)_Lp. Точка Невозврата #43 ПАРАДОКС ВРЕМЕНИ [Поломка] • Майнкрафт.mp3 new file mode 100644 index 0000000..81da060 Binary files /dev/null and b/MrLololoshka (Роман Фильченков)_Lp. Точка Невозврата #43 ПАРАДОКС ВРЕМЕНИ [Поломка] • Майнкрафт.mp3 differ diff --git a/RandoHorn_Chase V2 [Encounter Vita Carnis Mix].mp3 b/RandoHorn_Chase V2 [Encounter Vita Carnis Mix].mp3 new file mode 100644 index 0000000..9463bca Binary files /dev/null and b/RandoHorn_Chase V2 [Encounter Vita Carnis Mix].mp3 differ diff --git a/The Living Tombstone_The Living Tombstone - Long Time Friends.mp3 b/The Living Tombstone_The Living Tombstone - Long Time Friends.mp3 new file mode 100644 index 0000000..e0d5c91 Binary files /dev/null and b/The Living Tombstone_The Living Tombstone - Long Time Friends.mp3 differ diff --git a/disnake.log b/disnake.log new file mode 100644 index 0000000..e69de29 diff --git a/main.py b/main.py new file mode 100644 index 0000000..02cdcac --- /dev/null +++ b/main.py @@ -0,0 +1,164 @@ +import os +import logging +import nextcord +import yt_dlp +import subprocess +from nextcord.ext import commands +import logging +import multiprocessing + +logger = logging.getLogger('disnake') +logger.setLevel(logging.DEBUG) +handler = logging.FileHandler(filename='disnake.log', encoding='utf-8', mode='w') +handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')) +logger.addHandler(handler) + + +SquogServer = 1356433463854497944 +SquogToken = "MTM1NjU2MTY2MjQyOTM2ODQxMQ.G8aypc.CZBX-x6e4Oad3U5zO0nUgc02d9FDIDSNFybysI" + +SquogHelp = commands.HelpCommand() #command_attrs={"name", "help", "usage", "description"} + +client = commands.Bot(command_prefix="!", intents=nextcord.Intents.all(), help_command = SquogHelp) + +SquogMod = None + +SquogFinalName: str = None +def SquogFilename(d): + global SquogFinalName + SquogFinalName = d.get('info_dict').get('_filename') + +SquogVideo = { + "verbose":True, + "progress_hooks": [SquogFilename], + 'final_ext': 'mp3', + 'postprocessors': [{ + 'key': 'FFmpegExtractAudio', + 'preferredcodec': 'mp3', + }], + "outtmpl": './%(uploader)s_%(title)s.%(ext)s', + "quality": "low" +} + +SquogCurrentConnection: nextcord.VoiceClient = None + +SquogDownload = yt_dlp.YoutubeDL(SquogVideo) + +# _____ _ +# / ____| | | +# | | ___ _ __ ___ _ __ ___ __ _ _ __ __| |___ +# | | / _ \| '_ ` _ \| '_ ` _ \ / _` | '_ \ / _` / __| +# | |___| (_) | | | | | | | | | | | (_| | | | | (_| \__ \ +# \_____\___/|_| |_| |_|_| |_| |_|\__,_|_| |_|\__,_|___/ + +@client.command(description="Check how fast the bot will reply to you.", help="evil") +async def ping(ctx: nextcord.Message): + await ctx.reply("Pong!") + +@client.command(description="Join the voice channel.") +async def join(ctx: nextcord.Message): + print("Joining") + print(client.voice_clients) + if client.voice_clients.__len__() == 0: + if ctx.author.voice: + global SquogCurrentConnection + SquogCurrentConnection = await ctx.author.voice.channel.connect() + await ctx.reply("Joined.") + else: + await ctx.reply("Can't join as you aren't in any voice channel.") + else: + await ctx.reply("Can't join as i'm already in a voice channel.") + +@client.command(description="Leaves the voice channel.") +async def leave(ctx: nextcord.Message): + print("Leaving") + if client.voice_clients.__len__() != 0: + await client.voice_clients[0].disconnect(force=True) + await ctx.reply("Left.") + else: + await ctx.reply("Can't leave as i'm not in any voice channel.") + +@client.command(description="Plays music in the voice channel.", usage={"link"}) +async def play(ctx: nextcord.Message, link): + global SquogEvilFilename + global SquogFinalName + SquogEvilFilename = None + if client.voice_clients.__len__() == 0: + return await ctx.reply("I'm not in a voice channel.") + if client.voice_clients[0].is_playing(): + return await ctx.reply("I'm already playing music.") + print(ctx.guild.voice_client.is_connected()) + print(SquogCurrentConnection) + SquogVoiceClient = ctx.guild.voice_client + print(link) + SquogDownload.download(link) + SquogInfo = SquogDownload.extract_info(link, download=False) + SquogFinalName = SquogDownload.prepare_filename(SquogInfo) + SquogLength = SquogFinalName.__len__() - 4 + SquogExt = os.path.splitext(SquogFinalName) + print(SquogExt) + SquogLength = SquogFinalName.find(SquogExt[1]) + 1 + print(SquogLength) + SquogEvilFilename = f"{SquogFinalName[:SquogLength]}mp3" + SquogVoiceClient.play(nextcord.FFmpegPCMAudio(f"{SquogEvilFilename}")) + +@client.command(description="Stops the music in voice channel") +async def stop(ctx: nextcord.Message): + if client.voice_clients.__len__() == 0: + return await ctx.reply("I'm not in a voice channel.") + if not SquogCurrentConnection.is_playing(): + return await ctx.reply("I'm not playing music.") + SquogCurrentConnection.stop() + +# ______ _ +# | ____| | | +# | |____ _____ _ __ | |_ ___ +# | __\ \ / / _ | '_ \| __/ __| +# | |___\ V | __| | | | |_\__ \ +# |______\_/ \___|_| |_|\__|___/ + +@client.event +async def on_member_join(member: nextcord.Member): + print(f"Member {member.display_name} joined") + await member.add_roles(nextcord.utils.get(member.guild.roles, name="Squog")) + +@client.event +async def on_member_remove(member: nextcord.Member): + print(f"Member {member.display_name} left") + +@client.event +async def on_message_delete(msg: nextcord.Message): + embed = nextcord.Embed( + title = "Message delete", + description = msg.content + ) + embed.set_author(name = msg.author.name) + for image in msg.attachments: + embed.set_image(image.url) # Unfortunately i cant add multiple images. + await SquogMod.send(embed=embed) + +@client.event +async def on_command(ctx: commands.Context): + embed = nextcord.Embed( + title="Command used", + description=ctx.message.content + ) + field = embed.add_field(name="Channel", value = ctx.channel.name) + await SquogMod.send(embed=embed) + +@client.event +async def on_ready(): + global SquogMod + print("Bot logged") + SquogMod = client.get_channel(1356577069068324986) + print(SquogMod) + +# ______ _ _ +# | ____| | | (_) +# | |__ __ _____ ___ _ _| |_ _ _ __ __ _ +# | __| \ \/ / _ \/ __| | | | __| | '_ \ / _` | +# | |____ > | __| (__| |_| | |_| | | | | (_| | +# |______/_/\_\___|\___|\__,_|\__|_|_| |_|\__, | +# __/ | +# |___/ +client.run(SquogToken)