#discord-bots

1 messages · Page 529 of 1

hollow agate
#

Yes

hearty shoal
#

It's just causing a timeout regardless of whether the condition is met or not

dapper cobalt
#

Can I see your code?

hearty shoal
#

can I dm you it?

dapper cobalt
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

hearty shoal
#

not that long

#

just felt like doing so

visual island
hollow agate
#

What're we trying to do?

hearty shoal
visual island
hearty shoal
#

Been browsing the docs and whatnot for ages
still lost huehpain

hollow agate
#
class History(discord.ui.Select):
    def __init__(self):
        options = [
            discord.SelectOption(emoji='1️⃣', label='Warns'),
            discord.SelectOption(emoji='2️⃣', label='Mutes'),
            discord.SelectOption(emoji='3️⃣', label='Bans'),
            discord.SelectOption(emoji='4️⃣', label='Kicks')
        ]
        super().__init__(placeholder='How may I help?', min_values=1, max_values=1, options=options, custom_id="pp1")

    async def callback(self, interaction: discord.Interaction):
        if self.values[0] == 'Warns':
            db = await aiosqlite.connect('database.db')
            cursor = await db.execute('SELECT * FROM warns WHERE user_ids=?', (member.id,))
            rows = await cursor.fetchall()
            await db.close()
            embed = discord.Embed(
                title=f"Warns",
                color=discord.Color.red())
            for row in rows:
                embed.add_field(name=f"Case {row[2]}", value=row[1])
            await interaction.response.send_message(embed=embed)
            return
        if self.values[0] == 'Mutes':
            await interaction.response.send_message(f'Currently Not Available!', ephemeral=True)
        if self.values[0] == 'Bans':
            await interaction.response.send_message(f'Currently Not Available!', ephemeral=True)
        if self.values[0] == 'Kicks':
            await interaction.response.send_message(f'Currently Not Available!', ephemeral=True)

class HistoryView(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)
        self.add_item(History())

client = PersistentViewBot()
client.remove_command('help')

@client.command()
@commands.has_permissions(administrator=True)
async def history(ctx: commands.Context, member: discord.Member = None):
    if member == None:
        a = await ctx.reply("You can't see the history of nobody!")
        await asyncio.sleep(5)
        await ctx.message.delete()
        await a.delete()
        return
    else:
        view = HistoryView()
        embed = discord.Embed(
            title=f"History of {member}",
            description=
            f"Choose the type of history you would like to view!",
            color=discord.Color.purple())
        await ctx.channel.send(embed=embed, view=view)
        await ctx.message.delete()
        await view.wait()``` It sends the right view. I just need to get the member from the command into the callback/some other way to fix the `member.id` to get their history.
dapper cobalt
hearty shoal
#

well

#

it was initially something else and I kinda just rushed that in

dapper cobalt
#
@commands.Cog.listener()
async def on_reaction_add(self, reaction, user):
    if user == self.bot.user:
      return
    delete = '🗑️'

    if str(reaction.emoji) == delete:
      if reaction.message.author.bot:
        await reaction.message.delete()
hearty shoal
#

thanks, lol

my brain is quite fried too, so I honestly just have no idea what the hell I am doing for the most part

dapper cobalt
#

I recommend you learn Python before jumping into discord.py.

hearty shoal
#

I've just been learning both at once at this point
huehpain

visual island
#

then later you can access it from callback

dapper cobalt
#

Will take you much longer to learn than if you learnt at least the basics first.

hollow agate
#

Could I by chance get an example to add it to the init? I've been trying to research it in the documents, but I can't find anything, I'm so sorry, I just would really like to go this done

visual island
# hollow agate Could I by chance get an example to add it to the init? I've been trying to rese...
class History(discord.ui.Select):
    def __init__(self, member: discord.Member = None):
        self.member = member
        options = [
            discord.SelectOption(emoji='1️⃣', label='Warns'),
            discord.SelectOption(emoji='2️⃣', label='Mutes'),
            discord.SelectOption(emoji='3️⃣', label='Bans'),
            discord.SelectOption(emoji='4️⃣', label='Kicks')
        ]
        super().__init__(placeholder='How may I help?', min_values=1, max_values=1, options=options, custom_id="pp1")

    async def callback(self, interaction: discord.Interaction):
        if self.values[0] == 'Warns':
            db = await aiosqlite.connect('database.db')
            cursor = await db.execute('SELECT * FROM warns WHERE user_ids=?', (self.member.id,))
            rows = await cursor.fetchall()
            await db.close()
            embed = discord.Embed(
                title=f"Warns",
                color=discord.Color.red())
            for row in rows:
                embed.add_field(name=f"Case {row[2]}", value=row[1])
            await interaction.response.send_message(embed=embed)
            return
        if self.values[0] == 'Mutes':
            await interaction.response.send_message(f'Currently Not Available!', ephemeral=True)
        if self.values[0] == 'Bans':
            await interaction.response.send_message(f'Currently Not Available!', ephemeral=True)
        if self.values[0] == 'Kicks':
            await interaction.response.send_message(f'Currently Not Available!', ephemeral=True)

class HistoryView(discord.ui.View):
    def __init__(self, member: discord.Member = None):
        super().__init__(timeout=None)
        self.add_item(History(member))
``` this is for the `View`
#

view = HistoryView(member) and in the command

hollow agate
#

Oh wait

#

It works! Thank you so much!

blazing beacon
visual island
delicate moat
#

Wait is there a way to make a bot do TTS in a vc?

keen oasis
#

how do you set a vanity url using d.py RS_hmmHD

keen oasis
#

ah

#

ty RS_ThumbsUp

pale zenith
#

😄

pale zenith
hollow agate
#
class History(discord.ui.Select):
    def __init__(self, member: discord.Member = None):
        self.member = member
        options = [
            discord.SelectOption(emoji='1️⃣', label='Warns'),
            discord.SelectOption(emoji='2️⃣', label='Mutes'),
            discord.SelectOption(emoji='3️⃣', label='Bans'),
            discord.SelectOption(emoji='4️⃣', label='Kicks')
        ]
        super().__init__(placeholder='How may I help?', min_values=1, max_values=1, options=options, custom_id="pp1")

    async def callback(self, interaction: discord.Interaction):
        channel = interaction.guild.get_channel(interaction.channel)
        if self.values[0] == 'Warns':
            db = await aiosqlite.connect('database.db')
            cursor = await db.execute('SELECT * FROM warns WHERE user_ids=?', (self.member.id,))
            rows = await cursor.fetchall()
            await db.close()
            embed = discord.Embed(
                title=f"Warns",
                color=discord.Color.red())
            for row in rows:
                embed.add_field(name=f"Case {row[2]}", value=row[1])
            await interaction.channel.send(embed=embed)
            return
        if self.values[0] == 'Mutes':
            await interaction.channel.send(f'Currently Not Available!')
        if self.values[0] == 'Bans':
            await interaction.channel.send(f'Currently Not Available!', ephemeral=True)
        if self.values[0] == 'Kicks':
            await interaction.channel.send(f'Currently Not Available!', ephemeral=True)

class HistoryView(discord.ui.View):
    def __init__(self, member: discord.Member = None):
        super().__init__(timeout=45)
        self.add_item(History(member))

client = PersistentViewBot()
client.remove_command('help')

@client.command()
@commands.has_permissions(administrator=True)
async def history(ctx: commands.Context, member: discord.Member = None):
    if member == None:
        a = await ctx.reply("You can't see the history of nobody!")
        await asyncio.sleep(5)
        await ctx.message.delete()
        await a.delete()
        return
    else:
        view = HistoryView(member)
        embed = discord.Embed(
            title=f"History of {member}",
            description=
            f"Choose the type of history you would like to view!",
            color=discord.Color.purple())
        await ctx.channel.send(embed=embed, view=view)
        await ctx.message.delete()
        await view.wait()``` Why does it send this error: ```py
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction``` when I use any of those?
#

It works, but it just gives me that error confusedparrot

hollow agate
#

I'm responding in under 3 seconds though?

#

Where would I add .defer()?

pale zenith
#

await interaction.response.defer() (i think its a coro)

slate swan
#

I need a help

hollow agate
#
            await interaction.edit_original_message.defer(embed=embed)``` I don't think I'm understanding :P
