#discord-bots

1 messages · Page 755 of 1

cedar stream
#

U put a space too much

tacit token
#

lsáfmagsk

slate swan
#

how do i remove a field in an embed?

tacit token
#
@client.group(invoke_without_command=True)
async def help(ctx):
    embed = discord.Embed(title = "Help", description = "Use >help <command> for extended on a command.", color=0x34568B)
    embed.add_field(name="Moderation",value = "Moderation Commands")
    embed.add_field(name = "Fun", value = "Fun commands")
    embed.add_field(name = "Chat", value = "Chat commands")
    embed.add_field(name = "Fun", value = "Fun commands")
    embed.add_field(name = "Chat", value = "Chat commands")
    await ctx.send(embed = embed)```
orchid bay
#

Hi

tacit token
#

where the space? where?

orchid bay
#

Guys

cedar stream
unkempt canyonBOT
#

class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
cedar stream
unkempt canyonBOT
#

remove_field(index)```
Removes a field at a specified index.

If the index is invalid or out of bounds then the error is silently swallowed.

Note

When deleting a field by index, the index of the other fields shift to fill the gap just like a regular list.
cedar stream
#

Lije this

heavy radish
#

Something is wrong with my COGs. Can someone check?

orchid bay
#

Wht r u doing

slate swan
cedar stream
heavy radish
#

await ctx.send(embed=embed)

cedar stream
tacit token
orchid bay
#

Heyy

cedar stream
orchid bay
#

! Resources

cedar stream
tacit token
cedar stream
orchid bay
#

!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.

tacit token
#

It works as long as only the top 3 is there.

heavy radish
cedar stream
cedar stream
heavy radish
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
tacit token
orchid bay
#

How to make bots

cedar stream
orchid bay
#

Please help

cedar stream
orchid bay
#

Ya

cedar stream
#

Do yk oop

orchid bay
#

Ya

tacit token
cedar stream
#

Do yk asynchronous programming

cedar stream
orchid bay
cedar stream
#

Try to delete the spaces and reindent

cedar stream
#

Then go to dpy docs and read

orchid bay
#

How to?

cedar stream
orchid bay
#

K

cedar stream
#

Google python asynchronous programming

#

Or something

slate swan
tacit token
#

bro wtf i restart vsc and this shit work.

cedar stream
tacit token
heavy radish
cedar stream
slate swan
cedar stream
heavy radish
#

It says what they are. Not how to use them

tacit token
#

thank u @cedar stream or @lone lichen NM_peepoKing

cedar stream
cedar stream
heavy radish
#

Am I looking at the wrong doc?

cedar stream
#

Why would docs exist if they didnt show how to use it

slate swan
heavy radish
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
cedar stream
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
heavy radish
#

I clicked that top thing

cedar stream
#

Scroll all the way up on the same page

#

And read from top to bottom

brittle axle
#

sorry for not giving you the answer in the correct time man i was held up by other work

#

so sorry

brittle axle
#

yea i use that for timed mutes

heavy radish
#

Ok, Let me see what I can come up with

brittle axle
#

k

heavy radish
#

5.0 is 5sec

#

How about 5m

brittle axle
#

for example if i want to mute someone for 10 seconds i put "S" in dictionary and then typed the value

#

which is 1

#

for a minute i put 60 for a hour i pout 3600

#

like taht

#

then after that i did this line of code

#

idk how to describe so i will just copy paste it

heavy radish
#

I mean. I don't think I need a dictionary. I'm only gonna need a 5 min interval all the time

brittle axle
#

oh ok

heavy radish
#

I don't think

brittle axle
#

then you just have to put the value as 60 in that

heavy radish
#

I'm may be wrong

#

60 is 5min? Or 1m?

brittle axle
#

i meant 1 m

#

60*5

heavy radish
#

300

brittle axle
#

yup

#

you have to put that and after that

#

you have to put await asyncio.sleep(the variable you put for the time)

#

and then after that you have to put the line of code you want to put after the wait time

heavy radish
#

so

#

i'll show u

#

Um

#
  @commands.Cog.listener()
  async def on_message(self, ctx, message):
    Unlock = discord.PermissionsOverwrite(send_messages=True)
    Lock = discord.PermissionsOverwrite(send_messages=False)
    Role = ctx.guild.default_role
    if message.channel.id == 814207750342705164 and message.content.startwith('RPG miniboss', 'rpg miniboss'):
      await ctx.channel.set_permissions(Role, overwrite=Unlock)
      await ctx.send(f":white_check_mark: Unlocked {ctx.channel.name}")
      await asyncio.sleep(300.0)
      await ctx.channel.set_permissions(Role, overwrite=Lock)
      await ctx.send(f"white_check_mark: Locked Down {ctx.channel.name}")
#

That look good?

#

@brittle axle

brittle axle
#

i think you need to put a variable inside a brackets

#

time = 300.0

#

use it like this

final iron
brittle axle
#

oh ok

#

then its fine @heavy radish

heavy radish
#

Ayy

#

New problem

brittle axle
#

what is it

#

btw i cant stay long for too much tmrw i have a math test so i need to study for that

heavy radish
#

I can't have CTX here

#

if i remove all the ctx, will it still work

brittle axle
#

i think we need to put guild in that

final iron
brittle axle
#

thats what i did for mute when it came to channel permissions

heavy radish
#

let me remove them all

final iron
brittle axle
#

@final iron is what im saying correct. I am a little new to this lib and i created my own bot

#

adding new features slowly

brittle axle
#

k

heavy radish
brittle axle
#

i think

final iron
#

Well message has a channel attribute

#

!d discord.Message.channel

unkempt canyonBOT
slate swan
# heavy radish I can't have CTX here

You have to remove ctx, only message is the argument passed to the event and self of course because you are in a cog, You can get ctx by using bot.get_context and passing the message object to it and set ctx as a variable

heavy radish
#

This only have to work in one channel

final iron
#

Add a check

heavy radish
#

My brain..

final iron
#

A little if statement

heavy radish
#

bot.get_context how do I do this part?

brittle axle
#

i need to go now @heavy radish sorry bye

final iron
#

You don't have to get context

heavy radish
#

Then what do I do?

final iron
#

So discord.Message has a channel attribute

#

!d discord.Message.channel

unkempt canyonBOT
final iron
#

So you can use that

heavy radish
#

How?

final iron
#

Well message is your discord.Message object

#

Therefore it would be...

heavy radish
#

channel attritbute?

final iron
#

I'll give you this one

#

It would be message.channel

#

So you would do message.channel.set_permissions(...)

heavy radish
#

You're kidding me

#

I just do that for all?

final iron
#

Well where you need the channel you would do that

heavy radish
#

That fixed it

#

Now I got more error. 😢

final iron
#

Like where you're setting the channels permissions and sending the message

