#Channel edit bug

1 messages · Page 1 of 1 (latest)

distant moth
#

Hello I am currently coding an Ticket System and when I click ob button xy the name should get replaced from

🔵 | test to ⚪ | test

that worked untli now good but I discoverd an Error. When I Click the Button and restart the Bot and change everything back to normal it just doesnt work anymore

            channel = client.get_channel(interaction.channel.id)
            print(channel)
            if channel.category.id != termin_abholung.id:
                print('xx')
                embed = disnake.Embed(
                    description=f'Du wurdest auf die **Warteliste** gesetzt, ich bitte dich bei der nächsten ankündigung in {terminvergabe_channel.mention} ins Wartezimmer zu kommen!',
                    color=config.color)
                embed.set_author(name='Warteliste', icon_url='attachment://author.gif')
                embed.set_image(url='attachment://image.gif')
                print('xx')
                try:
                    await channel.edit(name=f'🔵{channel.name.replace("⚪", "").replace("⚫", "").replace("🔵", "")}')
                except:
                    print('Error')
                print('xx')
                await interaction.response.send_message(embed=embed, files=[author, image])
#

Output from an Channel that works:
🔵・clothing-lizhxro
xx
xx
xx

Output from an Channel that worked but now it doesn´t do anything
⚪・clothing-lizhxro
xx
xx

prisma basalt
#

Using a view?

#

views do no persist through bot restarts.

worn night
prisma basalt
#

Lol.

#

brb. I"m going to start making "How to build a bot with disnake" videos. But first I need a shittier mic

distant moth
prisma basalt
#

Which part of "I'm" means "you"?

#

Anyay..

Are you using a view?

distant moth
#

I use

@client.listen('on_button_click')

prisma basalt
#

OK.

#

As hellish said:
You don't need channel = client.get_channel(intaction.channel.id) you literally already have teh channel object. Getting it from cache is a wasted line

#

But also, you can only edit a channel name like 2/10 minutes IIRC. So it probably works, works, then doesn't work because you're ratelimited.

worn night
#

try:
do stuff
except:
print('Error')
will be better if u print the error
except Exception as e:
print(e)
for example

prisma basalt
#

^ yeah, never use a bare except.

distant moth
#

When I move the Channel manually and then Press the Button it doesn´t work

#
        if role in interaction.author.roles:
            try:
                images_path = 'assets/images/ticketsystem/waitingsystem'
                image = disnake.File(f'{images_path}/image/image.gif', filename='image.gif')
                author = disnake.File(f'{images_path}/author/author.gif', filename='author.gif')
                terminvergabe_channel = client.get_channel(config.terminvergabe_channel)
                termin_abholung = client.get_channel(config.termin_abholung)
                channel = interaction.channel
                print(channel.category.id == termin_abholung.id)
                print(termin_abholung)
                if channel.category.id != termin_abholung.id:
                    print('x')
                    embed = disnake.Embed(
                        description=f'Du wurdest auf die **Warteliste** gesetzt, ich bitte dich bei der nächsten ankündigung in {terminvergabe_channel.mention} ins Wartezimmer zu kommen!',
                        color=config.color)
                    embed.set_author(name='Warteliste', icon_url='attachment://author.gif')
                    embed.set_image(url='attachment://image.gif')
                    print('x2')
                    await channel.edit(name=f'🔵{channel.name.replace("⚪", "").replace("⚫", "").replace("🔵", "")}', category=termin_abholung)
                    print('x3')
                    await interaction.response.send_message(embed=embed, files=[author, image])
                else:
                    embed = disnake.Embed(description='Ticket ist bereits in der Warteliste.', color=config.color)
                    await interaction.response.send_message(embed=embed, ephemeral=True)
            except Exception as e:
                embed = disnake.Embed(description='Die angegebene Aktion konnte nicht durchgeführt werden.',
                                      color=config.color)
                await interaction.response.send_message(embed=embed, ephemeral=True)
        else:
            embed = disnake.Embed(description='Die angegebene Aktion konnte nicht durchgeführt werden.',
                                  color=config.color)
            await interaction.response.send_message(embed=embed, ephemeral=True)

Output :

False
Kategorie 1
x
x2

worn night
#

except Exception as e:

#

print the e pls

distant moth
#

It doesn´t go to the except

#

It just stops at the point after await channel.edit

prisma basalt
#

probably rate limited.

worn night
#

yep

distant moth
#

On other Channels it works

prisma basalt
#

It will work for ths one, too. After the rate limit expires.

distant moth
#

Is the Channel rate limited?

prisma basalt
#

Yes.

distant moth
#

Ah

#

Thanks

prisma basalt
#

editing THAT channel is rate limited and you'll have to wait

#

Really not a good idea to edit a channel on a button click because of this.

#

Unless you add a cooldown to the button click

#

Which then defeats the whole purpose of what problem this is supposed to solve.

Usually it should create a thread or forum post or something, or even a knew channel, rather than editing and moving around the channel where this button exists.

distant moth
#

Is there a way to check if the Channel is rate limited like ?

if channe.ratelimit > 1:?