pale zenith
# pale zenith `await interaction.response.defer()` (i think its a coro)

also try using your view's on_error to see if it catches a different error @hollow agate
i was having the same error and it was actually this:

discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.5: The specified component exceeds the maximum width
slate swan
# slate swan I need a help

I need to make a select menu when clicked on a option it should show an embed when clicked on other it should show other can anyone help?

hollow agate
#
@client.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandNotFound):
        return
    elif isinstance(error, commands.MissingPermissions):
        return
    elif isinstance(error, commands.MemberNotFound):
        return
    elif isinstance(error, commands.CommandInvokeError):
        return
    elif isinstance(error, commands.CommandOnCooldown):
        await ctx.channel.send(
            f"Hey {ctx.author.mention}! You can't use that command yet! \n \nTry again in {error.retry_after:.2f}s.",
            delete_after=10)
        await ctx.message.delete()
    else:
        print('Ignoring exception in command {}:'.format(ctx.command),
              file=sys.stderr)
        traceback.print_exception(type(error),
                                  error,
                                  error.__traceback__,
                                  file=sys.stderr)``` Is the only thing I had and I removed it.
slate swan
#

Or

pale zenith
unkempt canyonBOT
#

DuckBot/helpers/paginator.py lines 256 to 258

async def on_error(self, error: Exception, item: discord.ui.Item, interaction: discord.Interaction) -> None:
    if interaction.user.id in self.ctx.bot.owner_ids:
        await self.ctx.reply('`​`​`​py' + ''.join(traceback.format_exception(etype=None, value=error, tb=error.__traceback__) + '\n`​`​`​'))```
pale zenith
#

thanks python bot :D

hollow agate
#

I don't have an on_error

pale zenith
#

make one, see if it catches an unexpected error that isnt handled

hollow agate
#

Where would I put it? sorry

pale zenith
#

inside your View class/subclass

slate swan
#

Can anyone help

pale zenith
#

like making drop-down menus?

slate swan
#

Yh

hollow agate
#
class HistoryView(discord.ui.View):
    def __init__(self, member: discord.Member = None):
        super().__init__(timeout=45)
        self.add_item(History(member))
    async def on_error(self, error: Exception, item: discord.ui.Item, interaction: discord.Interaction) -> None:
        if interaction.user.id in self.ctx.bot.owner_ids:
            await self.ctx.reply('`​`​`​py' + ''.join(traceback.format_exception(etype=None, value=error, tb=error.__traceback__) + '\n`​`​`​'))``` Should I indent the `async def on_error`?
pale zenith
slate swan
#

I using without cogs

hollow agate
#

Well, kinda... but it works differently

slate swan
pale zenith
slate swan
#

O

#

Btw I need to make an embed when reacted to an option I have this kind of sample@pale zenith

#

No one here?

covert igloo
#

i get the error local variable 'role' referenced before assignment when i run this

pale zenith
hollow agate
#
    async def on_error(self, error: Exception, item: discord.ui.Item, interaction: discord.Interaction) -> None:
        await self.ctx.reply('`​`​`​py' + ''.join(traceback.format_exception(etype=None, value=error, tb=error.__traceback__) + '\n`​`​`​'))``` What do I replace ctx with? I'm so bad using self :P
pale zenith
#

uhm... interaction.response.send_message

hollow agate
#

Ah, thank you xd

pale zenith
hollow agate
#
    await interaction.response.send_message('`​`​`​py' + ''.join(traceback.format_exception(etype=None, value=error, tb=error._
_traceback__) + '\n`​`​`​'))
TypeError: can only concatenate list (not "str") to list```
hollow agate
#
class HistoryView(discord.ui.View):
    def __init__(self, member: discord.Member = None):
        super().__init__(timeout=45)
        self.add_item(History(member))
    async def on_error(self, error: Exception, item: discord.ui.Item, interaction: discord.Interaction) -> None:
        await interaction.response.send_message('`​`​`​py' + ''.join(traceback.format_exception(etype=None, value=error, tb=error.__traceback__) + '\n`​`​`​'))``` :P
pale zenith
covert igloo
#

so what do i need to change to stop getting the error

#

oh nvm fixewd it

pale zenith
slate swan
#

Kay

#

Hm

#

What should I do

#

😞

brisk fiber
#

!d traceback.format_exception

unkempt canyonBOT
#

traceback.format_exception(exc, /, [value, tb, ]limit=None, chain=True)```
Format a stack trace and the exception information. The arguments have the same meaning as the corresponding arguments to [`print_exception()`](https://docs.python.org/3/library/traceback.html#traceback.print_exception "traceback.print_exception"). The return value is a list of strings, each ending in a newline and some containing internal newlines. When these lines are concatenated and printed, exactly the same text is printed as does [`print_exception()`](https://docs.python.org/3/library/traceback.html#traceback.print_exception "traceback.print_exception").

Changed in version 3.5: The *etype* argument is ignored and inferred from the type of *value*.

Changed in version 3.10: This function’s behavior and signature were modified to match [`print_exception()`](https://docs.python.org/3/library/traceback.html#traceback.print_exception "traceback.print_exception").
brisk fiber
#

ah i see

hollow agate
#

I'm just using an error handler I was told to use :P

#

So I have no clue xd

boreal ravine
#

:P?

pale zenith
#

hypixel_tongue_put but :P

slate swan
#

Hm

hollow agate
#
class HistoryView(discord.ui.View):
    def __init__(self, member: discord.Member = None):
        super().__init__(timeout=45)
        self.add_item(History(member))
    async def on_error(self, error: Exception, item: discord.ui.Item, interaction: discord.Interaction) -> None:
        await self.ctx.reply('`​`​`​py' + ''.join(traceback.format_exception(etype=None, value=error, tb=error.__traceback__) + '\n`​`​`​'))``` @pale zenith how would I pass ctx? I wanna see if that'll work
boreal ravine
#

i dont think u can use ctx lol

pale zenith
hollow agate
#
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'HistoryView' object is not callable ```
#

The command and dropdown works, but it gives me an error which is weird

pale zenith
#

what -

#

what line is the error at?

hollow agate
#

The new one or the older one?

boreal linden
#

how can i make it so when the bot restarted, the reaction role button will still works?

boreal linden
hollow agate
boreal linden
hollow agate
#

Are you using reactions or buttons?

maiden fable
#

Wait, u mean using events?

boreal linden
maiden fable
#

Ah, nvm. Buttons

hollow agate
#

Send me your code

boreal linden
maiden fable
#

U can use persistent views

hollow agate
maiden fable
pliant gulch
#

bouta implement commands to my wrapper before I even finish all the models

#

😔 got the parser running

hollow agate
pale zenith
#

like, which line does that error that popped up at last is raised

#

the one where says ... is not callable

hollow agate
#
    await ctx.channel.send(embed=embed, view=view(ctx=ctx, member=member))
TypeError: 'HistoryView' object is not callable```
pale zenith
#

oh

#

view=view()

boreal linden
#

nvm, i figured out

pale zenith
#

when youre creating the class you need to

#

here pass your ctx

#

not in view=view

#

@hollow agate ^