final iron
#

It's most likely the guild

heavy radish
#

Having problems with discord part

#

Unlock = discord.PermissionsOverwrite(send_messages=True)
Lock = discord.PermissionsOverwrite(send_messages=False)

final iron
#

What's the error

heavy radish
slate swan
#

It's PermissionOverwrite

heavy radish
#

oh

#

Moment of truth

slate swan
#

That won't work.

heavy radish
#

No errors lemon_hearteyes

dense coral
#

How do I count members in status?

heavy radish
final iron
heavy radish
#

yes

#

Role = message.guild.default_role 😢

slate swan
final iron
#

!d discord.ext.commands.Bot.get_all_members

unkempt canyonBOT
#

for ... in get_all_members()```
Returns a generator with every [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") the client can see.

This is equivalent to:

```py
for guild in client.guilds:
    for member in guild.members:
        yield member
heavy radish
#

message.content.startwith.lower('RPG miniboss'):

slate swan
#

.lower()

heavy radish
#

its there

slate swan
#

On the string.

#

Very basics of Python, have you learned it correctly?

#

!e
msg = "RPg MinIbOss"

if msg.lower().startswith("rpg miniboss"):
print("Yes")

unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

Yes
dense coral
#

Can you show me how to write it down?

final iron
#

Idk why he sent that

#

!d discord.ext.commands.Bot.users

unkempt canyonBOT
final iron
#

Use this

#

It returns a list, therefore you need to use list() on it

slate swan
#

As simple as that.

dense coral
#

ok

slate swan
final iron
#

Probably a typo

slate swan
#

Thanks I realized it :)

dense coral
#

Erorr

#

But I think it has nothing to do with the command

final iron
slate swan
dense coral
slate swan
#

Still not the entire error.

#

The main part of error is still missing

#

It could be a ratelimited ip ( use kill 1 in console)

#

Well, considering you're using Replit. There is 99% chance that you are rate limited from using Discord's API.

primal scarab
#

What is the shortcut to end the bot

#

For VS code

slim ibex
#

You just destroy the terminal

primal scarab
#

How do you do that

#

Like what is the shortcut to do that

slim ibex
#

Don’t think there is one

#

haven’t looked for it lmao

primal scarab
#

Oh oki

slate swan
#

Just press CTRL+C to terminate the running script.

#

And to kill the terminal instance it's CTRL+F4

primal scarab
#

Ohk thank you :D

slate swan
#

heyy

stable berry
#

from discord_slash import SlashCommand is this not ok ??

slate swan
#

i have this code ```python
class closebutton(nextcord.ui.View):
def init(self):
super().init()
self.view = None

        @nextcord.ui.button(label="🔒", style=nextcord.ButtonStyle.gray)
        async def closebtn(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
            user = interaction.user
            emb=nextcord.Embed(title="🔒 Close Ticket", description=f"Είσαι σίγουρος οτι θέλεις να διαγράψεις το Ticket σου?", color=color, timestamp=datetime.now())
            emb.set_author(name=user.name, icon_url=user.avatar.url)
            await interaction.response.send_message(embed=emb, ephemeral=True)

class ticket1(nextcord.ui.View):
        def __init__(self):
            super().__init__()
            self.view = None

        @nextcord.ui.button(label="💎", style=nextcord.ButtonStyle.gray)
        async def ticketbut(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
                guild = interaction.guild
                user = interaction.user
                name = 'ticket'
                view1 = self.closebutton()
                category = nextcord.utils.get(interaction.guild.categories, name=name)
                channel = await guild.create_text_channel(f'🎫Ticket-{user.name}', category=category)
                await channel.set_permissions(interaction.guild.default_role, send_messages=True, read_messages=False)
                await channel.set_permissions(user, view_channel = True)
                await channel.set_permissions(guild.default_role, connect = False, view_channel = False)
                await channel.send(f"{user.mention}")
                emb=nextcord.Embed(title="🎫 Ticket Category", description=f"Επέλεξε από το παρακάτω `menu` την κατηγορία που ταιριάζει το **__Ticket__** σου.", color=color, timestamp=datetime.now())
                emb.set_author(name=user.name, icon_url=user.avatar.url)
                emb2=nextcord.Embed(title="🎫 Ticket Channel Created!", description=f"Έλεγξε το {channel.mention} για να ανοίξεις το **__Ticket__** σου.", color=color, timestamp=datetime.now())
                emb2.set_author(name=user.name, icon_url=user.avatar.url)
                await channel.send(embed=emb, view=view1)
                await interaction.response.send_message(embed=emb2, ephemeral=True)
But i get this error when i press the 💎 button
`AttributeError: 'ticket1' object has no attribute 'closebutton'`
stable berry
slim ibex
stable berry
slim ibex
#

prolly don’t have discord slash or whatever it is installed

stable berry
#

i just installed it 🥲

slim ibex
#

@slate swan can you send just the part where ticket1 is

#

@stable berry maybe restart VSCode and see if the right interpreter is selected

stable berry
slim ibex
cloud dawn
slim ibex
#

^

stable berry
stable berry
#

and everything is public

#

ok trying to do the same in vs code

slate swan
slim ibex
slate swan
#

I have this code:

@bot.command()
async def userinfo(ctx, *, user: discord.Member = None):
    if user is None:
        user = ctx.author      
    date_format = "%a, %d %b %Y %I:%M %p"
    userembed = discord.Embed(color=0xdfa3ff, description=user.mention)
    userembed.set_author(name=str(user), icon_url=user.avatar_url)
    userembed.set_thumbnail(url=user.avatar_url)
    userembed.add_field(name="Joined", value=user.joined_at.strftime(date_format))
    members = sorted(ctx.guild.members, key=lambda m: m.joined_at)
    userembed.add_field(name="Join position", value=str(members.index(user)+1))
    userembed.add_field(name="Registered", value=user.created_at.strftime(date_format))
    if len(user.roles) > 1:
        role_string = ' '.join([r.mention for r in user.roles][1:])
        userembed.add_field(name="Roles [{}]".format(len(user.roles)-1), value=role_string, inline=False)
    perm_string = ', '.join([str(p[0]).replace("_", " ").title() for p in user.guild_permissions if p[1]])
    userembed.add_field(name="Guild permissions", value=perm_string, inline=False)
    userembed.set_footer(text='ID: ' + str(user.id))
    return await ctx.send(embed=userembed)```

**And the error is this:**
https://cdn.discordapp.com/attachments/924690098749054997/932637465007783966/Rocket_Beta.py_-_Replit_-_Opera_17_1_2022_4_07_11_2.png
stable berry
#

Import "discord.ext" could not be resolvedPylancereportMissingImports

vale wing
#

Seems like there's no user in members

cloud dawn
#

Members is just a property that returns a list.

