mirror of
https://github.com/MrUnknownDE/redbot-assets.git
synced 2026-04-06 00:31:57 +02:00
fix slash command
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import discord
|
import discord
|
||||||
from redbot.core import commands
|
from redbot.core import app_commands, commands
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
@@ -10,8 +10,8 @@ class Bierbaron(commands.Cog):
|
|||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.api_url = "https://live.der-bierbaron.de/api/vrchat.json"
|
self.api_url = "https://live.der-bierbaron.de/api/vrchat.json"
|
||||||
|
|
||||||
@commands.hybrid_command(name="bierbaron")
|
@app_commands.command(name="bierbaron")
|
||||||
async def info(self, ctx: commands.Context):
|
async def info(self, interaction: discord.Interaction):
|
||||||
"""Informationen über den Bierbaron."""
|
"""Informationen über den Bierbaron."""
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title="der-Bierbaron",
|
title="der-Bierbaron",
|
||||||
@@ -23,21 +23,21 @@ class Bierbaron(commands.Cog):
|
|||||||
embed.add_field(name="📡 Live Stats", value="[live.der-bierbaron.de](https://live.der-bierbaron.de)", inline=True)
|
embed.add_field(name="📡 Live Stats", value="[live.der-bierbaron.de](https://live.der-bierbaron.de)", inline=True)
|
||||||
embed.set_footer(text="Bierbaron VRChat Projekt")
|
embed.set_footer(text="Bierbaron VRChat Projekt")
|
||||||
|
|
||||||
await ctx.send(embed=embed)
|
await interaction.response.send_message(embed=embed)
|
||||||
|
|
||||||
@commands.hybrid_command(name="bierbaron-live")
|
@app_commands.command(name="bierbaron-live")
|
||||||
async def live(self, ctx: commands.Context):
|
async def live(self, interaction: discord.Interaction):
|
||||||
"""Live-Informationen vom Server."""
|
"""Live-Informationen vom Server."""
|
||||||
await ctx.typing()
|
await interaction.response.defer()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
async with session.get(self.api_url) as response:
|
async with session.get(self.api_url) as response:
|
||||||
if response.status != 200:
|
if response.status != 200:
|
||||||
return await ctx.send(f"Fehler! API gab Status-Code {response.status} zurück.")
|
return await interaction.followup.send(f"Fehler! API gab Status-Code {response.status} zurück.")
|
||||||
data = await response.json()
|
data = await response.json()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return await ctx.send(f"Fehler beim Abrufen der API: {e}")
|
return await interaction.followup.send(f"Fehler beim Abrufen der API: {e}")
|
||||||
|
|
||||||
# Parse Data
|
# Parse Data
|
||||||
server_info = data.get("server", {})
|
server_info = data.get("server", {})
|
||||||
@@ -80,4 +80,4 @@ class Bierbaron(commands.Cog):
|
|||||||
message = last_prost.get("message", "Prost!")
|
message = last_prost.get("message", "Prost!")
|
||||||
embed.add_field(name="Letztes Prost 🍻", value=f"**{sender}** an **{recipient}**:\n*\"{message}\"*", inline=False)
|
embed.add_field(name="Letztes Prost 🍻", value=f"**{sender}** an **{recipient}**:\n*\"{message}\"*", inline=False)
|
||||||
|
|
||||||
await ctx.send(embed=embed)
|
await interaction.followup.send(embed=embed)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
from redbot.core import app_commands, commands
|
||||||
import discord
|
import discord
|
||||||
from redbot.core import commands
|
|
||||||
|
|
||||||
class MrUnknownDE(commands.Cog):
|
class MrUnknownDE(commands.Cog):
|
||||||
"""Mein persönliches Info-Cog."""
|
"""Mein persönliches Info-Cog."""
|
||||||
@@ -7,8 +7,8 @@ class MrUnknownDE(commands.Cog):
|
|||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
@commands.hybrid_command()
|
@app_commands.command(name="mrunknown")
|
||||||
async def mrunknown(self, ctx: commands.Context):
|
async def mrunknown(self, interaction: discord.Interaction):
|
||||||
"""Zeigt Informationen über MrUnknownDE."""
|
"""Zeigt Informationen über MrUnknownDE."""
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title="MrUnknownDE",
|
title="MrUnknownDE",
|
||||||
@@ -19,4 +19,4 @@ class MrUnknownDE(commands.Cog):
|
|||||||
embed.set_thumbnail(url="https://mrunk.de/pic/profil_pic.webp") # Optionales Thumbnail, falls vorhanden
|
embed.set_thumbnail(url="https://mrunk.de/pic/profil_pic.webp") # Optionales Thumbnail, falls vorhanden
|
||||||
embed.add_field(name="🌐 Webseite", value="[https://mrunk.de](https://mrunk.de)", inline=False)
|
embed.add_field(name="🌐 Webseite", value="[https://mrunk.de](https://mrunk.de)", inline=False)
|
||||||
|
|
||||||
await ctx.send(embed=embed)
|
await interaction.response.send_message(embed=embed)
|
||||||
|
|||||||
Reference in New Issue
Block a user