hollow agate
#
AttributeError: 'Context' object has no attribute 'id'```
maiden fable
#

And after doing this, u r calling view again, which raises that error

#

Breh, my net

pale zenith
#

or you can make it a kwarg, like ctx=ctx

hollow agate
#

Uhhh

#

I'm confused on what you're trying to do now

pale zenith
hollow agate
#

No like, what is the end goal?

#

Everything works, but an error happens in the process

pale zenith
#

which is context has no attribute id?

#

right?

hollow agate
#
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction``` this error
#
class History(discord.ui.Select):
    def __init__(self, member: discord.Member = None):
        self.member = member
        options = [
            discord.SelectOption(emoji='1️⃣', label='Warns'),
            discord.SelectOption(emoji='2️⃣', label='Mutes'),
            discord.SelectOption(emoji='3️⃣', label='Bans'),
            discord.SelectOption(emoji='4️⃣', label='Kicks')
        ]
        super().__init__(placeholder='How may I help?', min_values=1, max_values=1, options=options, custom_id="pp1")

    async def callback(self, interaction: discord.Interaction):
        channel = interaction.guild.get_channel(interaction.channel)
        if self.values[0] == 'Warns':
            db = await aiosqlite.connect('database.db')
            cursor = await db.execute('SELECT * FROM warns WHERE user_ids=?', (self.member.id,))
            rows = await cursor.fetchall()
            await db.close()
            embed = discord.Embed(
                title=f"Warns",
                color=discord.Color.red())
            for row in rows:
                embed.add_field(name=f"Case {row[2]}", value=row[1])
            await interaction.channel.send(embed=embed)
            return
        if self.values[0] == 'Mutes':
            await interaction.channel.send(f'Currently Not Available!')
        if self.values[0] == 'Bans':
            await interaction.channel.send(f'Currently Not Available!', ephemeral=True)
        if self.values[0] == 'Kicks':
            await interaction.channel.send(f'Currently Not Available!', ephemeral=True)

class HistoryView(discord.ui.View):
    def __init__(self, member: discord.Member = None):
        super().__init__(timeout=45)
        self.add_item(History(member))

client = PersistentViewBot()
client.remove_command('help')

@client.command()
@commands.has_permissions(administrator=True)
async def history(ctx: commands.Context, member: discord.Member = None):
    if member == None:
        a = await ctx.reply("You can't see the history of nobody!")
        await asyncio.sleep(5)
        await ctx.message.delete()
        await a.delete()
        return
    else:
        view = HistoryView(member)
        embed = discord.Embed(
            title=f"History of {member}",
            description=
            f"Choose the type of history you would like to view!",
            color=discord.Color.purple())
        await ctx.channel.send(embed=embed, view=view)
        await ctx.message.delete()```
#

Removing the member stuff, breaks everything.

pale zenith
#

right we got very off topic. but the end goal was for you to have an on_error inside your HistoryView so you could see what was causing Unknown Interaction

hollow agate
#

Yes. So do I do what you just asked me to do... or?

#

It'll throw me way too many errors for it to be even helpful because I need member for it to work the database.

#

Oh my wait

pale zenith
#

the end goal was to have something like this so you could see if there were any unexpected errors:

class HistoryView(discord.ui.View):
    def __init__(self, member: discord.Member = None):
        super().__init__(timeout=45)
        self.add_item(History(member))

    def on_error(self, error, interaction):
        await interaction.channel.send('`​`​`​py\n' + ''.join(traceback.format_exception(etype=None, value=error, tb=error.__traceback__)) + '\n`​`​`​')

# then in your command
view = HistoryView(member)
hollow agate
#

I had two bot instances running, that's probably it

pale zenith
#

oh? 👀 blobsweatsip

hollow agate
#
class History(discord.ui.Select):
    def __init__(self, member: discord.Member = None):
        self.member = member
        options = [
            discord.SelectOption(emoji='1️⃣', label='Warns'),
            discord.SelectOption(emoji='2️⃣', label='Mutes'),
            discord.SelectOption(emoji='3️⃣', label='Bans'),
            discord.SelectOption(emoji='4️⃣', label='Kicks')
        ]
        super().__init__(placeholder='How may I help?', min_values=1, max_values=1, options=options, custom_id="pp1")

    async def callback(self, interaction: discord.Interaction):
        channel = interaction.guild.get_channel(interaction.channel)
        if self.values[0] == 'Warns':
            db = await aiosqlite.connect('database.db')
            cursor = await db.execute('SELECT * FROM warns WHERE user_ids=?', (self.member.id,))
            rows = await cursor.fetchall()
            await db.close()
            embed = discord.Embed(
                title=f"Warns",
                color=discord.Color.red())
            for row in rows:
                embed.add_field(name=f"Case {row[2]}", value=row[1])
            await interaction.channel.send(embed=embed)
            return
        if self.values[0] == 'Mutes':
            await interaction.channel.send(f'Currently Not Available!')
        if self.values[0] == 'Bans':
            await interaction.channel.send(f'Currently Not Available!', ephemeral=True)
        if self.values[0] == 'Kicks':
            await interaction.channel.send(f'Currently Not Available!', ephemeral=True)

class HistoryView(discord.ui.View):
    def __init__(self, member: discord.Member = None):
        super().__init__(timeout=45)
        self.add_item(History(member))

client = PersistentViewBot()
client.remove_command('help')

@client.command()
@commands.has_permissions(administrator=True)
async def history(ctx: commands.Context, member: discord.Member = None):
    if member == None:
        a = await ctx.reply("You can't see the history of nobody!")
        await asyncio.sleep(5)
        await ctx.message.delete()
        await a.delete()
        return
    else:
        view = HistoryView(member)
        embed = discord.Embed(
            title=f"History of {member}",
            description=
            f"Choose the type of history you would like to view!",
            color=discord.Color.purple())
        await ctx.channel.send(embed=embed, view=view)
        await ctx.message.delete()``` Doesn't throw me an error anymore
pale zenith
hollow agate
#
    async def callback(self, interaction: discord.Interaction):
        channel = interaction.guild.get_channel(interaction.channel)
        if self.values[0] == 'Warns':
            db = await aiosqlite.connect('database.db')
            cursor = await db.execute('SELECT * FROM warns WHERE user_ids=?', (self.member.id,))
            rows = await cursor.fetchall()
            await db.close()
            embed = discord.Embed(
                title=f"Warns",
                color=discord.Color.red())
            for row in rows:
                embed.add_field(name=f"Case {row[2]}", value=row[1])
            await interaction.edit_original_message(embed=embed)``` When I add edit_original_messgage it says ```py
    raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10015): Unknown Webhook```/doesn't work
#

Using interaction.channel.send works.

pale zenith
#

there's interaction.response.edit_message

hollow agate
#

Thank you, that worked!

#

Now I'm going to go take a break... my brains wants to rgbexplosion

sullen shoal
#

why not just use a loop

#

it will look cleaner

hollow agate
sullen shoal
#

oh

slate swan
#

uhm..how would I make a cooldown error handle display the time you have left in minutes or hours or even days ??

boreal ravine
#

!pypi humanize

unkempt canyonBOT
boreal ravine
#

you can use that lib to convert the time needed left to run the command

slate swan
#

I SEE

#

I shall try this

crystal wind
#

Hey, I was wondering if there's a way to clear out this notification every time there's an argument error when a command is being invoked.

unkempt canyonBOT
#
Nuh-uh.

No documentation found for the requested symbol.

crystal wind
#

my code looks like this

maiden fable
#

Uhhh, what

maiden fable
crystal wind
#

I removed the insertion of the embed message.

slate swan
#

yes it gives output as seconds

maiden fable
slate swan
#

yes but I need it to be minutes or hours ¯_(ツ)_/¯

crystal wind
#

What's supposed to do is that if you do !howsus without any arguments, it would just send an embed of how sus the author of the command sender is.

maiden fable
slate swan
#

I tried it dosent give output

maiden fable
#

Wym

slate swan
#

it dosent ive error

#

but it also dosent send any output

boreal ravine
#

didnt i give the module

#

to do that earlier

#

it does what u want but more simple

slate swan
#

yes

#

im trying that rn 🙂

crystal wind
#

i assume you can't

#

ok.

calm vortex
slate swan
#

hey guys, does anyone know how i would be able to use a check inside a command instead of using it as a decorator?

pale zenith
# crystal wind i assume you can't

you could make member an optional field, then make it so if theres no member, the member is the author

@bot.command
async def howsus(ctx, member: discord.Member = None):
    member = member or ctx.author
    # check how sus

``` No need to handle that in a local error handler
slate swan
boreal ravine
#

idk how to make a check without an @ tho

crystal wind
slate swan
#

ah ok, that isnt possible

crystal wind
#

I just wanted to clear those error messages on my console, although idk how to prevent it

boreal ravine
slate swan
#

so this whole time

#

ive wasted my time making a function

#

to convert seconds to those units

pale zenith
crystal wind
#

We can do that inside a {}?

pale zenith
#

yeah

#

wait no