#

Oh wait

stable berry
#

hello

vale wing
#

In his case it is a list sorted by joining date

slim ibex
#

!d discord.ext.commands.Bot

slate swan
slim ibex
vale wing
#

@slate swan you may try get the list of ids out of list of members and then use index with id

stable berry
#

why its saying error when i am running in vs code

slim ibex
stable berry
#

ok

#

what is this jupyter

rugged tangle
#

why do I get an indent error? It looks good to me..

#

it's at await message.channel.send(encouragements)

cloud dawn
rugged tangle
#

it says i'm already using tabs

cloud dawn
#

Sure you aren't mixing them?

slim ibex
#

It is indented Too far I believe

rugged tangle
cloud dawn
slim ibex
#

It should be in the line under the if

rugged tangle
#

okay

#

made it worse

cloud dawn
#

Setting indention level to 4 might see these easier.

slim ibex
#

holy fuck

slate swan
#

@commands.command()
@commands.is_owner()
@commands.bot_has_permissions(send_messages=True)
async def dev_invite(self, ctx, guild_id : int):

    try:
        guild = self.bot.get_guild(guild_id)
    except:
        return await ctx.reply('Invaild guild id.')

    try:
        invite = await guild.text_channels[0].create_invite()
    except:
        return await ctx.reply('I do not have permissions to create invites in that guild.')

    await ctx.check()
    return await ctx.author.send(invite)
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'check'

cloud dawn
#

Yeah website coding is kinda ..

slim ibex
#

