Skip to content

Basic

Bases: Extension

Source code in extentions/basic.py
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
class Basic(Extension):
    def __init__(self, bot: Client):
        self.bot = bot

    @slash_command("echo", description="Echo your messages")
    @text()
    @channel()
    @check(member_permissions(Permissions.ADMINISTRATOR))
    async def echo(self, ctx: SlashContext, text: str, channel:OptionType.CHANNEL=None):
        """
        /echo
        Description:
            Echo your messages.

        Args:
            text (str): Text to echo.
            channel (OptionType.CHANNEL, optional): Channel to echo in, defaults to channel you're executing the command from.
        """
        if (channel is None):
            channel = ctx.channel
        await channel.send(text)
        message = await ctx.send(f'{ctx.author.mention} message `{text}` in {channel.mention} echoed!', ephemeral=True)
        #await channel.delete_message(message, 'message for echo command')

    @slash_command(name='userinfo', description="Lets you see info about server members")
    @member()
    async def userinfo(self, ctx:SlashContext, member:OptionType.USER=None):
        """
        /userinfo
        Description:
            Lets you see info about server members.

        Args:
            member (OptionType.USER, optional): Member to fetch info about. Defaults to the member executing the command.
        """
        if member is None:
            member = ctx.author

        if member.top_role.name != '@everyone':
            toprole = member.top_role.mention
        else:
            toprole = 'None'

        roles = [role.mention for role in member.roles if role.name != '@everyone']
        rolecount = len(roles)
        if rolecount == 0:
            roles = 'None'
        else:
            roles = ' '.join(roles)

        if member.top_role.color.value == 0:
            color = 0xffcc50
        else:
            color = member.top_role.color

        cdiff = relativedelta(datetime.now(tz=timezone.utc), member.created_at.replace(tzinfo=timezone.utc))
        creation_time = f"{cdiff.years} Y, {cdiff.months} M, {cdiff.days} D"

        jdiff = relativedelta(datetime.now(tz=timezone.utc), member.joined_at.replace(tzinfo=timezone.utc))
        join_time = f"{jdiff.years} Y, {jdiff.months} M, {jdiff.days} D"

        if member.guild_avatar is not None:
            avatarurl = f'{member.guild_avatar.url}.png'
        else:
            avatarurl = f'{member.avatar.url}.png'

        embed = Embed(color=color,
                      title=f"User Info - {member}")
        embed.set_thumbnail(url=avatarurl)
        embed.add_field(name="ID(snowflake):", value=member.id, inline=False)
        embed.add_field(name="Nickname:", value=member.display_name, inline=False)
        embed.add_field(name="Created account on:", value=f"<t:{math.ceil(member.created_at.timestamp())}> `{creation_time} ago`", inline=False)
        embed.add_field(name="Joined server on:", value=f"<t:{math.ceil(member.joined_at.timestamp())}> `{join_time} ago`", inline=False)
        embed.add_field(name=f"Roles: [{rolecount}]", value=roles, inline=False)
        embed.add_field(name="Highest role:", value=toprole, inline=False)
        await ctx.send(embed=embed)

    @slash_command(name='serverinfo', description="Lets you see info about the server")
    async def serverinfo(self, ctx:SlashContext):
        """
        /serverinfo
        Description:
            Lets you see info about the server
        """
        cdiff = relativedelta(datetime.now(tz=timezone.utc), ctx.guild.created_at.replace(tzinfo=timezone.utc))
        creation_time = f"{cdiff.years} Y, {cdiff.months} M, {cdiff.days} D"
        owner = await guild_owner(ctx)
        embed = Embed(title=f"Server Info", color=0xffcc50)
        embed.set_author(name=f'{ctx.guild.name}', icon_url=f'{ctx.guild.icon.url}')
        embed.set_thumbnail(url=f'{ctx.guild.icon.url}')
        embed.add_field(name='Server owner', value=f'{owner.mention}', inline=False)
        embed.add_field(name='Members', value=f'{ctx.guild.member_count}', inline=False)
        embed.add_field(name="Channels:", value=len(ctx.guild.channels), inline=False)
        embed.add_field(name="Roles:", value=len(ctx.guild.roles), inline=False)
        embed.add_field(name='Boost level', value=f'{ctx.guild.premium_tier}[{ctx.guild.premium_subscription_count} boosts]', inline=False)
        embed.add_field(name='Created at', value=f'<t:{math.ceil(ctx.guild.created_at.timestamp())}> `{creation_time} ago`', inline=False)
        embed.add_field(name='Region', value=f'{ctx.guild.preferred_locale}', inline=False)
        embed.add_field(name='ID', value=f'{ctx.guild_id}', inline=True)
        await ctx.send(embed=embed)

    @slash_command(name='botinfo', description="Lets you see info about the bot")
    async def botinfo(self, ctx: SlashContext):
        """
        /botinfo
        Description:
            Lets you see info about the bot
        """
        member = ctx.guild.get_member(self.bot.user.id)

        if member.top_role.name != '@everyone':
            toprole = member.top_role.mention
        else:
            toprole = 'None'

        roles = [role.mention for role in member.roles if role.name != '@everyone']
        rolecount = len(roles)
        if rolecount == 0:
            roles = 'None'
        else:
            roles = ' '.join(roles)

        if member.top_role.color.value == 0:
            color = 0xffcc50
        else:
            color = member.top_role.color

        cdiff = relativedelta(datetime.now(tz=timezone.utc), member.created_at.replace(tzinfo=timezone.utc))
        creation_time = f"{cdiff.years} Y, {cdiff.months} M, {cdiff.days} D"

        jdiff = relativedelta(datetime.now(tz=timezone.utc), member.joined_at.replace(tzinfo=timezone.utc))
        join_time = f"{jdiff.years} Y, {jdiff.months} M, {jdiff.days} D"

        if member.guild_avatar is not None:
            avatarurl = f'{member.guild_avatar.url}.png'
        else:
            avatarurl = f'{member.avatar.url}.png'

        embed = Embed(color=color,
                      title=f"Bot Info - {member}")
        embed.set_thumbnail(url=avatarurl)
        #embed.set_author(name=member, icon_url=member.avatar.url)
        embed.add_field(name="ID(snowflake):", value=member.id, inline=False)
        embed.add_field(name="Nickname:", value=member.display_name, inline=False)
        embed.add_field(name="Created account on:", value=f"<t:{math.ceil(member.created_at.timestamp())}> `{creation_time} ago`", inline=False)
        embed.add_field(name="Joined server on:", value=f"<t:{math.ceil(member.joined_at.timestamp())}> `{join_time} ago`", inline=False)
        embed.add_field(name=f"Roles: [{rolecount}]", value=roles, inline=False)
        embed.add_field(name="Highest role:", value=toprole, inline=False)
        embed.add_field(name="Library:", value="[interactions.py](https://github.com/interactions-py/interactions.py)")
        embed.add_field(name="Servers:", value=len(self.bot.user.guilds))
        embed.add_field(name="Bot Latency:", value=f"{self.bot.latency * 1000:.0f} ms")
        embed.add_field(name='GitHub: https://github.com/siren15/melody', value='‎')
        embed.set_footer(text="Melody | powered by i.py")
        await ctx.send(embed=embed)

    @slash_command(name='avatar', description="Show's you your avatar, or members, if provided")
    @member()
    async def avatar(self, ctx:SlashContext, member:OptionType.USER=None):
        """/avatar
        Description:
            Show's you your avatar, or members, if provided

        Args:
            member (OptionType.USER, optional): Member to fetch avatar from. Defaults to member executing the command.
        """
        if member is None:
            member = ctx.author

        if member.guild_avatar is not None:
            avatarurl = member.guild_avatar.url
        else:
            avatarurl = member.avatar.url

        embed = Embed(description=member.display_name, color=0xffcc50)
        embed.set_image(url=avatarurl)
        await ctx.send(embed=embed)

    @slash_command(name='useravatar', description="Show's you your avatar, or users, if provided")
    @member()
    async def useravatar(self, ctx:SlashContext, member:OptionType.USER=None):

        if member is None:
            member = ctx.author

        avatarurl = member.avatar.url

        embed = Embed(description=member.display_name, color=0xffcc50)
        embed.set_image(url=avatarurl)
        await ctx.send(embed=embed)

    @slash_command(name='search', description="Search with DuckDuckGo, returns the first result.")
    @text()
    async def duckduckgosearch(self, ctx:SlashContext, text: str):
        """/search

        Description:
            Search with DuckDuckGo, returns the first result.

        Args:
            text (str): Search query
        """
        await ctx.defer()
        results = await duckduckgo.search(text)
        embed = Embed(
            title=results[0].title,
            description=results[0].description,
            color=0xdb4b26
        )
        embed.set_footer(text=results[0].url)
        await ctx.send(embed=embed)

    @slash_command(name='ping', description="Ping! Pong!")
    async def ping(self, ctx:SlashContext):
        """/ping
        Description:
            Get the bot's latency
        """
        await ctx.send(f"Pong! \nBot's latency: {self.bot.latency * 1000} ms")

    create_embed = SlashCommand(name='embed', description='Create and edit embeds.', default_member_permissions=Permissions.ADMINISTRATOR)

    @create_embed.subcommand(sub_cmd_name='create', sub_cmd_description='Create embeds')
    async def embed_create(self, ctx:SlashContext):
        """/embed create
        Description:
            Create embeds. After execution it will show you a modal popup, where you can write your embed. Limit 10 minutes for creation.
        """
        components=[
            ShortText(
                label="Embed Title",
                custom_id=f'embed_title',
                required=False
            ),
            ParagraphText(
                label="Embed Text",
                custom_id=f'embed_text',
                required=False
            ),
            ShortText(
                label="Embed Image",
                custom_id=f'embed_image',
                required=False,
                placeholder='Image URL'
            ),
            ShortText(
                label="Embed Colour",
                custom_id=f'embed_colour',
                required=False,
                placeholder='Colour HEX code'
            )
        ]
        m = Modal(title='Create an embed', custom_id=f'{ctx.author.id}_embed_modal')
        m.add_components(components)
        await ctx.send_modal(m)
        try:
            modal_recived: ModalContext = await self.bot.wait_for_modal(modal=m, author=ctx.author.id, timeout=600)
        except asyncio.TimeoutError:
            return await ctx.send(f":x: Uh oh, {ctx.author.mention}! You took longer than 10 minutes to respond.", ephemeral=True)

        embed_title = modal_recived.responses.get('embed_title')
        if embed_title is None:
            embed_title = MISSING
        embed_text = modal_recived.responses.get('embed_text')
        if embed_text is None:
            embed_text = MISSING
        embed_image = modal_recived.responses.get('embed_image')
        if embed_image is None:
            embed_image = MISSING
        if (embed_title is None) and (embed_text is None):
            await ctx.send('You must include either embed title or text', ephemeral=True)
            return
        embed_colour = modal_recived.responses.get('embed_colour')
        if embed_colour is None or embed_colour == '':
            embed_colour = 0xffcc50
        else:
            from utils import utils
            if not utils.is_hex_valid(embed_colour):
                await modal_recived.send('Colour HEX not valid. Using default embed colour.', ephemeral=True)
                embed_colour = 0xffcc50
        embed=Embed(color=embed_colour,
        description=embed_text,
        title=embed_title)
        embed.set_image(embed_image)
        await modal_recived.send(embed=embed)

    @create_embed.subcommand(sub_cmd_name='edit', sub_cmd_description='Edit embeds')
    @embed_message_id()
    @channel()
    async def embed_edit(self, ctx:SlashContext, embed_message_id:str=None, channel:OptionType.CHANNEL=None):
        """/embed edit

        Description:
            Edit embeds. After execution it will show you a modal popup, where you can write your embed. Limit 10 minutes for editing.

        Args:
            embed_message_id (str, optional): ID of the message the embed is on.
            channel (OptionType.CHANNEL, optional): Channel the message is in. Defaults to the channel the command is executed in.
        """
        if embed_message_id is None:
            await ctx.send('You have to include the embed message ID, so that I can edit the embed', ephemeral=True)
            return
        elif channel is None:
            channel = ctx.channel
        m = Modal(title='Create an embed', components=[
            InputText(
                label="Embed Title",
                style=TextStyles.SHORT,
                custom_id=f'embed_title',
                required=False
            ),
            InputText(
                label="Embed Text",
                style=TextStyles.PARAGRAPH,
                custom_id=f'embed_text',
                required=False
            ),
            InputText(
                label="Embed Image",
                style=TextStyles.SHORT,
                custom_id=f'embed_image',
                required=False,
                placeholder='Image URL'
            ),
            InputText(
                label="Embed Colour",
                style=TextStyles.SHORT,
                custom_id=f'embed_colour',
                required=False,
                placeholder='Colour HEX code'
            )
        ],
        custom_id=f'{ctx.author.id}_embed_modal'
        )

        await ctx.send_modal(modal=m)

        try:
            modal_recived: ModalContext = await self.bot.wait_for_modal(modal=m, author=ctx.author.id, timeout=600)
        except asyncio.TimeoutError:
            return await ctx.send(f":x: Uh oh, {ctx.author.mention}! You took longer than 10 minutes to respond.", ephemeral=True)

        embed_title = modal_recived.responses.get('embed_title')
        if embed_title is None:
            embed_title = MISSING
        embed_text = modal_recived.responses.get('embed_text')
        if embed_text is None:
            embed_text = MISSING
        embed_image = modal_recived.responses.get('embed_image')
        if embed_image is None:
            embed_image = MISSING
        if (embed_title is None) and (embed_text is None):
            await ctx.send('You must include either embed title or text', ephemeral=True)
            return
        embed_colour = modal_recived.responses.get('embed_colour')
        if embed_colour is None:
            embed_colour = 0xffcc50
        else:
            from utils import utils
            if not utils.is_hex_valid(embed_colour):
                await modal_recived.send('Colour HEX not valid. Using default embed colour.', ephemeral=True)
                embed_colour = 0xffcc50
        message_to_edit = await channel.fetch_message(embed_message_id)
        embed=Embed(color=embed_colour,
        description=embed_text,
        title=embed_title)
        embed.set_image(embed_image)
        await message_to_edit.edit(embed=embed)
        await modal_recived.send('Message edited', ephemeral=True)