crystal wind
#

ooooh that makes more sense and way easier

pale zenith
#

you cant have \

lusty swallow
#

yeah

calm vortex
crystal wind
#

yes you can have ' inside a string

#

if it's backslash pretty sure

slate swan
lusty swallow
#

use f"""{member.name + ' is' if member != ctx.author else "you're"} {number} percent sus"""

slate swan
#

still if i knew that at the start id use it

crystal wind
#

ooh

calm vortex
#

humanize can convert bytes to mb, gb etc. and more stuff

slate swan
#

ah nice

pale zenith
crystal wind
#

oooh okok

lusty swallow
#
var = member.name + ' is' if member != ctx.author else "you're"
f"{var} {number} percent sus"
```this is better
calm vortex
pale zenith
slate swan
#

yeah but if i have to use naturaltime id use humanize

crystal wind
#

aaaah

#

thanks imma try it out

boreal ravine
tawdry perch
boreal ravine
calm vortex
boreal ravine
calm vortex
tawdry perch
#

._. I have always used a convert with bunch of if statement

boreal ravine
#

that still works

unkempt canyonBOT
#

MyBot/cogs/moderation/admins.py lines 101 to 114

if time is None:
    time = apply_time + timedelta(hours=1)
else:
    if 'm' in new_time:
        convert = int(new_time[:-1])
        time = apply_time + timedelta(minutes=convert)
    elif 'h' in new_time:
        convert = int(time[:-1])
        time = apply_time + timedelta(hours=convert)
    elif 'd' in new_time:
        convert = int(time[:-1])
        time = apply_time + timedelta(days=convert)
    else:
        time = apply_time + timedelta(hours=1)```
tawdry perch
#

What? Why did it send it?

calm vortex
#

A feature of the bot

boreal ravine
tawdry perch
#

I see, I thought it is only for the bots source

tawdry perch
pliant gulch
#

Heres how I do mine

#

You don't need a bunch of if statements you can just make a time mapping

tawdry perch
#

I'll take look

#

Class about to start bye

calm vortex
#

I wrote this for converting something like 2h 3m 40s to just seconds

def cts(self, string):
  def divide_list(l, n):
   return [l[a:b] for a, b in [(a, b) for a, b in zip(range(0, len(l), n), range(n, len(l) + n, n))]]
  string = string.lower()
  numbers = [n for n in re.findall(r"\d", string) if n]
  words = [w.strip().lower()[0] for w in re.findall(r"\D", string) if w]
  if [w for w in words if not w in ["s", "m", "h", "d"]]: return False
  if not len(numbers) == len(words): return False
  formatted_list = []
  for t in zip(numbers, words):
   formatted_list.append(t[0])
   formatted_list.append(t[1])
  formatted_list = divide_list(formatted_list, 2)
  cv = {"s": 1, "m": 60, "h": 3600, "d": 86400}
  return sum([int(x[0]) * int(cv[x[1]]) for x in formatted_list])
#

I don't know much regex

final iron
#

Smart to use regex

pliant gulch
#

pretty pog, got commands working on my wrapper

slate swan
#

Heloo

#

I need a help in a code it shows error

boreal ravine
#

sure

#

what is it

slate swan
#

What's the error Here?

#

Also pls check #bot-commands

#

See this@boreal ravine

boreal ravine
#

hm

#

can u edit select menus tho

slate swan
#

What?

pliant gulch
#

If you look at lefi/ws/wsclient.py there is a method read_messages of WebSocketClient. Which is really just an overhead to handle the internal websocket which is under the attribute ws. The read_messages method actually receives the events then dispatches it to parsers in state.py. You're gonna want to use aiohttp.ClientSession.ws_connect(url), here url being the url you receive after calling the /gateway/bot endpoint in the API. Keep in mind after connecting to the websocket you will need to keep it alive, first send an identify, then start the heartbeat loop. All of this can be seen in the code

slate swan
boreal ravine
#

u tried editing a select menu? idk if u can

slate swan
#

Yh

slate swan
#

But that error

boreal ravine
#

@slate swan try removing await

slate swan
boreal ravine
#

wait wheres ur code

slate swan
#
@client.command()
async def option(ctx):
    await ctx.send(
        "This message has a select menu!",
        components=[
            SelectMenu(
                custom_id="test",
                placeholder="Choose up to 2 options",max_values=1,
              options=[
SelectOption(
  label = "Option 1", 
  value =  "value 1"),

SelectOption(
  label = "Option 2", 
  value = "value 2"),
                    
SelectOption(
  label = "Option 3", 
  value = "value 3")
                ]
            )
        ]
    )

e1 = Embed(title="embed1", description="a really exciting embed")
e2 = Embed(title="embed2", description="a really exciting embed")
e3 = Embed(title="embed3", description="a really exciting embed")

while True:
  try:
    event=await self.client.wait_for("select_option" , check=None)
    label = event.component[0].label

    if label == "Option 1":
      await event.edit(
        ephemeral = False,
        embed=e1
        )
    
    
    elif label == "Option 2":
      await event.edit(
        ephemeral = False, 
        embed=e2
      )

    elif label ==  "Option 2":
      await event.edit(
        ephemeral = False, 
        embed=e3
      )
  except discord.NotFound:
   print("error")
#

Here

boreal ravine
#

why self tho

slate swan
#

Oh sry

#

My mistake

#

Didn't remove it

#

i cant install psutil.. (i had it installed) but since i reinstalled python it gives an error while installing it

#
ERROR: Command errored out with exit status 1: 'C:\Users\Krzx\AppData\Local\Programs\Python\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Krzx\\AppData\\Local\\Temp\\pip-req-build-xnj3dbkw\\setup.py'"'"'; __file__='"'"'C:\\Users\\Krzx\\AppData\\Local\\Temp\\pip-req-build-xnj3dbkw\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Krzx\AppData\Local\Temp\pip-record-b4jci4hd\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Krzx\AppData\Local\Programs\Python\Python310\Include\psutil' Check the logs for full command output```
#

(error is too big to send full thing)

#

import discord from discord.ext import commands from env import load_env from os import getenv load_env()

i want to store token how to do that it throws error

slate swan
slate swan
#

load_dotenv()

#

also make sure you did pip install python-dotenv

#

but that file name should be .env then right?

#

@slate swan

#

yes

slate swan
#

that's bc replit stores then somewhere else

#

why even use replit

slate swan
#

🥲

#

.

#

either get an actual VPS or if your bot's really really small then use heroku

#

is there no way i can do it in repl?....

#

you can

#

how

#

it should work the same way

#

only that u don't have to do the load_dotenv

#

@slate swan

#

Error says it all

boreal ravine
#

or use replit's new key syste

slate swan
#

¯_(ツ)_/¯

#

how do i fix it :/

#

Just read

#

i am dumb help me when 🥲

#

If you know the very very very very basics of Python you know how to fix

slate swan
#

If you never learned Python consider learning it before making a bot

slate swan
#

... the error is just...

lament mesa
#

Is it possible to get the Invite a user used to join a guild?

slate swan
#

They even give a fix KEKW

#

we need AI to solve that error

#

😳 so tough

slate swan
slate swan
lament mesa
slate swan
#

ig the guy is following python 2

#

💀

#

:>

#

my print has parenthesis after it

#

😳 show the code also pls

slate swan
# slate swan 😳 show the code also pls

`import discord
from discord.ext import commands
from env import load_env
from os import getenv
load_env()

client = commands.Bot(command_prefix=".")

@client.event
async def on_ready():
print("Bot is Ready")

@client.command()
async def hello(ctx):
await ctx.reply("Hello")

@client.command()
async def add(ctx, numb1:int, numb2:int):
await ctx.reply(numb1+numb2)

@client.command()
async def multiply(ctx, numb1:int, numb2:int):
await ctx.reply(numb1*numb2)

@client.command()
async def divide(ctx, numb1:int, numb2:int):
await ctx.reply(numb1/numb2)

