GoldyBot.utility.commands

 1import GoldyBot
 2from . import _mention_, _send_, _icon_, _defer_, _send_modal_
 3
 4mention = _mention_.mention
 5""""""
 6send = _send_.send
 7""""""
 8defer = _defer_.defer
 9""""""
10get_member_pfp = _icon_.get_member_pfp
11""""""
12send_modal = _send_modal_.send_modal
13""""""
14
15# Aliases
16#--------------------------
17think = _defer_.defer
18"""An alias of ``GoldyBot.utility.commands.defer``."""
19
20def what_command_type(ctx):
21    """Tells you whether this command is a slash command or a normal command."""
22    if isinstance(ctx, GoldyBot.objects.slash.InteractionToCtx):
23        return "slash"
24
25    elif isinstance(ctx, GoldyBot.nextcord.Interaction):
26        return "slash"
27        
28    elif isinstance(ctx, GoldyBot.objects.member.Member):
29        if isinstance(ctx.ctx, GoldyBot.objects.slash.InteractionToCtx):
30            return "slash"
31        else:
32            return "normal"
33        
34    elif isinstance(ctx, GoldyBot.objects.channel.Channel):
35        if isinstance(ctx.ctx, GoldyBot.objects.slash.InteractionToCtx):
36            return "slash"
37        else:
38            return "normal"
39        
40    else:
41        return "normal"
def mention(member: nextcord.member.Member | GoldyBot.objects.member.Member):
 9def mention(member:Nextcord_Member|GoldyBot_Member):
10    """Fixes slash commands compatibility when mentioning a member the normal way."""
11
12    if isinstance(member, Nextcord_Member):
13        return member.mention
14    if isinstance(member, GoldyBot_Member):
15        return member.member.mention
16    else:
17        return member

Fixes slash commands compatibility when mentioning a member the normal way.

async def send( ctx, text=None, embed=None, tts=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None, private=False) -> nextcord.message.Message:
 8async def send(ctx, text=None, embed=None, tts=None, 
 9    embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, 
10    reference=None, mention_author=None, view=None, private=False) -> nextcord.Message:
11    """Goldy Bot method for sending messages."""
12    message:GoldyBot.objects.slash.Message
13
14    if GoldyBot.utility.commands.what_command_type(ctx) == "slash":
15        if not embed == None:
16            if not file == None:
17                if not text == None:
18                    message = await ctx.send(content=text, embed=embed, file=file, delete_after=delete_after, 
19                    allowed_mentions=allowed_mentions, ephemeral=private)
20                    return message
21                else: # Without context.
22                    message = await ctx.send(embed=embed, file=file, delete_after=delete_after, 
23                    allowed_mentions=allowed_mentions, ephemeral=private)
24                    return message
25            
26            if not files == None:
27                message = await ctx.send(content=text, embed=embed, files=files, delete_after=delete_after, 
28                allowed_mentions=allowed_mentions, ephemeral=private, view=view)
29                return message
30
31            if not view == None:
32                message = await ctx.send(content=text, embed=embed, 
33                delete_after=delete_after, allowed_mentions=allowed_mentions, 
34                ephemeral=private, view=view)
35                return message
36
37            message = await ctx.send(content=text, embed=embed, 
38            delete_after=delete_after, allowed_mentions=allowed_mentions, 
39            ephemeral=private)
40            return message
41
42        if not embeds == None:
43            if not file == None:
44                message = await ctx.send(content=text, embeds=embeds, file=file, delete_after=delete_after, 
45                allowed_mentions=allowed_mentions, ephemeral=private, view=view)
46                return message
47
48            if not files == None:
49                message = await ctx.send(content=text, embeds=embeds, files=files, delete_after=delete_after, 
50                allowed_mentions=allowed_mentions, ephemeral=private, view=view)
51                return message
52
53            if not view == None:
54                message = await ctx.send(content=text, embeds=embeds, 
55                delete_after=delete_after, allowed_mentions=allowed_mentions, 
56                ephemeral=private, view=view)
57                return message
58
59            message = await ctx.send(content=text, embeds=embeds, delete_after=delete_after, 
60            allowed_mentions=allowed_mentions, ephemeral=private)
61            return message
62
63        if not file == None:
64            message = await ctx.send(content=text, file=file, 
65            delete_after=delete_after, allowed_mentions=allowed_mentions, 
66            ephemeral=private)
67            return message
68        
69        if not files == None:
70            message = await ctx.send(content=text, files=files, 
71            delete_after=delete_after, allowed_mentions=allowed_mentions, 
72            ephemeral=private)
73            return message
74
75        if not view == None:
76            message = await ctx.send(content=text, delete_after=delete_after, 
77            allowed_mentions=allowed_mentions, 
78            ephemeral=private, view=view)
79            return message
80
81        message = await ctx.send(content=text, delete_after=delete_after, 
82        allowed_mentions=allowed_mentions, ephemeral=private)
83        return message
84
85    if GoldyBot.utility.commands.what_command_type(ctx) == "normal":
86        message = await ctx.send(text, embed=embed, tts=tts, embeds=embeds, file=file, files=files, 
87        stickers=stickers, delete_after=delete_after, nonce=nonce, allowed_mentions=allowed_mentions, 
88        reference=reference, mention_author=mention_author, view=view)
89        return message