echo(ctx, text, channel=None) async

/echo

Description

Echo your messages.

Parameters:

Name Type Description Default
text str

Text to echo.

required
channel OptionType.CHANNEL

Channel to echo in, defaults to channel you're executing the command from.

None
Source code in extentions/basic.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
@slash_command("echo", description="Echo your messages")
@text()
@channel()
@check(member_permissions(Permissions.ADMINISTRATOR))
async def echo(self, ctx: SlashContext, text: str, channel:OptionType.CHANNEL=None):
    """
    /echo
    Description:
        Echo your messages.

    Args:
        text (str): Text to echo.
        channel (OptionType.CHANNEL, optional): Channel to echo in, defaults to channel you're executing the command from.
    """
    if (channel is None):
        channel = ctx.channel
    await channel.send(text)
    message = await ctx.send(f'{ctx.author.mention} message `{text}` in {channel.mention} echoed!', ephemeral=True)

userinfo(ctx, member=None) async

/userinfo

Description

Lets you see info about server members.

Parameters:

Name Type Description Default
member OptionType.USER

Member to fetch info about. Defaults to the member executing the command.

None
Source code in extentions/basic.py
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
@slash_command(name='userinfo', description="Lets you see info about server members")
@member()
async def userinfo(self, ctx:SlashContext, member:OptionType.USER=None):
    """
    /userinfo
    Description:
        Lets you see info about server members.

    Args:
        member (OptionType.USER, optional): Member to fetch info about. Defaults to the member executing the command.
    """
    if member is None:
        member = ctx.author

    if member.top_role.name != '@everyone':
        toprole = member.top_role.mention
    else:
        toprole = 'None'

    roles = [role.mention for role in member.roles if role.name != '@everyone']
    rolecount = len(roles)
    if rolecount == 0:
        roles = 'None'
    else:
        roles = ' '.join(roles)

    if member.top_role.color.value == 0:
        color = 0xffcc50
    else:
        color = member.top_role.color

    cdiff = relativedelta(datetime.now(tz=timezone.utc), member.created_at.replace(tzinfo=timezone.utc))
    creation_time = f"{cdiff.years} Y, {cdiff.months} M, {cdiff.days} D"

    jdiff = relativedelta(datetime.now(tz=timezone.utc), member.joined_at.replace(tzinfo=timezone.utc))
    join_time = f"{jdiff.years} Y, {jdiff.months} M, {jdiff.days} D"

    if member.guild_avatar is not None:
        avatarurl = f'{member.guild_avatar.url}.png'
    else:
        avatarurl = f'{member.avatar.url}.png'

    embed = Embed(color=color,
                  title=f"User Info - {member}")
    embed.set_thumbnail(url=avatarurl)
    embed.add_field(name="ID(snowflake):", value=member.id, inline=False)
    embed.add_field(name="Nickname:", value=member.display_name, inline=False)
    embed.add_field(name="Created account on:", value=f"<t:{math.ceil(member.created_at.timestamp())}> `{creation_time} ago`", inline=False)
    embed.add_field(name="Joined server on:", value=f"<t:{math.ceil(member.joined_at.timestamp())}> `{join_time} ago`", inline=False)
    embed.add_field(name=f"Roles: [{rolecount}]", value=roles, inline=False)
    embed.add_field(name="Highest role:", value=toprole, inline=False)
    await ctx.send(embed=embed)