client.run(getenv('TOKEN'))`

#

... i don't seem to find print anywhere

#

also. next time use

#

lmao what tf is the error then

#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

slate swan
#

bruh

#

@slate swan

#

it is in your env.py file

#

😂

gloomy quest
#

how to make an event that if anyone messages in a certain channel then the bot will reply Hi to it

slate swan
#

use on_message

gloomy quest
#

how to check the channel id

slate swan
#

message.channel.id

#

message.channel.id

slate swan
gloomy quest
#

k

slate swan
gloomy quest
#

thx

slate swan
slate swan
slate swan
#

your file is .py

#

env files have .env extension

#

💀

#

No pretty sure that's the library

#

💀 i bet; he himself doesn't know what he is doing

#

Yeah this indeed is true

slate swan
#

🥲 feel free to ask for help, but don't go for dpy without knowing basic py

gloomy quest
#

In the on_message event

#

I tried keeping ctx.reply

slate swan
#

...

gloomy quest
#

But it says ctx is undefined

slate swan
#

u dont' do ctx.reply

gloomy quest
#

then wut do i do

slate swan
#

do message.reply

gloomy quest
#

ohk

#

thxx

slate swan
#

tias, (me not really sure, lol)

gloomy quest
#

ARGH THE TIMER

#
if message.channel.id !== "896472063496298496":
    return
#

It says invalid syntax

slate swan
#

...

#

wtf is !== 💀

#

maybe u wanna do !=

gloomy quest
#

not =

#

o h

slate swan
slate swan
gloomy quest
#
@client.event
async def on_message(message):
  if message.channel.id != "896472063496298496":
    return
  else:
    embed = discord.Embed(title="Hi", description=
    "This a  test", color=0x1dddee)
    await message.reply(embed=embed)
#

nothing happens

novel rampart
#

how will i get all roles of the ctx user

gloomy quest
#

when I send a message in the specified channel

covert quest
#

dm me if somebody can make me a website

novel rampart
slate swan
novel rampart
lament mesa
gloomy quest
slate swan
novel rampart
gloomy quest
slate swan
gloomy quest
#

no see im returning it

#

if its not= channel id
return

slate swan
#

and you've used != i.e. it won't do anytihng if u message there

gloomy quest
#

yeah but i kept else: after it

slate swan
#

...

visual island
slate swan
gloomy quest
#

ohhh

#

OH NO

#

THE BOT IS REPLYING TO ITSELF IN A LOOP

slate swan
#

and return it

gloomy quest
#

kkkk

novel rampart
#

in this code

slate swan
#

would anyone here know how to make a command that when it's run, shows the current server member count? kinda like the server stats bot but in chat command form?

lament mesa
slate swan
novel rampart
#

@lament mesa this is the error

#
 roles = [role.mention for role in ctx.author.roles.mention]
lament mesa
slate swan
novel rampart
slate swan
novel rampart
#

and that roles want to mention also

lament mesa
novel rampart
#

that is i added mention

novel rampart
opaque seal
#

Hi! I am trying to host my bot in heroku but import cv2 causing error .This I got to know by logs

#

I am able to start the resource

#

but the bot is inactive due to crash by cv2 import

slate swan
#

gg; you got to know by logs; then send logs here

opaque seal
#

ok

slate swan
#

so that we know what is causing the error

opaque seal
#

okay

gloomy quest
#

It still keeps looping for 5 time

slate swan
#

or u did some mistake while doing it?

gloomy quest
#

if message.author == client:
return

opaque seal
slate swan
#

🙂

#

not client

gloomy quest
#

ohk

slate swan
#

ig (not sure)

#

Just ignore all bots, so a simple if message.author.bot

slate swan
#

?

opaque seal
#

yes

slate swan
#

send requirements.txt for a second

opaque seal
#

opencv-python

slate swan
# slate swan a "chat command" is just like a "normal command" or a "commnd" 🙂

yeah but how would I do it?


@bot.command(name='roll',help='rickrolles someone')
async def roll(ctx):
    print('someone just got rolled')
    content = ('you just got rolled! https://www.youtube.com/watch?v=dQw4w9WgXcQ')
    print('roll was used, so I replied with',content)
    await ctx.send(content)

this is what I currently use as a command handler, would I just need to change content out for the member count thing you said earlier?

#

Nice

#

damn it didn't format

#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

opaque seal
slate swan
#

🙂

novel rampart
unkempt canyonBOT
#

Hey @opaque seal!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

novel rampart
slate swan
visual island
slate swan
#

i don't have much idea on opencv

lament mesa
opaque seal
novel rampart
slate swan
slate swan
lament mesa
slate swan
slate swan
#

!bin

#

!bins

lament mesa
slate swan
#

ok nvm

slate swan
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

novel rampart
slate swan
#

gg

slate swan
#

You need to loop trough the roles object

opaque seal
slate swan
#

idk i don't have much idea on openv

novel rampart
slate swan
#

No

lament mesa
#

no

novel rampart
#

then

slate swan
#

in the last part

slate swan
#

l a s t

#

and we're just putting it on him

novel rampart
#
roles = [role.mention for role in ctx.author.roles].mention
#

like this

slate swan
#

remove it

slate swan
#

you remove last .mention

#

content is by default a parameter in send

#

And consider learning python

novel rampart
#
roles = [role.mention for role in ctx.author.roles]
slate swan
#

because you don't know what you're doing

opaque seal
slate swan
#

yes lmao

#

imma do some testing

novel rampart
slate swan
#

😳

slate swan
#

it's not hard to learn

#

it's called "list comprehension"

#

!resources

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

slate swan
#

:p

lament mesa
#

subclass list and add a mention property

visual island
slate swan
#

XD

lament mesa
visual island
lament mesa
#

no

#

maybe can use some ctypes and make [] to use the custom list

stone palm
#

does anyone know how to use on_timeout

#

in views

#

;-;

visual island
radiant shadow
#

^_^

cinder horizon
#

how do i get my bot to list all the servers its in...if possible the names too rather than only ids

slate swan
cinder horizon
#

peace

stiff nexus
#

help??```py
@commands.command()
async def nuke(self, ctx, channel: discord.TextChannel = None):
"""Clones a channel and deletes the older one"""
channel = channel or ctx.channel
new_channel = await channel.clone(reason=f"Action performed by {ctx.author} ({ctx.author.id})")
await channel.delete()
await new_channel.send(f"{utily.done} Successfully Nuked this channel by {ctx.author}")

slate swan
#

but ig, it's not possible to arrange

#

💀

#

Is there any way to make a command that completely deletes every message in a channel when used?

slate swan
#

or make purge command

#

I need a purge command

#

then code it ;'/

#

How

slate swan
#

pycord or discord.py.. whatever u use.. just read docs

slate swan
slate swan
#

command

#
  • nuke command has its own pros & cons
#

Ik, it's a nuker right?

#

yes

#

Good enough

#

i hope u will try to understand it rather than copy pasting

#

gg

#

I mean I understand what it does and kinda how it does it

#

Just not well enough to write it myself

#

...

#

alr

#

Plus im also just lazy

stiff nexus
slate swan
#

The code

stiff nexus
slate swan
#

oo i see

stiff nexus
slate swan
slate swan
#

Lol

stiff nexus
#

but it wont work

slate swan
#

we can get the position* of the channel

#

then we create new channel & move it to the position*

#

🤔

lilac latch
#
async def game(ctx, *, message):
  if ctx.author.id in [738609666505834517,840411506646319124,827123687055949824]:
     await client.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=message)
  else:
     titld = "You don't have permissions?"
     main = "The command you tried to use can be used only be used by the developer and people whom he gave access to. You are not allowed to use it"
     embedVar = disnake.Embed(title=titld, description=main, color=bot_embed_color)
     await ctx.send(embed=embedVar)```
#

Can someone tell me what's wrong in this?

tawdry perch
#

can you tell us?

lilac latch
tawdry perch
lilac latch
#
    else:
    ^
SyntaxError: invalid syntax
 ```
#

I can't understand how it's wrong

tawdry perch
#

There is a weird character?

hasty iron
#

missing ) in the line before

tawdry perch
#

Oh

lilac latch
hasty iron
#

what?

slate swan
#
  if ctx.author.id in [738609666505834517,840411506646319124,827123687055949824]:
     await client.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=message))
lilac latch
#

