GoldyBot.objects.slash

 1import asyncio
 2from typing import Any
 3
 4import nextcord
 5from nextcord import InteractionResponse
 6
 7Interaction = nextcord.Interaction
 8MISSING: Any = nextcord.utils.MISSING
 9
10loop = asyncio.get_event_loop()
11
12class InteractionToCtx():
13    """This Goldy Bot class is used to convert interactions to ctx."""
14    def __init__(self, interaction: Interaction):
15        self.interaction = interaction
16
17    @property
18    def guild(self) -> Interaction.guild:
19        return self.interaction.guild
20
21    @property
22    def author(self):
23        return self.interaction.user
24
25    @property
26    def channel(self):
27        return self.interaction.channel
28
29    @property
30    def response(self) -> InteractionResponse:
31        return self.interaction.response
32
33    async def send(self, text:str=None, **kwargs):
34        if not text == None:
35            await self.interaction.send(text)
36        else:
37            await self.interaction.send(**kwargs)
38        
39        return Message(self.interaction)
40
41    async def send_modal(self, modal:nextcord.ui.Modal):
42        """Sends modal."""
43        await self.interaction.response.send_modal(modal)
44
45        return Message(self.interaction)
46
47class Message():
48    def __init__(self, interaction: Interaction):
49        self.interaction = interaction
50
51    async def delete(self, delay=None):
52        await self.interaction.delete_original_message(delay=delay)
53
54    async def edit(self, **args):
55        #TODO: #29 Don't forget to add text to this.
56        await self.interaction.edit_original_message(**args)
MISSING: Any = ...
class InteractionToCtx:
13class InteractionToCtx():
14    """This Goldy Bot class is used to convert interactions to ctx."""
15    def __init__(self, interaction: Interaction):
16        self.interaction = interaction
17
18    @property
19    def guild(self) -> Interaction.guild:
20        return self.interaction.guild
21
22    @property
23    def author(self):
24        return self.interaction.user
25
26    @property
27    def channel(self):
28        return self.interaction.channel
29
30    @property
31    def response(self) -> InteractionResponse:
32        return self.interaction.response
33
34    async def send(self, text:str=None, **kwargs):
35        if not text == None:
36            await self.interaction.send(text)
37        else:
38            await self.interaction.send(**kwargs)
39        
40        return Message(self.interaction)
41
42    async def send_modal(self, modal:nextcord.ui.Modal):
43        """Sends modal."""
44        await self.interaction.response.send_modal(modal)
45
46        return Message(self.interaction)

This Goldy Bot class is used to convert interactions to ctx.

InteractionToCtx(interaction: nextcord.interactions.Interaction)
15    def __init__(self, interaction: Interaction):
16        self.interaction = interaction
guild: <property object at 0x000001B473CA9EE0>
author
channel
response: nextcord.interactions.InteractionResponse
async def send(self, text: str = None, **kwargs):
34    async def send(self, text:str=None, **kwargs):
35        if not text == None:
36            await self.interaction.send(text)
37        else:
38            await self.interaction.send(**kwargs)
39        
40        return Message(self.interaction)
async def send_modal(self, modal: nextcord.ui.modal.Modal):
42    async def send_modal(self, modal:nextcord.ui.Modal):
43        """Sends modal."""
44        await self.interaction.response.send_modal(modal)
45
46        return Message(self.interaction)

Sends modal.

class Message:
48class Message():
49    def __init__(self, interaction: Interaction):
50        self.interaction = interaction
51
52    async def delete(self, delay=None):
53        await self.interaction.delete_original_message(delay=delay)
54
55    async def edit(self, **args):
56        #TODO: #29 Don't forget to add text to this.
57        await self.interaction.edit_original_message(**args)
Message(interaction: nextcord.interactions.Interaction)
49    def __init__(self, interaction: Interaction):
50        self.interaction = interaction
async def delete(self, delay=None):
52    async def delete(self, delay=None):
53        await self.interaction.delete_original_message(delay=delay)
async def edit(self, **args):
55    async def edit(self, **args):
56        #TODO: #29 Don't forget to add text to this.
57        await self.interaction.edit_original_message(**args)