misc: imported ui from discord instead of accessing discord.ui

This commit is contained in:
Seaswimmer 2023-07-15 19:16:11 -04:00
parent 98dccd919e
commit 26c0ad8b63
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -2,6 +2,7 @@ import asyncio
import aiohttp
import discord
import requests
from discord import ui
from redbot.core import commands, app_commands, Config
class Pterodactyl(commands.Cog):
@ -108,13 +109,13 @@ class Pterodactyl(commands.Cog):
passed_info = [old_startup_args[0], old_startup_args[1], headers, put_data, new_put_data, interaction_message]
await interaction_message.edit(content="The server is already running! Are you sure you'd like to stop the server for updates?", view=self.UpdateButtons(timeout=180, passed_info=passed_info))
class UpdateButtons(discord.ui.View):
class UpdateButtons(ui.View):
def __init__(self, timeout, passed_info):
super().__init__()
self.passed_info = passed_info
@discord.ui.button(label="Yes", style=discord.ButtonStyle.success)
async def yes_button(self, button:discord.ui.Button, interaction:discord.Interaction):
@ui.button(label="Yes", style=discord.ButtonStyle.success)
async def yes_button(self, button:ui.Button, interaction:discord.Interaction):
requests.post(await Pterodactyl.get_url(interaction.guild, "power"), headers=headers, json={"signal": "stop"})
await interaction.response.edit_message("Server stopping...", view=None)
while True:
@ -158,8 +159,8 @@ class Pterodactyl(commands.Cog):
await asyncio.sleep(1)
continue
@discord.ui.button(label="No", style=discord.ButtonStyle.danger)
async def no_button(self, button:discord.ui.Button, interaction:discord.Interaction):
@ui.button(label="No", style=discord.ButtonStyle.danger)
async def no_button(self, button:ui.Button, interaction:discord.Interaction):
for button in self.children:
button.disabled = True
await interaction.response.edit_message(content=f"Command cancelled.", view=self)