Oooooooooo

hasty iron
#

wow nice spoonfeed

slate swan
thick sigil
lilac latch
hasty iron
#

and you didn’t understand a "missing )"

lilac latch
#

Hhhhelpppppppppppp

tawdry perch
#

can you show what you have atm?

lilac latch
tawdry perch
#

the code, can you show it?

lilac latch
# tawdry perch the code, can you show it?
async def game(ctx, *, message):
  if ctx.author.id in [738609666505834517,840411506646319124,827123687055949824]:
     await Yui.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name=message))
  else:
     titld = "You don't have permissions?"
     main = "The command you tried to use can be used only be used by the developer and people whom he gave access to. You are not allowed to use it"
     embedVar = disnake.Embed(title=titld, description=main, color=bot_embed_color)
     await ctx.send(embed=embedVar)```
tawdry perch
#

are you sure there is a activity called playing?

lilac latch
#

I used it earlier

tawdry perch
#

did it work?

lilac latch
slate swan
#

Why is it even disnake.Embed but discord.Activity

tawdry perch
#

probably using disnake

lilac latch
#

Issue found

slate swan
#

Why is it different though

lilac latch
#

LOLLLLLLLLLLL

tawdry perch
#

lol?

slate swan
#

Why not just one

tawdry perch
slate swan
#

Either everything disnake. or discord.

tawdry perch
#

and dpy is no longer supported

lilac latch
slate swan
#

It's just confusing

lilac latch
tawdry perch
#

it's a different package so it makes sense

lilac latch
#

Anyways it worked

#

Thanks

maiden fable
slate swan
#

Yeah makes more sense

maiden fable
#

That's what most people use

#

As long as they ain't rewriting their whole bot

tawdry perch
tawdry perch
#

don't mind me

maiden fable
tawdry perch
#

good

maiden fable
# lilac latch loll

Facts. I was also lazy to change my imports but I am rewriting my bot nowadays, so I am okay with changing all the imports to disnake since it doesn't conflict with discord.py package :D

tawdry perch
#

rewriting sound painful to do

visual island
#

I like how everyone are changing to disnake potato_popcorn

reef shell
#

edpy

tawdry perch
#

I'm still staying with dpy

slate swan
#

I switched language

tawdry perch
#

evil choice

slate swan
#

Nope

reef shell
#

Not bad choice

slate swan
#

Can't be arsed to wait for updates and use forks

maiden fable
#

Hehe well I am also learnig JS to make my website. And gotta say canvas sucks

slate swan
#

XD

hasty iron
slate swan
maiden fable
#

😂

hasty iron
#

very funny joke

slate swan
#

Indeed

storm sluice
tawdry perch
#

you did not install smth I guess @storm sluice

slate swan
#

That's a nice guess x)

boreal ravine
#

can u await a list tho

slate swan
#

premium_subscribers is an attribute, not a method and you therefore don't need to await it and don't need to have ()

#

Also consider not naming your variable list as this is kind of a reserved keyword of Python

#

And you don't need user = boosters.user

#

As the elements in the list is already of type Member

#

So you can directly use the attributes of it

#

Such as boosters.name, etc.

slate swan
#

Once again I need help a small line in my code

#

Select menus

storm sluice
tawdry perch
#

¯\_(ツ)_/¯

boreal ravine
#

Read ur code it says where the error is and what you need to install

#

sure

slate swan
#

We don't teach you, there are enough tutorials around

#

We help you with your errors

boreal ravine
#

we dont teach people how to make a working bot, people teach us

hasty iron
#

then make it work

boreal ravine
#

Make the bot first > Code it > If theres errors ask people

hasty iron
#

sad

boreal ravine
#

why u cant

hasty iron
#

ok, so how are we supposed to help when you sent nothing for us to work with

tawdry perch
#

Totally new? No experience with python?

#

Please learn Python first, you will do a favor for yourself

urban sphinx
#
@client.command()
@commands.has_permissions(manage_messages = True)
async def log(ctx, content):
        guild = ctx.guild
        c_id = str(content[2:-1])
        channelbruh = client.get_channel(c_id)
        channelid = channelbruh
        with open('logs.json', 'r') as f:
            logs = json.load(f)
 
        logs[str(guild.id)] = channelid

        with open('logs.json', 'w') as f:
            json.dump(logs, f, indent=4)
        
        await ctx.send("added")

it just does null https://shit-dev.me/​​‌‎​​‍‌​‏​‍​‎​​‎‏‎​‏​​‍​‎​‏‎‌​‎‎​‌‎​‌​‍

tiny.rip

uploaded by Leimag at 11/10/2021 11:25:18 AM

slate swan
#

Is it possible to check when specified members got offline and got online with a discord bot?

urban sphinx
#

wdym?

#

??

slate swan
grim oar
#

guild.get_channel gets channel from cache too

slate swan
#

But from the guild itself

urban sphinx
#

still prints out none

slate swan
#

Which has more chances to be cached than all the bot's channels

slate swan
urban sphinx
#

channelbruh = guild.fetch_channel(c_id)?

#

like that yeah?

slate swan
#

No, client.

vocal plover
#

fetch_channel is an async function, so it needs to be awaited too

slate swan
#

But only use if it's None

#

You shouldn't always make API calls

vocal plover
#

a simple one-line solution would be channel = client.get_channel(id) or await channel.fetch_channel(id)

junior verge
#

What is wrong here?

cloud dawn
#

em is not indented

vocal plover
#

the line where you wrote em = isnt indented far enough

gloomy quest
#

hey

#

whenever i do events my cmds dont work

#

what to do

vocal plover
#

use @bot.listen() rather than @bot.event

gloomy quest
#

oo

#

ok thx

#

WORKED

junior verge
#

Yeah saw that

#

Now, my bot just works. But the cogs are not working at all

urban sphinx
#

i want the channel id not the name it just prints out ze name

junior verge
#

@vocal plover How would I fix that or got any idea?

#

My cogs are not not doing anything al all.

vocal plover
#

This sounds obvious, but have you loaded them?

#

ive forgot a bunch of times and it makes me feel so dumb lol

junior verge
#
@client.command()
async def load(ctx, extension):
    client.load_extension(f'cogs.{extension}')

@client.command()
async def unload(ctx, extension):
    client.unload_extension(f'cogs.{extension}')

for filename in os.listdir('./cogs'):
    if filename.endswith('.py'):
        client.load_extension(f'cogs.{filename[:-3]}')
``` @vocal plover Isn't this right?
vocal plover
#

hm should be

junior verge
glad thicket
#

hello

junior verge
vocal plover
#

no clue sorry

glad thicket
junior verge
#

Well, my cogs are just not doing anything at all.

glad thicket
#

what kind of bot are you making?

junior verge
#

I already have a bot I was just trying to get cogs to work

#

Because that would be way easier

#

Any clue @glad thicket

glad thicket
#

hmm wait one sec

junior verge
#

Okay

glad thicket
#

no clue... sorry

junior verge
#

Weird

gloomy quest
#

How to make an or in an on_message client.listen?

#

ok i didnt explain nicely

#

but like

#
async def on_message(message):
  if message.author == client.user:
    return
  else:
   if message.channel.id == int(896472063496298496):
     await message.reply("Thanks for advertising in Nebula advertising!")
   else:
     return```
#

how to make two channels

#

Ok i really cant explain what im trying to say

junior verge
#
        @client.command()
        async def on_message(self, message):
            if message.author == self.client.user:
                return
            else:
                guild = self.client.get_guild(867086205182017536)
                channels = await guild.fetch_channels()
                channel = discord.utils.get(channels, name = str(message.author.id))


                if channel is None:
                    category = discord.utils.get(guild.categories, name = "Tickets")
                    channel = await guild.create_text_channel((message.author.name),category = category)
                    await message.author.send("Modmail has been created succesfully")
                    em = discord.Embed(
                        title = f"{message.author.name}#{message.author.discriminator} created a modmail",
                        description = {message.content},
                        timestamp = datetime.utcnow(),
                        color = discord.Color.dark_blue()
                    )
                    await channel.send(embed = em)

                else:
                    em = discord.Embed(
                        title = f"{message.author.name}#{message.author.discriminator}",
                        description = {message.content},
                        timestamp = datetime.utcnow(),
                        color = discord.Color.dark_blue()
                    )
                    await channel.send(embed = em)
``` What is wrong with this
#