serverinfo(ctx) async

/serverinfo

Description

Lets you see info about the server

Source code in extentions/basic.py
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
@slash_command(name='serverinfo', description="Lets you see info about the server")
async def serverinfo(self, ctx:SlashContext):
    """
    /serverinfo
    Description:
        Lets you see info about the server
    """
    cdiff = relativedelta(datetime.now(tz=timezone.utc), ctx.guild.created_at.replace(tzinfo=timezone.utc))
    creation_time = f"{cdiff.years} Y, {cdiff.months} M, {cdiff.days} D"
    owner = await guild_owner(ctx)
    embed = Embed(title=f"Server Info", color=0xffcc50)
    embed.set_author(name=f'{ctx.guild.name}', icon_url=f'{ctx.guild.icon.url}')
    embed.set_thumbnail(url=f'{ctx.guild.icon.url}')
    embed.add_field(name='Server owner', value=f'{owner.mention}', inline=False)
    embed.add_field(name='Members', value=f'{ctx.guild.member_count}', inline=False)
    embed.add_field(name="Channels:", value=len(ctx.guild.channels), inline=False)
    embed.add_field(name="Roles:", value=len(ctx.guild.roles), inline=False)
    embed.add_field(name='Boost level', value=f'{ctx.guild.premium_tier}[{ctx.guild.premium_subscription_count} boosts]', inline=False)
    embed.add_field(name='Created at', value=f'<t:{math.ceil(ctx.guild.created_at.timestamp())}> `{creation_time} ago`', inline=False)
    embed.add_field(name='Region', value=f'{ctx.guild.preferred_locale}', inline=False)
    embed.add_field(name='ID', value=f'{ctx.guild_id}', inline=True)
    await ctx.send(embed=embed)