Goldy Bot method for sending messages.

async def defer(ctx: nextcord.interactions.Interaction) -> None:
4async def defer(ctx:nextcord.Interaction) -> None:
5    """Warns Goldy Bot that this interaction may take longer than usual. This also informs the user that goldy is currently thinking. (ONLY WORKS WITH SLASH COMMAND!)"""
6    interaction = ctx
7    await interaction.response.defer()

Warns Goldy Bot that this interaction may take longer than usual. This also informs the user that goldy is currently thinking. (ONLY WORKS WITH SLASH COMMAND!)

async def get_member_pfp(member: nextcord.member.Member) -> str:
 7async def get_member_pfp(member:nextcord.Member) -> str:
 8    """Goldy Bot method for grabbing member profile picture url."""
 9    
10    if not member.avatar == None:
11        return member.avatar.url
12    else:
13        return GoldyBot.assets.NO_PFP_IMAGE

Goldy Bot method for grabbing member profile picture url.

async def send_modal( ctx: GoldyBot.objects.slash.InteractionToCtx, modal: nextcord.ui.modal.Modal) -> GoldyBot.objects.slash.Message:
4async def send_modal(ctx:GoldyBot.InteractionToCtx, modal:GoldyBot.nextcord.ui.Modal) -> GoldyBot.objects.slash.Message:
5    return await ctx.send_modal(modal)
async def think(ctx: nextcord.interactions.Interaction) -> None:
4async def defer(ctx:nextcord.Interaction) -> None:
5    """Warns Goldy Bot that this interaction may take longer than usual. This also informs the user that goldy is currently thinking. (ONLY WORKS WITH SLASH COMMAND!)"""
6    interaction = ctx
7    await interaction.response.defer()
def what_command_type(ctx):
21def what_command_type(ctx):
22    """Tells you whether this command is a slash command or a normal command."""
23    if isinstance(ctx, GoldyBot.objects.slash.InteractionToCtx):
24        return "slash"
25
26    elif isinstance(ctx, GoldyBot.nextcord.Interaction):
27        return "slash"
28        
29    elif isinstance(ctx, GoldyBot.objects.member.Member):
30        if isinstance(ctx.ctx, GoldyBot.objects.slash.InteractionToCtx):
31            return "slash"
32        else:
33            return "normal"
34        
35    elif isinstance(ctx, GoldyBot.objects.channel.Channel):
36        if isinstance(ctx.ctx, GoldyBot.objects.slash.InteractionToCtx):
37            return "slash"
38        else:
39            return "normal"
40        
41    else:
42        return "normal"

Tells you whether this command is a slash command or a normal command.