would this be event?

gloomy quest
#

yeh

junior verge
tawdry perch
#

indent

junior verge
#

Yeah but which one

gloomy quest
tawdry perch
#

I guess you need to indent everything after that line

junior verge
#

ah ye

gloomy quest
#

yeh

#

u need to indent everything after that

junior verge
#

yeah

#

shift tab right

tawdry perch
#

are you on cogs, or why is there so big indent?

junior verge
#

My cogs don't work or sum

#

So I just moved my cog code to my main file

tawdry perch
#

ooh that's why

junior verge
#

yeah

tawdry perch
#

cogs are really useful to be used

junior verge
#

I know

#

But it just doesn't work

#

Like my code runs but my cogs don't respond at all

tawdry perch
#

there may be a logic error somewhere , or a missing 1-2 lines if you have a on_message event

junior verge
#

Should I try to use cogs though

#

I can show you

#

I got that code now in cogs

#

I got 2 cogs atm

junior verge
#

But they just don't respond at all

tawdry perch
#

Your bot has many commands that you want to spread into different category?

gloomy quest
#

nowadays python's been having some werird errors

junior verge
#

But like cogs don't work for me

#

all the commands I use in cogs just don't work, I don't even get a error

tawdry perch
#

do you know how to use them?

junior verge
#

Yeah

#

Well I think I do

boreal ravine
#

will len(bot.cogs) return the amount of cogs the bot has?

tawdry perch
junior verge
#

Should be

#
@client.command()
async def load(ctx, extension):
    client.load_extension(f'cogs.{extension}')

@client.command()
async def unload(ctx, extension):
    client.unload_extension(f'cogs.{extension}')

for filename in os.listdir('./cogs'):
    if filename.endswith('.py'):
        client.load_extension(f'cogs.{filename[:-3]}')

boreal ravine
#

maybe somethings wrong in ur file

junior verge
#
import discord
from discord.ext import commands
from datetime import datetime

class Member(commands.Cog):
    def __init__(self, client):
        self.client = client

        @commands.Cog.listener()
        async def on_message(self, message):
            if message.author == self.client.user:
                return
            else:
                guild = self.client.get_guild(867086205182017536)
                channels = await guild.fetch_channels()
                channel = discord.utils.get(channels, name = str(message.author.id))


                if channel is None:
                    category = discord.utils.get(guild.categories, name = "Tickets")
                    channel = await guild.create_text_channel((message.author.name),category = category)
                    await message.author.send("Modmail has been created succesfully")
                    em = discord.Embed(
                        title = f"{message.author.name}#{message.author.discriminator} created a modmail",
                        description = {message.content},
                        timestamp = datetime.utcnow(),
                        color = discord.Color.dark_blue()
                    )
                    await channel.send(embed = em)

                else:
                    em = discord.Embed(
                        title = f"{message.author.name}#{message.author.discriminator}",
                        description = {message.content},
                        timestamp = datetime.utcnow(),
                        color = discord.Color.dark_blue()
                    )
                    await channel.send(embed = em)

def setup(client):
    client.add_cog(Member(client))
#

and I got 1 more cog

boreal ravine
#

mm u need to unindent that

junior verge
#

wait should I use the .load command though?

boreal ravine
junior verge
#

Yea

vocal plover
#

quick side note, after your if message.author == self.client.user: you dont need an else: since you already return

junior verge
#

oh okay

#

@boreal ravine Got any idea why the cogs don't work?

tawdry perch
#

So you have some sort of fire tree like this? (just example)

junior verge
tawdry perch
#

you need a some sort of main file

junior verge
boreal ravine
# junior verge <@!656073353215344650> Got any idea why the cogs don't work?

Wrong Way: ```py
class Member(commands.Cog):
def init(self, client):
self.client = client

    @commands.command()
    async def ping(self, ctx):
      #code

def setup(client):
client.add_cog(Member(client))

Right Way:
```py
class Member(commands.Cog):
    def __init__(self, client):
        self.client = client

    @commands.command()
    async def ping(self, ctx):
          #code

def setup(client):
    client.add_cog(Member(client))
``` u did the `wrong way` btw
boreal ravine
#

in ur cog

junior verge
boreal ravine
#

yes

junior verge
#

I don't see a difference

tawdry perch
junior verge
#

Yea?

boreal ravine
tawdry perch
#

it needs to match the def __init__ indent

junior verge
#

oh

#

would that fix it?

tawdry perch
#

maybe

junior verge
#
import discord 
from discord.ext import commands
from datetime import datetime

class Mod(commands.Cog):
    def __init__(self, client):
        self.client = client

        @commands.Cog.listener()
        async def on_message(self, message):
            try:
                if ".close" in message.content:
                    pass
            
                else:
                    if str(message.channel.type) == "private":
                        return
                    else:
                        if message.author == self.client.user:
                            return
                        else:
                            user = await message.guild.fetch_member(int(message.channel.name))
                            emb = discord.Embed(
                                title = "Message from the staff team",
                                description = {message.content},
                                timestamp = datetime.utcnow(),
                                color = discord.Color.green()
                            )
                            await user.send(embed = emb)
            except Exception as e:
                print(e)
                pass

        @client.command()
        async def close(self, ctx):
             user = await ctx.guild.fetch_member(int(ctx.channel.name))
             await user.send("The modmail has been closed by the staff team")
             await ctx.channel.delete

def setup(client):
    client.add_cog(Mod(client))
``` This is my other cog
boreal ravine
#

ur making a command like a function, so it needs to be on the def __init__() indent line and not the self.bot indent line

junior verge
#

Yeah

#

I did the same thing for the other cog

boreal ravine
#

!e

class my_cog():
  def __init__(self, name):
    self.name = name

    def age(self, age:int):
      print("{self.name} is {age}")

cog = my_cog("kayle")
cog.age(5)
unkempt canyonBOT
#

@boreal ravine :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 9, in <module>
003 | AttributeError: 'my_cog' object has no attribute 'age'
boreal ravine
#

you did something like that ^

#

so it wont register into the class properly

junior verge
#

Mhm

#

How would I fix that?

boreal ravine
junior verge
#

uh I don't really get you in what way

boreal ravine
#

!e

class my_cog():
  def __init__(self, name):
    self.name = name

  def age(self, age:int):
    print(f"{self.name} is {age}")

cog = my_cog("kayle")
cog.age(5)
``` this is what I did to fix ur cog
unkempt canyonBOT
#

@boreal ravine :white_check_mark: Your eval job has completed with return code 0.

kayle is 5
boreal ravine
slate swan
#
import discord 
from discord.ext import commands
from datetime import datetime

class Mod(commands.Cog):
    def __init__(self, client):
        self.client = client

    @commands.Cog.listener()
    async def on_message(self, message):
        try:
            if ".close" in message.content:
                pass
        
            else:
                if str(message.channel.type) == "private":
                    return
                else:
                    if message.author == self.client.user:
                        return
                    else:
                        user = await message.guild.fetch_member(int(message.channel.name))
                        emb = discord.Embed(
                            title = "Message from the staff team",
                            description = {message.content},
                            timestamp = datetime.utcnow(),
                            color = discord.Color.green()
                        )
                        await user.send(embed = emb)
        except Exception as e:
            print(e)
            pass

    @commands.command()
    async def close(self, ctx):
            user = await ctx.guild.fetch_member(int(ctx.channel.name))
            await user.send("The modmail has been closed by the staff team")
            await ctx.channel.delete

def setup(client):
    client.add_cog(Mod(client))
#

This is how it should be

#

client.command can't be used in cogs

junior verge
#

Thanks

boreal ravine
#

oh yeah

junior verge
#
import discord
from discord.ext import commands
from datetime import datetime

class Member(commands.Cog):
    def __init__(self, client):
        self.client = client

        @commands.Cog.listener()
        async def on_message(self, message):
            if message.author == self.client.user:
                return
            else:
                guild = self.client.get_guild(867086205182017536)
                channels = await guild.fetch_channels()
                channel = discord.utils.get(channels, name = str(message.author.id))


                if channel is None:
                    category = discord.utils.get(guild.categories, name = "Tickets")
                    channel = await guild.create_text_channel((message.author.name),category = category)
                    await message.author.send("Modmail has been created succesfully")
                    em = discord.Embed(
                        title = f"{message.author.name}#{message.author.discriminator} created a modmail",
                        description = {message.content},
                        timestamp = datetime.utcnow(),
                        color = discord.Color.dark_blue()
                    )
                    await channel.send(embed = em)

                else:
                    em = discord.Embed(
                        title = f"{message.author.name}#{message.author.discriminator}",
                        description = {message.content},
                        timestamp = datetime.utcnow(),
                        color = discord.Color.dark_blue()
                    )
                    await channel.send(embed = em)

def setup(client):
    client.add_cog(Member(client))
``` @slate swan And this one?
tawdry perch
#