botinfo(ctx) async

/botinfo

Description

Lets you see info about the bot

Source code in extentions/basic.py
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
@slash_command(name='botinfo', description="Lets you see info about the bot")
async def botinfo(self, ctx: SlashContext):
    """
    /botinfo
    Description:
        Lets you see info about the bot
    """
    member = ctx.guild.get_member(self.bot.user.id)

    if member.top_role.name != '@everyone':
        toprole = member.top_role.mention
    else:
        toprole = 'None'

    roles = [role.mention for role in member.roles if role.name != '@everyone']
    rolecount = len(roles)
    if rolecount == 0:
        roles = 'None'
    else:
        roles = ' '.join(roles)

    if member.top_role.color.value == 0:
        color = 0xffcc50
    else:
        color = member.top_role.color

    cdiff = relativedelta(datetime.now(tz=timezone.utc), member.created_at.replace(tzinfo=timezone.utc))
    creation_time = f"{cdiff.years} Y, {cdiff.months} M, {cdiff.days} D"

    jdiff = relativedelta(datetime.now(tz=timezone.utc), member.joined_at.replace(tzinfo=timezone.utc))
    join_time = f"{jdiff.years} Y, {jdiff.months} M, {jdiff.days} D"

    if member.guild_avatar is not None:
        avatarurl = f'{member.guild_avatar.url}.png'
    else:
        avatarurl = f'{member.avatar.url}.png'

    embed = Embed(color=color,
                  title=f"Bot Info - {member}")
    embed.set_thumbnail(url=avatarurl)
    #embed.set_author(name=member, icon_url=member.avatar.url)
    embed.add_field(name="ID(snowflake):", value=member.id, inline=False)
    embed.add_field(name="Nickname:", value=member.display_name, inline=False)
    embed.add_field(name="Created account on:", value=f"<t:{math.ceil(member.created_at.timestamp())}> `{creation_time} ago`", inline=False)
    embed.add_field(name="Joined server on:", value=f"<t:{math.ceil(member.joined_at.timestamp())}> `{join_time} ago`", inline=False)
    embed.add_field(name=f"Roles: [{rolecount}]", value=roles, inline=False)
    embed.add_field(name="Highest role:", value=toprole, inline=False)
    embed.add_field(name="Library:", value="[interactions.py](https://github.com/interactions-py/interactions.py)")
    embed.add_field(name="Servers:", value=len(self.bot.user.guilds))
    embed.add_field(name="Bot Latency:", value=f"{self.bot.latency * 1000:.0f} ms")
    embed.add_field(name='GitHub: https://github.com/siren15/melody', value='‎')
    embed.set_footer(text="Melody | powered by i.py")
    await ctx.send(embed=embed)