^

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
#
 
    @commands.command()
    @commands.is_owner()
    @commands.bot_has_permissions(send_messages=True)
    async def dev_invite(self, ctx, guild_id : int):

        try:
            guild = self.bot.get_guild(guild_id)
        except:
            return await ctx.reply('Invaild guild id.')

        try:
            invite = await guild.text_channels[0].create_invite()
        except:
            return await ctx.reply('I do not have permissions to create invites in that guild.')

        await ctx.check()
        return await ctx.author.send(invite)```
#

Command raised an exception: AttributeError: 'Context' object has no attribute 'check'

slate swan
cloud dawn
slate swan
#

await ctx.check() ?

cloud dawn
#

Well you got private guilds and i respect privacy.

slate swan
#

i own

#

my bot is a private

#

and i have rulesets for every server that uses my bot

#

and they own a license to my bot

#

i have permission to grab that guild i feel like it my g

quick gust
cloud dawn
cloud dawn
slate swan
slate swan
#

u dumbass bum

stable berry
#

im confused now 🥲

rugged tangle
slate swan
#

u actually mad slow

cloud dawn
slate swan
#

i can do wtv i want

slate swan
cloud dawn
#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

slate swan
#

it doesnt breach tos

karmic totem
slate swan
#

i have this code ```python
class closebutton(nextcord.ui.View):
def init(self):
super().init()
self.view = None

        @nextcord.ui.button(label="🔒", style=nextcord.ButtonStyle.gray)
        async def closebtn(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
            user = interaction.user
            emb=nextcord.Embed(title="🔒 Close Ticket", description=f"Είσαι σίγουρος οτι θέλεις να διαγράψεις το Ticket σου?", color=color, timestamp=datetime.now())
            emb.set_author(name=user.name, icon_url=user.avatar.url)
            await interaction.response.send_message(embed=emb, ephemeral=True)

class ticket1(nextcord.ui.View):
        def __init__(self):
            super().__init__()
            self.view = None

        @nextcord.ui.button(label="💎", style=nextcord.ButtonStyle.gray)
        async def ticketbut(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
                guild = interaction.guild
                user = interaction.user
                name = 'ticket'
                view1 = self.closebutton()
                category = nextcord.utils.get(interaction.guild.categories, name=name)
                channel = await guild.create_text_channel(f'🎫Ticket-{user.name}', category=category)
                await channel.set_permissions(interaction.guild.default_role, send_messages=True, read_messages=False)
                await channel.set_permissions(user, view_channel = True)
                await channel.set_permissions(guild.default_role, connect = False, view_channel = False)
                await channel.send(f"{user.mention}")
                emb=nextcord.Embed(title="🎫 Ticket Category", description=f"Επέλεξε από το παρακάτω `menu` την κατηγορία που ταιριάζει το **__Ticket__** σου.", color=color, timestamp=datetime.now())
                emb.set_author(name=user.name, icon_url=user.avatar.url)
                emb2=nextcord.Embed(title="🎫 Ticket Channel Created!", description=f"Έλεγξε το {channel.mention} για να ανοίξεις το **__Ticket__** σου.", color=color, timestamp=datetime.now())
                emb2.set_author(name=user.name, icon_url=user.avatar.url)
                await channel.send(embed=emb, view=view1)
                await interaction.response.send_message(embed=emb2, ephemeral=True)
But i get this error when i press the 💎 button
`AttributeError: 'ticket1' object has no attribute 'closebutton'`
#

Privacy

quick gust
#

It does

daring olive
#

@slate swanexcuse me?

quick gust
#

Yeah no that's enough

#

lmao

slate swan
#

i bet rule1 is be nice and friendly

#

You cannot just create random invites with the bot

#

doesnt seem like that

stable berry
#

can anyone tell me why its showing Import "discord.ext" could not be resolvedPylancereportMissingImports

karmic totem
#

!rule 1

unkempt canyonBOT
rugged tangle
slate swan
#

u make no sense

cloud dawn
slate swan
#

ur downing me for "illegal code"

karmic totem
slate swan
#

its not even illegal code

karmic totem
slate swan
#

even dyno has dev_invite

slate swan
#

ur mad slow

karmic totem
#

its replit being dum

cloud dawn
rugged tangle
stable berry
#

yes

daring olive
#

!mute 926504003167203348 4h your recent message history is really unacceptable. abide by our #code-of-conduct and #rules

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1642443970:f> (3 hours and 59 minutes).

karmic totem
#

hmmm

daring olive
#

@slate swan don't DM me, please DM @novel apex

#

if i've missed something, we can address it via modmail

slate swan
slate swan
#

show the full import line

stable berry
#

yes

#

import typing
import discord
from discord_slash import SlashCommand
from discord.ext import commands

sweet ether
#

hey guys is discord.py still alive? i haven't been here in soooo long

#

i thought danny stopped mainataining the lib?

cloud dawn
slate swan
sweet ether
cloud dawn
slate swan
#

Disnake and nextcord are forks , hikari is a completely different library

sweet ether
slate swan
cloud dawn
slate swan
quick gust
cloud dawn
#

Disnake is king :3

stable berry
#

ok

slate swan
#

indeedstare

quick gust
#

100%

slate swan
#

👀what was that

#

yo

#

hey!

#

i need help

cloud dawn
#

Actually been suggesting Disnake ever since Danny announced the stop. Glad i did.

cloud dawn
slate swan
#

why did my message get deleted

#

Hey does anyone know why python nested if statements don't work when developing discord bots? Here is an example line of code
if message.content.startswith('$example'):
if gamestarted == True:
await message.channel.send('Variable equals true')
if gamestarted == False:
await message.channel.send('Variable equals true')

cloud dawn
slate swan
#

kk

#

This is the error message I get

bitter depot
#

@slate swan we filter .gg

slate swan
slate swan
#

Well the error says your problem itself

#

This is the error message

#

This is the error message

bitter depot
# slate swan kk

Just send a different string here and then put the .gg/xxx in your code

slate swan
#

please don't spam it @slate swan

#

Sorry having trouble sending images

quaint epoch
slate swan
#

Oh , relatable

Well your error means that the variable is not defined yet

bitter depot
#

@slate swan as I said, you need to remove it from your message here

cloud dawn
#

3th time is the charm

dense coral
#

Anyone have a button code in Python ?, everything I tried did not work ..

slate swan
#

i want to make so when you put the invite link to the server in ur status not bio ur status the bot gives you a role

shadow wraith
#

so basically i have an on_command_error event in my main file which runs the bot and the cogs and stuff, but here's the twist.

for some fucking reason it sends it twice

unkempt canyonBOT
#

disnake.on_member_update(before, after)```
Called when a [`Member`](https://docs.disnake.dev/en/latest/api.html#disnake.Member "disnake.Member") updates their profile.

This is called when one or more of the following things change:

• nickname

• roles

• pending...
cloud dawn
shadow wraith
#

so how do i make it send the error once

slate swan
cloud dawn
shadow wraith
#

ill get back here if my thing still happens

cloud dawn
#

Ah okay.

slate swan
shadow wraith
#

i thought the on_command_error event in cogs would only trigger when a command in the cog gets an error

sweet ether
#

i went through the disnake docs, thankfully it's almost as same as dpy

dense coral
# cloud dawn What do you got so far?
button = Button(label="click", style=discord.ButtonStyle.green,emoji="😀")
view = view()
view.add_item(button)
await ctx.send("hello", view=view)```
sweet ether
#

btw did dpy v2 ever officially realease?

final iron
shadow wraith
#

i kinda didnt code discord bots in a while

sweet ether
final iron
#

You can still use the master release

#

Or a fork

shadow wraith
#

ikr but the switch to disnake didn't affect anything, all was just search replacing

final iron
#

Preferably disnake

shadow wraith
#

yeah disnake is cool

sweet ether
slate swan
#

can someone help me i want the bot to check if user has the invite link in status if the user has it the bot will give a role

maiden fable
#

!d discord.Member.activities

unkempt canyonBOT
#

The activities that the user is currently doing.

Note

Due to a Discord API limitation, a user’s Spotify activity may not appear if they are listening to a song with a title longer than 128 characters. See GH-1738 for more information.

slate swan
maiden fable
#

!d discord.CustomActivity

unkempt canyonBOT
#

class discord.CustomActivity(name, *, emoji=None, **extra)```
Represents a Custom activity from Discord.

x == y Checks if two activities are equal.

x != y Checks if two activities are not equal.

hash(x) Returns the activity’s hash.

str(x) Returns the custom status text.

New in version 1.3.
slate swan
#

i searched there

sweet ether
slate swan
#

i couldn’t find

maiden fable
maiden fable
#

discord.CustomActivity is the custom status that users put

slate swan
#

i mean if user has . gg / vanity in status

#

the bot gives the member a role

#

bruh

maiden fable
#

Yea...

#

U need to access the status text first dude

slate swan
#

ik

maiden fable
#

So iterate through those and get the text with the name attr

unkempt canyonBOT
slate swan
#

☠️

#

brah

maiden fable
#

And just do if link in status.name

slate swan
#

no bruh

maiden fable
#

Then...?

#

Mind explaining better

slate swan
#

i want it like

invite_link = “the discord vanity here”

like if user has invite_link in status it gives them a role
maiden fable
#

Yea...

#

That's what am telling u dude

slate swan
#

bro then it’s just me that don’t understand

#

doesn’t *

maiden fable
#

Ik lol

slate swan
#

i’m stupid ☠️

sweet ether
soft trout
#

If I was making a /ban command how would I make it have another field

soft trout
#

for the members name

maiden fable
#
for activity in member.activities:
    if isinstance(activity, discord.CustomActivity):
        status = activity.name
        # STATUS IS NOW THE TEXT IN THE USER STATUS
slate swan
#

☠️ i’m so stupid

#

i had an easier way of doing this but i stopped coding for a while and somehow forgot some things

daring olive
#

@cloud dawn for that code/user earlier, creating guild invites. can you explain or point me to why that's Discord ToS breaking?

sweet ether
#

ooh

#

wait

maiden fable
sweet ether
#

@maiden fable is that really you?

maiden fable
#

Uhhh, yea ig? It's me only???

jade sinew
#

Helloo, so i think this is more of a replit problem than actual bug int he code. so i put my discord bot code into replit and then ran it, and instead of running it gave me this error: ```
Because no versions of discord match >1.7.3,<2.0.0
and discord (1.7.3) depends on discord.py (>=1.7.3), discord (>=1.7.3,<2.0.0) requires discord.py (>=1.7.3).
Because discord.py (1.7.3) depends on aiohttp (>=3.6.0,<3.8.0)
and no versions of discord.py match >1.7.3, discord.py (>=1.7.3) requires aiohttp (>=3.6.0,<3.8.0).
Thus, discord (>=1.7.3,<2.0.0) requires aiohttp (>=3.6.0,<3.8.0).
So, because repl-python3-challengebot depends on both aiohttp (^3.8.1) and discord (^1.7.3), version solving failed.

at /opt/virtualenvs/python3/lib/python3.8/site-packages/poetry/puzzle/solver.py:241 in _solve
237│ packages = result.packages
238│ except OverrideNeeded as e:
239│ return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
240│ except SolveFailure as e:
→ 241│ raise SolverProblemError(e)
242│
243│ results = dict(
244│ depth_first_search(
245│ PackageNode(self._package, packages), aggregate_package_nodes
exit status 1

Replit: Package operation failed.``` so basically aiohttp and that python version aren't really cooperating? Can someone pls tell me how to fix this? I'm very new to repl, so this may seem easy to some of you. pls ping when you respond

sweet ether
maiden fable
#

I forgot u ngl, sorry

slate swan
#

@maiden fable can i invite u to the project and u help me?

sweet ether
#

😭

maiden fable
#

Sorry bruv, on mobile rn

slate swan
#

brah

maiden fable
#

Mind giving me some context?

sweet ether
maiden fable
#

yea

sweet ether
#

and put in your variables obviously

slate swan
#

wait lemme see

slate swan
sweet ether
slate swan
#

that’s why i joined this server

sweet ether
maiden fable
maiden fable
slate swan
#

☠️

maiden fable
#

!d for @slate swan

unkempt canyonBOT
#
for

8.3. The for statement

The for statement is used to iterate over the elements of a sequence (such as a string, tuple or list) or other iterable object:


for_stmt ::=  "for" target_list "in" expression_list ":" suite
              ["else" ":" suite]
sweet ether
#

changed*

maiden fable
#

Yea

slate swan
maiden fable
#

No

slate swan
#

bro why am i so stupid today

maiden fable
#

Brooo why

jade sinew
slate swan
#

idk

jade sinew
#

the difference is that they didnt have aiohttp

slate swan
visual yarrow
#

Sorry, @maiden fable, caught by the spam filter because your message contained an invite link.

jade sinew
#

wtf

slate swan
#

pls help me

#

What the actual f

sweet ether
#

lmao

slate swan
jade sinew
#

W in TF

maiden fable
visual yarrow
#

Erm, @slate swan, not appropriate.

slate swan
#

what you never seen tits before?

visual yarrow
#

Let's not post memes here please.

jade sinew
visual yarrow
slate swan
maiden fable
#

Bruh

jade sinew
sweet ether
#

LMAO

slate swan
#

that was last meme i promise

#

Bots don't have them , so we don't talk about them here
Let's get back to topic

visual yarrow
#

I hope so. I will be handing out mutes if there are more memes here. Be warned!

slate swan
#

bruh ur like that one kid in the other server

#

coding his girlfriend

#

yes

sweet ether
#

dude

jade sinew
#

bruh

slate swan
#

Pls stop

visual yarrow
#

Alright

jade sinew
#

stppit

slate swan
#

stop what

visual yarrow
#

!mute 929023092842459136 Take a time out.

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1642435386:f> (59 minutes and 59 seconds).

sweet ether
#

you'll get this channel muted @slate swan

#

oh that works

slate swan
#

ty LX WHOAAAAA

jade sinew
#

😄 ty!

bitter depot
visual yarrow
#

Back to the topic of this channel please.

stable berry
#

how to stop a running bot in vs code

jade sinew
stable berry
#

ok tq

jade sinew
#

np

rugged tangle
#

unindent does not match any outer indentation level

stable berry
jade sinew
slate swan
jade sinew
sweet ether
jade sinew
#

it'll stop running the file and then the bot will stop working until you run it again

sweet ether
vale wing
stable berry
stable berry
#

tq

stable berry
#

can i dm u

jade sinew
jade sinew
cloud dawn
#

Slash commands & message intents
Discord is lately leaning much more towards slash commands (application commands).
They are meant to provide users a first-class way of interacting directly with
your application that feels deeply integrated into Discord.

As of April 30, 2022 if your bot is verified you would need to request message intents.
This changes only verified bots, If are verified and want this you would need
to request this (See resources).

Registering slash commands
To register global slash commands simply don't define a guilds or test_guilds in your bot.
Global commands will fan out slowly across all guilds, and will be guaranteed to be updated in an hour.
There is a global rate limit of 200 application command creates per day, per guild

Slash command types and limits
Slash has 3 unique command types:
CHAT_INPUT: Slash commands; a text-based command that shows up when a user types / (limit 100*)
USER: A UI-based command that shows up when you right click or tap on a user (limit 5)
MESSAGE: A UI-based command that shows up when you right click or tap on a message (limit 5)

Max 25 choices or autocomplete suggestions.

  • Be aware that sub-commands is a command

Sub-commands
Subcommands organize your commands by specifying actions within a command or group.
Using subcommands or subcommand groups will make your base command unusable.

Common issues
This is a common error, this means in the scope applications.commands isn't enabled.
[WARNING] Failed to overwrite commands in <Guild id=923632089834864690> due to 403 Forbidden (error code: 50001): Missing Access
To solve this go to https://discord.com/developers/applications and let the bot rejoin (See screenshot).

Command names are always lower case in slash.

Resources used
Discord developer docs: https://discord.com/developers/docs/interactions/application-commands
Message content: https://support-dev.discord.com/hc/en-us/articles/4404772028055

Screenshots:

devout iris
#

Hey my bot's prefix is when_mentioned_or() but when i send @ everyone , it is triggering.... How can i fix?

slate swan
#

that's not possible emoji_88

#

Lemme check

slim ibex
#

return when_mentioned_or(prefix)

rugged tangle
soft trout
#
@inter_client.slash_command(description="see ur bank", options=[
                Option(
                 name="user",
                 description="see ur friends bank",
                 option_type=6,
                 required=False)])
               
async def bank(interaction, user:discord.Member=None):
``` why is this not working
final iron
#

why is this not working is not descriptive enough

soft trout
#

ok

#

well lets start with I want you to be able to see other peoples banks

#

but it is not required

#

error message:

Traceback (most recent call last):
  File "c:\Users\\OneDrive\Documents\casino bot\main.py", line 96, in <module>
    Option(
  File "C:\Users\\AppData\Local\Programs\Python\Python39\lib\optparse.py", line 569, in __init__
    opts = self._check_opt_strings(opts)
  File "C:\Users\\AppData\Local\Programs\Python\Python39\lib\optparse.py", line 589, in _check_opt_strings
    raise TypeError("at least one option string must be supplied")
TypeError: at least one option string must be supplied
vale wing
sweet ether
vale wing
devout iris
slate swan
slim ibex
#

you can setup a custom prefix function where you pass in the bot and message like this

def prefix(bot, message):
    prefix = ?
    return when_mentioned_or(prefix)(bot, message)

#

If you have a database

vale wing
slim ibex
#

you can replace the ? with a query to find the prefix in the database for the specific server

slate swan
vale wing
#

Implementing commands in on_message is bad practice and shouldn't ever be used. By telling people to use this you are basically providing misinformation

final iron
#

@cloud dawn if I may ask, why do you limit the amount of packages passed in to your pypi package autocomplete to 25?

final iron
slate swan
final iron
#

By using an on_message event you are limiting yourself from using tons of resources

vale wing
#

^

slate swan
vale wing
#

It is better to learn the right way at first rather than to re-learn

vale wing
slate swan
vale wing
#

In on_message?

slate swan
stable berry
#

why my slash command giving this reply any idea (bcs the normal code is giving the correct output)

vale wing
#

Well you can use it but you shouldn't. When it comes to arguments, on_message is very complicated unlike commands

stable berry
#
The application did not respond
slate swan
vale wing
#

Yeah

#

I am not arguing btw I am just trying to show the right way, sorry if I offended you somehow

slate swan
#

yes, you are right and i think it's right to not use on_message events for these types of things

vale wing
#

👍

slate swan
#

actually i've been off from coding for a while that's why i suggested it

slate swan
sweet ether
# slate swan why can't i? bro i've done it myself without any "special function"

see all he's saying that it's bad because it uses up resources which on a wider scale could be detrimental to your bot because then it'll have to go through each and every text send in the entire server and then have to execute whatever code you have in the on-message which could be heavy for your server, at a smaller level i dont think on message has any harm

#

on_message sorry*

#

so like, avoid on_message for production at least

final iron
#

You don't have access to decorators

sweet ether
vale wing
#

@stable berry if the code takes long to evaluate you should defer the response not to cause this, in different libraries it might be done in different ways, for example in disnake it is

await inter.response.defer()```
soft trout
#

@final iron I sent the error message ^

sweet ether
final iron
#

Am I doing something wrong here?

    @slash_command(name="pypi", description="Sends the pypi of a valid package")
    async def pypi(self, inter: disnake.ApplicationCommandInteraction,
                   package: str = commands.Param(autocomplete=pypi_autocomplete)):
#

I'm getting a TypeError: pypi_autocomplete() missing 1 required positional argument: 'user_input'

cloud dawn
final iron
#

I'll add that to mine then

#

If I can actually get it working

#

I'm looking at the docs and they do something extremely similar

cloud dawn
#

Action actually crashes if you provide more than 25

hard trail
#

what do you suggest i do?

cloud dawn
harsh prism
#

Can any help me and my friend are facing

#

I and my friend thought to host a discord bot which was disconnected few months ago
So we asked the devs for the code and we got it but we ran into an huge error of db mongo uri , it needs 4 uri's but we do not know it how to solve as we are new to mongo things
please help us brothers

jovial dock
#

How would i make my discord bot send to any channel?

cloud dawn
hard trail
#

How can I fix the loop. I need it there

cloud dawn
#
@bot.event
async def on_message(ctx):
  if ctx.author.bot:
    return
  for word in naughty_words:
    if word in ctx.content:
      if ctx.author.guild_permissions.manage_messages:
        
        ...
    else:
        await asyncio.sleep(3)
        await ctx.delete()
        await ctx.channel.send(f"{ctx.author.mention}, you aren't allowed to say that!")
  await bot.process_commands(ctx)
lone aurora
#

shouldn't it be ctx.context?

cloud dawn
#

ctx == context?

lone aurora
#

for word in naughty_words:
if word in ctx.context:

lone aurora
cloud dawn
cloud dawn
final iron
# cloud dawn Could you show `pypi_autocomplete` func?
    async def pypi_autocomplete(self, inter: disnake.ApplicationCommandInteraction, user_input: str) -> List[str]:
        cursor = await self.bot.connection.cursor()
        packages = await cursor.execute(f"SELECT package FROM pypi_packages").fetchone()
        return sorted([lang for lang in list(packages) if user_input.lower() in lang.lower()])[:25]
cloud dawn
#

Discord does the rest for you

hard trail
final iron
#

Wait

#

But what about line 4

#

user_input.lower()

cloud dawn
final iron
#

I don't understand this

cloud dawn
final iron
#

Oh

#

I think I understand

cloud dawn
#

Discord will automatically insert the list into autocompletion, you don't have to manually check the content.

final iron
#

So I just have to return the list of packages?

hard trail
final iron
#

Like

list_ = ["discord.py", "discord", "psutil"]
#

?

cloud dawn
cloud dawn
final iron
#

Nice

hard trail
cloud dawn
kind wind
#

Okay i also came here yesterday because I had the same problem.
My code:

@bot.command()
async def pro(ctx, member: discord.Member = None):
    prousers = [485442448244342786, 608575327811272704]
    if member.id in prousers:
        await member.send("You have activated your pro membership!")
        prorole = get(ctx.guild.roles, id=911248795382194201)
        await member.add_roles(prorole)
    else:
        await member.send("You have no pro packages to activate!\nYou can buy pro packages at our website, or win them by a giveaway.")

I want to send a different dm message for certain users.

#

Although I get errors

slate swan
#

dont use utils.get for getting role , use ctx.guild.get_role(id) , and whats the error you face?

kind wind
#

i tried that but a guy changed it

vale wing
kind wind
#

here

maiden fable
#

Unrelated, but @slate swan if u like web dev, look into svelte!

kind wind
vale wing
#

Or you are checking if the user is eligible for pro

kind wind
#

no

vale wing
#

Nvm forget it

maiden fable
vale wing
#

@kind wind member doesn't seem like an optional argument, why are you making it such

kind wind
#

i got the updated code from him bc he said it was correct

#

so what?

final iron
#

return sorted([package for package in [package_tuple[0] for package_tuple in packages]][:25])
Readability pithink

#

Reduced my code by 4 whole lines though

final iron
#

And send the new code?

#

Its hard following an old thread

proud rain
#

@Client.slash_command(guild_ids=[testingServerID])
AttributeError: 'Bot' object has no attribute 'slash_command'

Can someone help?

kind wind
# final iron Can you restate your issue?

I changed the code for the role but just for that

@bot.command()
async def pro(ctx, member: discord.Member = None):
    prousers = [485442448244342786, 608575327811272704]
    if member.id in prousers:
        await member.send("You have activated your pro membership!")
        prorole = ctx.guild.get_role(911248795382194201)
        await member.add_roles(prorole)
    else:
        await member.send("You have no pro packages to activate!\nYou can buy pro packages at our website, or win them by a giveaway.")

Also what i want: I want to use the command and send a dm message and say either for the users that have un-activated pro membership that it is activated and give them the role and if they aren't in that list say that they don't have any pro packages. I want this to go on DM-only

final iron
#

!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.

kind wind
#

IT GIVES ME ERROR

maiden fable
#

Bro calm down

kind wind
final iron
quick gust
#

When are u gonna share the error

kind wind
#
Ignoring exception in command pro:
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\user\Desktop\Vaggelis\Coding\Bots\VDP's Utilities\main.py", line 106, in pro
    if member.id in prousers:
AttributeError: 'NoneType' object has no attribute 'id'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'id'
quick gust
#

member is None

final iron
#

So something like

#

!pro @final iron

unkempt canyonBOT
#
Did you mean ...

» kindling-projects
» xy-problem

final iron
#

This would work

#

But if you do

#

!pro

unkempt canyonBOT
#
Did you mean ...

» kindling-projects
» xy-problem

kind wind
#
@bot.command
async def pro(ctx, user : discord.Member = None):

The None must change to what?

final iron
#

Make it a required argument

#

or

kind wind
final iron
quick gust
#

You should just supply a member argument, or you can add an if statement to handle if they don't give a member argument, + what gazes said

proud rain
final iron
#

This is also an option user = user or ctx.author

#

Does the same thing as the if statement but its on 1 line

kind wind
kind wind
#

the person itself is the discord.Member

final iron
kind wind
#

from

async def pro(ctx, user : discord.Member):
```It will be

async def pro(ctx):

final iron
#

Yes

slate swan
kind wind
#

what about these

final iron
#

ctx.author is a member object

slate swan
#

what are you trying to do

kind wind
slate swan
final iron
kind wind
#

let me try

final iron
#

Since ctx.author a member object

slate swan
#

yup

kind wind
#

Works!

final iron
kind wind
#

lets try without my id being in there

#

IT WORKS :D

slate swan
#

nice

final iron
#

Good job

rustic onyx
#

best discord hosts?

slate swan
final iron
#

A raspberry pi is also an option

rustic onyx
#

ty sir

slim whale
#

guys what is the package for discord in replit?

maiden fable
slim whale
#

it says that

maiden fable
#

seems like u broke replit lol

unkempt canyonBOT
twin moon
#

'Comment_View' object has no attribute 'children'

slim whale
maiden fable
#

u didn't call super().__init__() @twin moon

slim whale
maiden fable
#

I didn't open the link tho

maiden fable
drifting vigil
#

Hey hello I was making thsi bot.. I wanted this command to be used by admins only.. so I have added @urban notch_permissions .. I wanted to know do I need to do some error handling?

maiden fable
maiden fable
slim whale
maiden fable
#

!d discord.ext.commands.MissingPermissions

unkempt canyonBOT
#

exception discord.ext.commands.MissingPermissions(missing_permissions, *args)```
Exception raised when the command invoker lacks permissions to run a command.

This inherits from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
maiden fable
#

@drifting vigil

drifting vigil
maiden fable
#

yea

#

that's the most common error that comes

drifting vigil
#

how do I do that?

maiden fable
#

on_command_error

drifting vigil
maiden fable
#

ctx, error

#

and use isinstance to see what type of error

drifting vigil
#

ok thanks

flint isle
#

I'm getting this error

Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
    start(fakepyfile,mainpyfile)
  File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
    exec(open(mainpyfile).read(),  __main__.__dict__)
  File "<string>", line 2
    from discord-buttons import DiscordButton
                ^
SyntaxError: invalid syntax

[Program finished]
maiden fable
#

- and + cannot be there in a module name

#

it should be discord_buttons

flint isle
#

Ok

#
Traceback (most recent call last):
  File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
    start(fakepyfile,mainpyfile)
  File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
    exec(open(mainpyfile).read(),  __main__.__dict__)
  File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'discord_buttons'

[Program finished]```
#

Even though it is installed

maiden fable
#

use dpy 2.0 or a fork instead

red sundial
#

or if you still wanna use this check the docs for discord-buttons

#

and see how to import and install it there

slate swan
#
act = input('What activity do you want your bot to do? ')

bot = commands.Bot(command_prefix=prefix, activity=discord.Activity(type=discord.ActivityType.act
maiden fable
#

act is a string

slate swan
#

ok how do imake the act = the act

#

ok yes so.................?

maiden fable
#

u can instead do discord.ActivityType["act"]

slate swan
#

ok

#

u are smart

maiden fable
#

!e

from enum import Enum
class A(Enum):
    name = 1
print(A["name"].value)
slate swan
#

jk

unkempt canyonBOT
#

@maiden fable :white_check_mark: Your eval job has completed with return code 0.

1
maiden fable
brisk reef
#

does anybody know how to make a command so that bot joins a VC, reads a MP3 file and leaves (I dont know if there is any difference but Im in replit)?

maiden fable
#

!d discord.VoiceChannel.connect

unkempt canyonBOT
#

await connect(*, timeout=60.0, reconnect=True, cls=<class 'discord.voice_client.VoiceClient'>)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Connects to voice and creates a [`VoiceClient`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceClient "discord.VoiceClient") to establish your connection to the voice server.

This requires [`Intents.voice_states`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.voice_states "discord.Intents.voice_states").
maiden fable
#

!d discord.VoiceClient.play

unkempt canyonBOT
#

play(source, *, after=None)```
Plays an [`AudioSource`](https://discordpy.readthedocs.io/en/master/api.html#discord.AudioSource "discord.AudioSource").

The finalizer, `after` is called after the source has been exhausted or an error occurred.

If an error happens while the audio player is running, the exception is caught and the audio player is then stopped. If no after callback is passed, any caught exception will be displayed as if it were raised.
brisk reef
#

thanks

sacred sigil
#

creating a discord bot bump checker where it checks if a bump is availble for my server and dms me to bump it. How do I check for it?

maiden fable
#

scrape the website

sacred sigil
#

yeah that was my initial method

#

idk how to scrape tho

maiden fable
#

!pypi beautifulsoup4

unkempt canyonBOT
sacred sigil
#

if yk how to use b64 and implement it in discord could u help me?

drifting vigil
#

@maiden fable
@client.event async def on_command_error(ctx, error): print(ctx.command.name+" invoked by unauthorized user") print(error)
did this what else do I need?

maiden fable
#

I don't sorry

maiden fable
#

it triggers if there is any error, even a KeyError or ValueError or smth

#

!d isinstance

unkempt canyonBOT
#

isinstance(object, classinfo)```
Return `True` if the *object* argument is an instance of the *classinfo* argument, or of a (direct, indirect, or [virtual](https://docs.python.org/3/glossary.html#term-abstract-base-class)) subclass thereof. If *object* is not an object of the given type, the function always returns `False`. If *classinfo* is a tuple of type objects (or recursively, other such tuples) or a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union) of multiple types, return `True` if *object* is an instance of any of the types. If *classinfo* is not a type or tuple of types and such tuples, a [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") exception is raised.

Changed in version 3.10: *classinfo* can be a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union).
maiden fable
#
if isinstance(error, commands.MissingPermissions):
    await ctx.send("Unauthorized user")
else:
    raise error
#

BTW the else statement is compulsory

drifting vigil
#

this should be in the same function right?

dire folio
#

Ye

drifting vigil
#

and what if I want to send unauthorized to channel...

#

oh got it

#

sorry

#

🤣

onyx geyser
#
  File "main.py", line 504, in <module>
    bot.run(os.getenv("TOKEN"))
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 678, in run
    return future.result()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 658, in runner
    await self.start(*args, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 621, in start
    await self.login(*args, bot=bot)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 472, in login
    await self.http.static_login(token.strip(), bot=bot)
AttributeError: 'NoneType' object has no attribute 'strip'```
#

why doesn't it work?

slim ibex
#

the token object is None

#

which is why the error is being raised

soft lynx
#

i have a command where a user can give themself a role
i want my bot to renickname that user the last three letters of the name of that role
how would i go about this?

weary mirage
#

can I use colors in messages my discord bot sends?

slim ibex
unkempt canyonBOT
#
Huh? No.

No documentation found for the requested symbol.

slim ibex
#

🧐

#

Oh wait

#

that returns a book

#

bool*

weary mirage
#

can you give an example how?

slate swan
#

!d discord.Member.edit

unkempt canyonBOT
#

await edit(*, nick=..., mute=..., deafen=..., suppress=..., roles=..., voice_channel=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the member’s data.

Depending on the parameter passed, this requires different permissions listed below...
slim ibex
#

^

#

cringe that it’s case sensitive but yeah

onyx geyser
slate swan
ruby flame
#

hello... pls suggest alternativez to discord.py... stable....

slate swan
#

wait let me screenshot it

unkempt canyonBOT
weary mirage
#

was I pinged twice?

slate swan
#

yes

weary mirage
#

twice**

#

can you link the documentation for it

#

or an example of how

slate swan
#

this is a good way for color text

ruby flame
slate swan
ruby flame
#

what about hikari?

slate swan
#

🧍‍♂️

ruby flame
#

its not fully developed or what?

slate swan
#

you can if you dont want a fork of dpy

weary mirage
#

oh, thank you

ruby flame
#

woah dude... easy easy

slate swan
#

lol

flint isle
slim ibex
slate swan
#

just use disnake or any other fork

#

which has buttons ofc

flint isle
#

Ok

slate swan
#

!pypi discord-buttons

unkempt canyonBOT
slim ibex
#

!pypi nextcord

unkempt canyonBOT
slim ibex
#

!pypi pincer

unkempt canyonBOT
slate swan
#

just use any fork lol

weary mirage
#

could you give an example of code for messages with colored text?

slate swan
#

wdym

weary mirage
#

I'm having trouble understanding how I should add it from just what you've linked me

weary mirage
# slate swan wdym

for my discord bot, the bit of code that would send a message with colored text

slate swan
#

you can use that or codeblocks

slim ibex
#

!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
#

other lans

#

i have this code ```python
class closebutton(nextcord.ui.View):
def init(self):
super().init()
self.view = None

        @nextcord.ui.button(label="🔒", style=nextcord.ButtonStyle.gray)
        async def closebtn(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
            user = interaction.user
            emb=nextcord.Embed(title="🔒 Close Ticket", description=f"Είσαι σίγουρος οτι θέλεις να διαγράψεις το Ticket σου?", color=color, timestamp=datetime.now())
            emb.set_author(name=user.name, icon_url=user.avatar.url)
            await interaction.response.send_message(embed=emb, ephemeral=True)

class ticket1(nextcord.ui.View):
        def __init__(self):
            super().__init__()
            self.view = None

        @nextcord.ui.button(label="💎", style=nextcord.ButtonStyle.gray)
        async def ticketbut(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
                guild = interaction.guild
                user = interaction.user
                name = 'ticket'
                view1 = self.closebutton()
                category = nextcord.utils.get(interaction.guild.categories, name=name)
                channel = await guild.create_text_channel(f'🎫Ticket-{user.name}', category=category)
                await channel.set_permissions(interaction.guild.default_role, send_messages=True, read_messages=False)
                await channel.set_permissions(user, view_channel = True)
                await channel.set_permissions(guild.default_role, connect = False, view_channel = False)
                await channel.send(f"{user.mention}")
                emb=nextcord.Embed(title="🎫 Ticket Category", description=f"Επέλεξε από το παρακάτω `menu` την κατηγορία που ταιριάζει το **__Ticket__** σου.", color=color, timestamp=datetime.now())
                emb.set_author(name=user.name, icon_url=user.avatar.url)
                emb2=nextcord.Embed(title="🎫 Ticket Channel Created!", description=f"Έλεγξε το {channel.mention} για να ανοίξεις το **__Ticket__** σου.", color=color, timestamp=datetime.now())
                emb2.set_author(name=user.name, icon_url=user.avatar.url)
                await channel.send(embed=emb, view=view1)
                await interaction.response.send_message(embed=emb2, ephemeral=True)
But i get this error when i press the 💎 button
`AttributeError: 'ticket1' object has no attribute 'closebutton'`
slim ibex
#

for what language

slate swan
slim ibex
slate swan
#

@weary mirage

slim ibex
#

oh that

weary mirage
#

mhm

slim ibex
#

forgot you could do that

slate swan
#

just codeblocks

weary mirage
#

can I have it be multiple colors in just one message?

slate swan
#

no

#

their code blocks

#
hi
something
#

see

#

first one is in ruby and the other one is in py

#

and they get separated

weary mirage
#

could you give an example of the colored text code bock already written

slate swan
#
+ im green
- im red
#

theirs more examples in the ss

weary mirage
#

... and this will work for what a discord bot is sending? O.o

slate swan
#

yes a discord bot can send code blocks

slate swan
weary mirage
#

could you give... an example... of what the code would look like on python for that bit please

slim ibex
slate swan
#

how i get server icon and avatar url in disnake

weary mirage
#

okay, thank you

slate swan
slate swan
magic ore
slim ibex
slate swan
#

but were talking about code blocks

magic ore
#

that is a code block

slate swan
#

yes but with languages like diff

weary mirage
#

I put this

slate swan
weary mirage
slate swan
proven granite
#

When will slash command support be added if it isn't already?

weary mirage
#

should or shouldn't o.o

slate swan
#

dpy has stopped being maintained

proven granite
# slate swan wont

It has to because isn't discord going to have bots without slash commands not work

slim ibex
slate swan
weary mirage
#

I don't know what other i there is, I put a space and I got the same result, Okimii

proven granite
weary mirage
#

oh wait, I think I got you

slate swan
slate swan
weary mirage
#

I added a space to it, and I'm not getting it o.o

keen talon
weary mirage
#

do I need to import something?

proven granite
keen talon
#
+ I'm green 
- I'm red
slate swan
slate swan
#

my fault

weary mirage
#

new line? o.o

slate swan
weary mirage
#

just the first one, okay

slate swan
#

!e

print("Hello\nWorld")
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

001 | Hello
002 | World
slate swan
#

makes a new line

proven granite
slate swan
weary mirage
#

I'm getting this result now :P

keen talon
slim ibex
proven granite
weary mirage
slate swan
slate swan
slate swan
slate swan
#

thats a discord code block

weary mirage
#

this is what I got o.o

slate swan
#

seems right

weary mirage
#

can you send me the official documentation page for this

slate swan
#

there is none

#

their code blocks

weary mirage
#

:P

slate swan
#

ai

#

👴🏿👴🏿

#

🙏🏽🙏🏽

weary mirage
#

has anybody got code for color codes? I'm having trouble figuring out how to use this o.o