indent error

boreal ravine
#

it wont register into the class

#

^

junior verge
#

I just don't get how to change it sorry

slate swan
#

Let me do it wait

slate swan
#
import discord
from discord.ext import commands
from datetime import datetime

class Member(commands.Cog):
    def __init__(self, client):
        self.client = client

    @commands.Cog.listener()
    async def on_message(self, message):
        if message.author == self.client.user:
            return
        else:
            guild = self.client.get_guild(867086205182017536)
            channels = await guild.fetch_channels()
            channel = discord.utils.get(channels, name = str(message.author.id))


            if channel is None:
                category = discord.utils.get(guild.categories, name = "Tickets")
                channel = await guild.create_text_channel((message.author.name),category = category)
                await message.author.send("Modmail has been created succesfully")
                em = discord.Embed(
                    title = f"{message.author.name}#{message.author.discriminator} created a modmail",
                    description = {message.content},
                    timestamp = datetime.utcnow(),
                    color = discord.Color.dark_blue()
                )
                await channel.send(embed = em)

            else:
                em = discord.Embed(
                    title = f"{message.author.name}#{message.author.discriminator}",
                    description = {message.content},
                    timestamp = datetime.utcnow(),
                    color = discord.Color.dark_blue()
                )
                await channel.send(embed = em)

def setup(client):
    client.add_cog(Member(client))
tawdry perch
slate swan
#

All the things should be under

def __init__(self, client):
        self.client = client
slate swan
#

He is learning

boreal ravine
#

u are spoonfeeding tho

slate swan
#

Yeah but he is not gonna understand

boreal ravine
#

why not

slate swan
boreal ravine
#

we already told him to unindent

#

i gave him an example if u didnt see it

slate swan
slate swan
vocal plover
tawdry perch
#

vco, how long have you been making discord bots?

vocal plover
#

couple years

tawdry perch
#

I guess you have made a public bots as well

vocal plover
#

sometimes

tawdry perch
#

cool

vocal plover
#

I prefer not to generally

#

public bots means i go from being a developer to being tech support

#

private bots mean i get to power moderation in places like the gta online server

#

which is much more fun

tawdry perch
#

I did not think it that way

#

so you make bots to servers you are in, instead of making public ones

vocal plover
#

mostly yeah

#

I do have a public bot but its main use to me is testing things like sharding when I'm doing library development Kek

tawdry perch
#

oo, cool

slate swan
#

making a public moderation bot is real pain

vocal plover
#

In my eyes you can have a public mod bot or a good mod bot, pick one

#

The issue with public mods bots is that you can't trust people, which means you can't give them powerful tooling

#

things like regex can be exploited to catastrophically backtrack and crash your program

slate swan
#

yeah , also you need to be super careful while doing anything with the bot

tawdry perch
#

sometimes public bots are good, but depends on use case (and type of bot)

vocal plover
#

public bots can definitely be good, its just that a small subset of them (mod bots) struggle to be good and public because of the aforementioned issues

boreal ravine
#

MEE6's team

vocal plover
#

the ideal thing for a mod bot is kinda semi public, bots like zeppelin for example, because you have motovation and help to build them from your users, but you only let select people use it to ensure its safe

tawdry perch
#

so not everyone may be able to invite it?

vocal plover
#

exactly, if you invite zep without being whitelisted it will just sit in your server and do nothing until it restarts, at which point it will leave all un-whitelisted servers

tawdry perch
#

nice system, that seems a good choice

vocal plover
#

it has the advantage also of meaning only a few people have access to support for the bot, in zeppelin's case large server admins, who are likely to understand it better in the first place, not ask annoying questions, and generally put less load on the devs for support

tawdry perch
#

That system sounds like working well

junior verge
#

I am back

tawdry perch
#

But I gotta go for a class 👋

junior verge
#

Bye

slate swan
steep estuary
#

why it is showing ffmpeg is not found

#

clientexception

#
@bot.command()
async def play(ctx, *, musicpath):
    voice_client: discord.VoiceClient = discord.utils.get(bot.voice_clients, guild=ctx.guild)
    audio_source = discord.FFmpegPCMAudio(musicpath)
    if not voice_client.is_playing():
        voice_client.play(audio_source, after=None)
boreal ravine
visual island
steep estuary
#

i downloaded it by pip

#

in env

visual island
steep estuary
#

ok

visual island
#

download to your pc, not your venv

steep estuary
#

ok

steep estuary
visual island
#

click whatever your os is

signal jay
#

pls beg

steep estuary
hasty iron
#

what?

steep estuary
steep estuary
leaden jasper
#

Hi! is there a timeout decorator for commands?

hasty iron
steep estuary
#

ok

slate swan
leaden jasper
#

Yass

#

If a command takes too long to process, it will timeout

slate swan
#

No there's not

steep estuary
#

i added ffmpeg in path

#

which was in env

visual island
steep estuary
#

in pc it was not installed

hasty iron
#

you can use asyncio.wait_for

steep estuary
hasty iron
#

for the timeout

steep estuary
#

where i will find ffmpeg?

slate swan
#

where you installed it

#

probably C:\ffmpeg\bin\

steep estuary
#

i did pip install

#

i installed using pip

slate swan
#

add that to environment variables

#

it's not ffmpeg

hasty iron
#

we told you not to install it with pip

steep estuary
slate swan
#

that's the library to be able to use it in a python script

harsh cradle
#

hi

#

i need help i have rank card and i dont know how to use Pil or any moudle to add my rank card to my level system is anyone know how

hasty iron
#

learn how to use PIL

slate swan
#

@steep estuary
Go to https://github.com/BtbN/FFmpeg-Builds/releases - Example: ffmpeg-n4.4-178-g4b583e5425-win64-gpl-4.4.zip
Download the file for Windows
Extract the content of the archive
Copy paste the folder somewhere you will always keep, example: C:\ffmpeg
Go to environment variables settings
Select the path variable in the rectangle at the top and click edit
Then click new in the window you will see
Add the path to the ffmpeg binaries folder you just previously created, example: C:\ffmpeg\bin

steep estuary
#

okk

#

ty

cloud dawn
#

The website also literally states this.

slate swan
#

It's hard to search things by yourself, people expect things to come to themselves instantly

steep estuary
#

now i added ffmpeg to path

#

but still it is showing same error :/

slate swan
#

Run ffmpeg in the cmd

steep estuary
#

ok

slate swan
#

to see if you really did everything correctly

steep estuary
#

should i restart my editor?

#

closed

slate swan
#

No

#

Open the cmd

#

Not your editor

steep estuary
#

i did

#

it closed

slate swan
#

Now open just the cmd

steep estuary
#

ok

#

now :/

slate swan
#

Execute ffmpeg -version

steep estuary
#

shown

slate swan
#

So you get the version

steep estuary
slate swan
#

Yeah it's installed

steep estuary
#

then now ?

#

ohh

#

that error solved

#

tysm :)

slate swan
#

:)

steep estuary
#

how i can get music

#

by its name ?

#

how i can search for music?

#

should i use youtube_Dl ?

slate swan
#

!ytdl

unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
steep estuary
#

ok

#

ty

slate swan
#

Have you even read it?

steep estuary
#

reading