avatar(ctx, member=None) async

/avatar

Description

Show's you your avatar, or members, if provided

Parameters:

Name Type Description Default
member OptionType.USER

Member to fetch avatar from. Defaults to member executing the command.

None
Source code in extentions/basic.py
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
@slash_command(name='avatar', description="Show's you your avatar, or members, if provided")
@member()
async def avatar(self, ctx:SlashContext, member:OptionType.USER=None):
    """/avatar
    Description:
        Show's you your avatar, or members, if provided

    Args:
        member (OptionType.USER, optional): Member to fetch avatar from. Defaults to member executing the command.
    """
    if member is None:
        member = ctx.author

    if member.guild_avatar is not None:
        avatarurl = member.guild_avatar.url
    else:
        avatarurl = member.avatar.url

    embed = Embed(description=member.display_name, color=0xffcc50)
    embed.set_image(url=avatarurl)
    await ctx.send(embed=embed)

duckduckgosearch(ctx, text) async

/search

Description

Search with DuckDuckGo, returns the first result.

Parameters:

Name Type Description Default
text str

Search query

required
Source code in extentions/basic.py
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
@slash_command(name='search', description="Search with DuckDuckGo, returns the first result.")
@text()
async def duckduckgosearch(self, ctx:SlashContext, text: str):
    """/search

    Description:
        Search with DuckDuckGo, returns the first result.

    Args:
        text (str): Search query
    """
    await ctx.defer()
    results = await duckduckgo.search(text)
    embed = Embed(
        title=results[0].title,
        description=results[0].description,
        color=0xdb4b26
    )
    embed.set_footer(text=results[0].url)
    await ctx.send(embed=embed)

