initial commit
This commit is contained in:
2
.env.example
Normal file
2
.env.example
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
PREFIX=prefixLike!
|
||||||
|
DISCORD_TOKEN=discordToken
|
||||||
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
dist
|
||||||
|
db
|
||||||
101
bot.py
Normal file
101
bot.py
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
import nextcord
|
||||||
|
from nextcord.ext import commands
|
||||||
|
import aiohttp
|
||||||
|
import os
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
# Set up intents
|
||||||
|
intents = nextcord.Intents.default()
|
||||||
|
intents.message_content = True # Required to read message content
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
# Create bot instance
|
||||||
|
bot = commands.Bot(command_prefix=os.getenv("PREFIX"), intents=intents)
|
||||||
|
|
||||||
|
|
||||||
|
@bot.event
|
||||||
|
async def on_ready():
|
||||||
|
print(f"Logged in as {bot.user}!")
|
||||||
|
|
||||||
|
|
||||||
|
# PREFIX COMMAND für 7TV Import
|
||||||
|
@bot.command(name="7tvimport")
|
||||||
|
async def seven_tv_import(ctx, name: str, link: str):
|
||||||
|
"""Importiert ein 7TV Emote direkt vom CDN
|
||||||
|
|
||||||
|
Verwendung: !7tvimport <name> <link>
|
||||||
|
Beispiel: !7tvimport PogChamp 7tv.app/emotes/603cac391cd55c0014d989be
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Lade-Nachricht
|
||||||
|
loading_msg = await ctx.send("⏳ Lade Emote herunter...")
|
||||||
|
|
||||||
|
# Konstruiere die CDN URL
|
||||||
|
if "7tv.app/emotes/" in link or "7tv.io/emotes/" in link:
|
||||||
|
emote_id = link.split("/emotes/")[-1].split("?")[0]
|
||||||
|
cdn_url = f"https://cdn.7tv.app/emote/{emote_id}/4x.webp"
|
||||||
|
elif link.startswith("cdn.7tv.app"):
|
||||||
|
cdn_url = f"https://{link}/4x.webp"
|
||||||
|
else:
|
||||||
|
# Falls nur die ID gegeben wurde
|
||||||
|
cdn_url = f"https://cdn.7tv.app/emote/{link}/4x.webp"
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Bild vom CDN herunterladen
|
||||||
|
async with aiohttp.ClientSession() as session:
|
||||||
|
async with session.get(cdn_url) as resp:
|
||||||
|
if resp.status != 200:
|
||||||
|
await loading_msg.edit(
|
||||||
|
content=f"❌ Fehler: Konnte das Bild nicht herunterladen! (Status: {resp.status})\n"
|
||||||
|
f"URL: {cdn_url}"
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
image_data = await resp.read()
|
||||||
|
|
||||||
|
# Überprüfe Dateigröße (Discord Limit: 256KB)
|
||||||
|
if len(image_data) > 256000:
|
||||||
|
await loading_msg.edit(
|
||||||
|
content=f"❌ Fehler: Das Bild ist zu groß! ({len(image_data) / 1000:.1f}KB > 256KB)\n"
|
||||||
|
f"Versuche es mit einer kleineren Version."
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
# Erstelle das Emoji
|
||||||
|
emoji = await ctx.guild.create_custom_emoji(
|
||||||
|
name=name, image=image_data, reason=f"7TV Import von {ctx.author}"
|
||||||
|
)
|
||||||
|
|
||||||
|
await loading_msg.edit(
|
||||||
|
content=f"✅ Emote {emoji} erfolgreich hinzugefügt!\n"
|
||||||
|
f"Name: `{name}`\n"
|
||||||
|
f"Größe: {len(image_data) / 1000:.1f}KB"
|
||||||
|
)
|
||||||
|
|
||||||
|
except nextcord.Forbidden:
|
||||||
|
await loading_msg.edit(
|
||||||
|
content="❌ Fehler: Ich habe keine Berechtigung, Emojis zu verwalten!"
|
||||||
|
)
|
||||||
|
except nextcord.HTTPException as e:
|
||||||
|
await loading_msg.edit(
|
||||||
|
content=f"❌ Discord-Fehler: {e}\n"
|
||||||
|
f"Mögliche Gründe: Server-Emoji-Limit erreicht, ungültiger Name, oder Netzwerkfehler."
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
await loading_msg.edit(content=f"❌ Unerwarteter Fehler: {e}")
|
||||||
|
|
||||||
|
|
||||||
|
# PREFIX COMMAND für Permissions Check
|
||||||
|
@bot.command(name="checkperms")
|
||||||
|
async def check_perms(ctx):
|
||||||
|
"""Überprüfe Bot-Berechtigungen"""
|
||||||
|
perms = ctx.guild.me.guild_permissions
|
||||||
|
|
||||||
|
if perms.manage_emojis:
|
||||||
|
await ctx.send("✅ Ich habe die Berechtigung, Emojis zu verwalten!")
|
||||||
|
else:
|
||||||
|
await ctx.send("❌ Ich habe keine Berechtigung, Emojis zu verwalten!")
|
||||||
|
|
||||||
|
|
||||||
|
bot.run(os.getenv("DISCORD_TOKEN"))
|
||||||
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
nextcord[speed]
|
||||||
|
python-dotenv
|
||||||
Reference in New Issue
Block a user