ping(ctx) async

/ping

Description

Get the bot's latency

Source code in extentions/basic.py
232
233
234
235
236
237
238
@slash_command(name='ping', description="Ping! Pong!")
async def ping(self, ctx:SlashContext):
    """/ping
    Description:
        Get the bot's latency
    """
    await ctx.send(f"Pong! \nBot's latency: {self.bot.latency * 1000} ms")

embed_create(ctx) async

/embed create

Description

Create embeds. After execution it will show you a modal popup, where you can write your embed. Limit 10 minutes for creation.

Source code in extentions/basic.py
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
@create_embed.subcommand(sub_cmd_name='create', sub_cmd_description='Create embeds')
async def embed_create(self, ctx:SlashContext):
    """/embed create
    Description:
        Create embeds. After execution it will show you a modal popup, where you can write your embed. Limit 10 minutes for creation.
    """
    components=[
        ShortText(
            label="Embed Title",
            custom_id=f'embed_title',
            required=False
        ),
        ParagraphText(
            label="Embed Text",
            custom_id=f'embed_text',
            required=False
        ),
        ShortText(
            label="Embed Image",
            custom_id=f'embed_image',
            required=False,
            placeholder='Image URL'
        ),
        ShortText(
            label="Embed Colour",
            custom_id=f'embed_colour',
            required=False,
            placeholder='Colour HEX code'
        )
    ]
    m = Modal(title='Create an embed', custom_id=f'{ctx.author.id}_embed_modal')
    m.add_components(components)
    await ctx.send_modal(m)
    try:
        modal_recived: ModalContext = await self.bot.wait_for_modal(modal=m, author=ctx.author.id, timeout=600)
    except asyncio.TimeoutError:
        return await ctx.send(f":x: Uh oh, {ctx.author.mention}! You took longer than 10 minutes to respond.", ephemeral=True)

    embed_title = modal_recived.responses.get('embed_title')
    if embed_title is None:
        embed_title = MISSING
    embed_text = modal_recived.responses.get('embed_text')
    if embed_text is None:
        embed_text = MISSING
    embed_image = modal_recived.responses.get('embed_image')
    if embed_image is None:
        embed_image = MISSING
    if (embed_title is None) and (embed_text is None):
        await ctx.send('You must include either embed title or text', ephemeral=True)
        return
    embed_colour = modal_recived.responses.get('embed_colour')
    if embed_colour is None or embed_colour == '':
        embed_colour = 0xffcc50
    else:
        from utils import utils
        if not utils.is_hex_valid(embed_colour):
            await modal_recived.send('Colour HEX not valid. Using default embed colour.', ephemeral=True)
            embed_colour = 0xffcc50
    embed=Embed(color=embed_colour,
    description=embed_text,
    title=embed_title)
    embed.set_image(embed_image)
    await modal_recived.send(embed=embed)

embed_edit(ctx, embed_message_id=None, channel=None) async

/embed edit

Description

Edit embeds. After execution it will show you a modal popup, where you can write your embed. Limit 10 minutes for editing.

Parameters:

Name Type Description Default
embed_message_id str

ID of the message the embed is on.

None
channel OptionType.CHANNEL

Channel the message is in. Defaults to the channel the command is executed in.

None
Source code in extentions/basic.py
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
@create_embed.subcommand(sub_cmd_name='edit', sub_cmd_description='Edit embeds')
@embed_message_id()
@channel()
async def embed_edit(self, ctx:SlashContext, embed_message_id:str=None, channel:OptionType.CHANNEL=None):
    """/embed edit

    Description:
        Edit embeds. After execution it will show you a modal popup, where you can write your embed. Limit 10 minutes for editing.

    Args:
        embed_message_id (str, optional): ID of the message the embed is on.
        channel (OptionType.CHANNEL, optional): Channel the message is in. Defaults to the channel the command is executed in.
    """
    if embed_message_id is None:
        await ctx.send('You have to include the embed message ID, so that I can edit the embed', ephemeral=True)
        return
    elif channel is None:
        channel = ctx.channel
    m = Modal(title='Create an embed', components=[
        InputText(
            label="Embed Title",
            style=TextStyles.SHORT,
            custom_id=f'embed_title',
            required=False
        ),
        InputText(
            label="Embed Text",
            style=TextStyles.PARAGRAPH,
            custom_id=f'embed_text',
            required=False
        ),
        InputText(
            label="Embed Image",
            style=TextStyles.SHORT,
            custom_id=f'embed_image',
            required=False,
            placeholder='Image URL'
        ),
        InputText(
            label="Embed Colour",
            style=TextStyles.SHORT,
            custom_id=f'embed_colour',
            required=False,
            placeholder='Colour HEX code'
        )
    ],
    custom_id=f'{ctx.author.id}_embed_modal'
    )

    await ctx.send_modal(modal=m)

    try:
        modal_recived: ModalContext = await self.bot.wait_for_modal(modal=m, author=ctx.author.id, timeout=600)
    except asyncio.TimeoutError:
        return await ctx.send(f":x: Uh oh, {ctx.author.mention}! You took longer than 10 minutes to respond.", ephemeral=True)

    embed_title = modal_recived.responses.get('embed_title')
    if embed_title is None:
        embed_title = MISSING
    embed_text = modal_recived.responses.get('embed_text')
    if embed_text is None:
        embed_text = MISSING
    embed_image = modal_recived.responses.get('embed_image')
    if embed_image is None:
        embed_image = MISSING
    if (embed_title is None) and (embed_text is None):
        await ctx.send('You must include either embed title or text', ephemeral=True)
        return
    embed_colour = modal_recived.responses.get('embed_colour')
    if embed_colour is None:
        embed_colour = 0xffcc50
    else:
        from utils import utils
        if not utils.is_hex_valid(embed_colour):
            await modal_recived.send('Colour HEX not valid. Using default embed colour.', ephemeral=True)
            embed_colour = 0xffcc50
    message_to_edit = await channel.fetch_message(embed_message_id)
    embed=Embed(color=embed_colour,
    description=embed_text,
    title=embed_title)
    embed.set_image(embed_image)
    await message_to_edit.edit(embed=embed)
    await modal_recived.send('Message edited', ephemeral=True)