#discord-bots

1 messages · Page 904 of 1

vale wing
#

Can you please put it like this
```py
your_code

final iron
#

It's guild not server

#

!d discord.Message.guild

unkempt canyonBOT
slate swan
# vale wing Can you please put it like this \`\`\`py your_code ```
@bot.command()
async def serverinfo(ctx):
        """Shows server info"""

        server = ctx.message.server

        roles = str(len(server.roles))
        emojis = str(len(server.emojis))
        channels = str(len(server.channels))

        embeded = discord.Embed(title=server.name, description='Server Info', color=0xEE8700)
        embeded.set_thumbnail(url=server.icon_url)
        embeded.add_field(name="Crée le:", value=server.created_at.strftime('%d %B %Y at %H:%M UTC+3'), inline=False)
        embeded.add_field(name="Server ID:", value=server.id, inline=False)
        embeded.add_field(name="Membres sur le serveur:", value=server.member_count, inline=True)
        embeded.add_field(name="Server owner:", value=server.owner, inline=True)

        embeded.add_field(name="Default Channel:", value=server.default_channel, inline=True)
        embeded.add_field(name="Server Region:", value=server.region, inline=True)
        embeded.add_field(name="Verification Level:", value=server.verification_level, inline=True)

        embeded.add_field(name="Nombre de rôle:", value=roles, inline=True)
        embeded.add_field(name="Nombre d'émojis:", value=emojis, inline=True)
        embeded.add_field(name="Nombre de Channel:", value=channels, inline=True)

        await ctx.send(embed=embeded)```
unkempt canyonBOT
#

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

001 | [1, 2, 3] <class 'list'>
002 | {'1': 2, '3': 4} <class 'dict'>
003 | "hello there" <class 'str'>
slate swan
torn sail
#

Maybe you mean system_channel?

slate swan
#
@bot.command()
async def serverinfo(ctx):
        """Shows server info"""

        guild = ctx.message.guild

        roles = str(len(guild.roles))
        emojis = str(len(guild.emojis))
        channels = str(len(guild.channels))

        embeded = discord.Embed(title=guild.name, description='Server Info', color=0xEE8700)
        embeded.set_thumbnail(url=guild.icon_url)
        embeded.add_field(name="Crée le:", value=guild.created_at.strftime('%d %B %Y at %H:%M UTC+3'), inline=False)
        embeded.add_field(name="Server ID:", value=guild.id, inline=False)
        embeded.add_field(name="Membres sur le serveur:", value=guild.member_count, inline=True)
        embeded.add_field(name="Server owner:", value=guild.owner, inline=True)

        embeded.add_field(name="Default Channel:", value=guild.default_channel, inline=True)
        embeded.add_field(name="Server Region:", value=guild.region, inline=True)
        embeded.add_field(name="Verification Level:", value=guild.verification_level, inline=True)

        embeded.add_field(name="Nombre de rôle:", value=roles, inline=True)
        embeded.add_field(name="Nombre d'émojis:", value=emojis, inline=True)
        embeded.add_field(name="Nombre de Channel:", value=channels, inline=True)

        await ctx.send(embed=embeded)
#

oh ok

pliant gulch
#

Except for any non-serialisable objects, E.g Message, Guilds Members etc

slate swan
#

what are webhook embed docs

slate swan
slate swan
#
@bot.command(name="claim",description="This is the description of your command. both name and description are optional",pass_context=True)
async def _claim(ctx, *, reason=None):
        username, user = reason.split(':')
        if not get(ctx.guild.roles,id=int(952619437427654696)) in ctx.author.roles:
          return await ctx.send("you dont have role 3l make ticket to apply")
huk = "webhook"
disc =DiscordWebhook (url =huk )
embed = DiscordEmbed(title='Alexs' , description='ok', color='264dd9')
disc.add_embed(embed)
response = disc.execute()``` webhook sends anyway without command
manic wing
errant fossil
#

Is anyone pretty familiar with it?

manic wing
lime trench
#

Hello, when im trying to make the bot add a default emoji to a message, it is throwing

discord.ext.commands.errors.EmojiNotFound: Emoji ":star:" not found.

.How can i get the bot to recognize normal emotes? i cant find a way

like for example in the command, id do .add (message id here) (emoji here)

errant fossil
manic wing
#

!d discord.ext.commands.Bot.change_presence

unkempt canyonBOT
#

await change_presence(*, activity=None, status=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Changes the client’s presence.

Example

```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
```   Changed in version 2.0: Removed the `afk` keyword-only parameter...
errant fossil
#

I'll try, thx

lime trench
#

yea i just read about it, how can i get it in unicode tho

manic wing
#

there are some websites where you type in the emoji and it gives you the unicode

#

some command like that

lime trench
#

ill find a way to do it wihtin the commsnd

rain olive
manic wing
#

!charinfo 👍

unkempt canyonBOT
lime trench
#

yea

fervent surge
#

are there docs for dpy2?

manic wing
#

i think

fervent surge
#

oh ok, thx

manic wing
#

realistically noone ever uses docs

#

you just print(dir(obj)) to get all the info you need

#

or look at the sourcecode

pliant gulch
#

I prefer reading source over the docs

manic wing
#

agreed

pliant gulch
#

But then again, it's mostly just preference some people won't be able to understand

manic wing
#

if you know how to, sourcecode > docs

fervent surge
#

hmmm

#

well, i want to know how to make a dropdown

#

i am not good at reading source code

#

i have realised

haughty quartz
#

just wondering, is it possible to host multiple bots on a VPS

manic wing
#

meh reading dropdown sourcecode would probably be an assache anyway

manic wing
haughty quartz
#

thanks!

fervent surge
#

for specifically dropdowns are pycord and dpy the same?

pliant gulch
#

You can assume it will work

fervent surge
#

but I know that there are tiny (tiny) changes

pliant gulch
#

Try it out and see then

fervent surge
#

alright

slate swan
#

how to delete the webhook on on_webhooks_update event?

manic wing
unkempt canyonBOT
#

await delete(*, reason=None, prefer_auth=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Deletes this Webhook.
manic wing
#

what does said time command do?

final iron
#

Can you describe what the time command will do?

slate swan
#

time you mean the current time?

slate swan
# manic wing !d discord.Webhook.delete

:P i did, basically this event returns the channel. and when i do channel.webhook.delete(). it gives this error 'TextChannel' object has no attribute 'webhook' so ya

fervent surge
#

for dropdowns, is it mandatory to create a sub-class?

#

cuz im watching a yt vid (cuz i dont understand anything else) and I don't rlly trust it that much

#

idk tho

manic wing
slate swan
pliant gulch
slate swan
#

!d discord.on_webhooks_update

unkempt canyonBOT
#

discord.on_webhooks_update(channel)```
Called whenever a webhook is created, modified, or removed from a guild channel.

This requires [`Intents.webhooks`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.webhooks "discord.Intents.webhooks") to be enabled.
manic wing
#

cringe

pliant gulch
#

Relative time with formatters

manic wing
#

i mean seems pretty pointless considering each message literally has a timestamp on it

slate swan
#

i get ttt has no attribute current_player

fervent surge
#

ok, in dropdowns, is there a way to hide the view ONLY to a member after they have selected it

tidal hawk
#

ephemeral=True

slate swan
#

no

tidal hawk
#

Or what

slate swan
#

he didnt mean tht

tidal hawk
#

oh

slate swan
#

he wanted to hide the view for a single member

#

which isnt possible according to my knowledge

fervent surge
#

well, i dont need that specificaly

#

i just need a solution that the user can only pick once

slate swan
vast gale
final iron
#

🗿

somber sky
#

anyone know how to make a command where it takes everyone off a role you mention

manic wing
#

you would create a webhook with the mention in the content and set allowed mentions to none

somber sky
#

you didnt understand

quaint epoch
somber sky
#

ik i didnt

#

idk how to explain it

#

pretty much the role you mention everyone on that role will be remvoed from the role if that makes sense

quaint epoch
quaint epoch
#

hmmm

#

!d disnake.Role.members

unkempt canyonBOT
quaint epoch
#

then just await member.remove_role(role)

tacit token
#
@client.event
async def on_message_delete(message):
    with open('log.json', 'r', encoding='utf-8') as f:
        guilds_dict = json.load(f)
        embed = discord.Embed(title=f"deleted a message {message}",description="", color=0xFF0000)
        embed.add_field(name=message.content, value=f"This is the message that he has deleted",inline=True)
        channel_id = guilds_dict[str(client.guild.id)]
        await client.get_channel(int(channel_id)).send(embed=embed)
channel_id = guilds_dict[str(client.guild.id)]

AttributeError: 'Bot' object has no attribute 'guild'

quaint epoch
#

use message.guild.id

#

because the bot doesn't have a singular guild

ivory shadow
#

WOOOOOO I DID IT

fervent surge
#

is there a way, that when Select Callback is called, to find (if exists) the last option selected?

cerulean olive
fervent surge
#

ok, does discord.ext.commands.Bot not have slash_command

#

how to make slash commands (dpy 2.0)

leaden jasper
#

@fervent surge app_commands

fervent surge
#

that doesn't work

#

im just reallly confused

#

why is there no 2.0 docs?

slate swan
fervent surge
#

HuH?

slate swan
fervent surge
#

should I just use pycord

slate swan
#

They only started updating it like week ago I don’t think so yet

fervent surge
#

like, atleast they have docs

slate swan
fervent surge
#

what would I even have to change

#

not much I think

slate swan
#

@bot.command(name="claim",description="This is the description of your command. both name and description are optional",pass_context=True)
async def _claim(ctx, *, reason=None):
        username, user = reason.split(':')
        if not get(ctx.guild.roles,id=int(952619437427654696)) in ctx.author.roles:
          return await ctx.send("you dont have role 3l make ticket to apply")
webhook = DiscordWebhook(url= os.environ['alexlol'])
embed = DiscordEmbed(title=f'{user}', description= 'ok {username}', color= '264dd9' )```
#

Auto sends requests to web hook

#

Even thought it’s command

manic wing
final iron
#

What are you even trying to do

fervent surge
#

how to install pycord????

manic wing
fervent surge
#

i am soooooo confused

#

i can't even explain it

#

and 100000% im not using disnake

#

ill try again tomorrow i suppose

#

yay

manic wing
slate swan
manic wing
sick birch
slate swan
flat solstice
#

Hi, I seem to be having some issues getting my bot to run a function. It's producing this error```py
File "C:\Users\Teagan\Documents\Coding\Zupie\bot\cogs\users.py", line 47, in userinfo
await userinfo(interaction, member)
NameError: name 'userinfo' is not defined

The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Teagan\Documents\Coding\Zupie\env\lib\site-packages\discord\app_commands\tree.py", line 696, in _call_context_menu
await ctx_menu._invoke(interaction, value)
File "C:\Users\Teagan\Documents\Coding\Zupie\env\lib\site-packages\discord\app_commands\commands.py", line 659, in _invoke
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'User Info' raised an exception: NameError: name 'userinfo' is not defined```I would put the _userinfo inside of my cog class but I want the context menu function to be able to call _userinfo which it won't be able to do if it's inside the class as d.py 2.0 context menu's can't be in classes and so don't have self.
This is my code: https://paste.pythondiscord.com/matugudapa

slate swan
slate swan
buoyant igloo
flat solstice
#

So I'm getting this errorpy Failed to Load Extension cogs.users ExtensionFailed: Extension 'cogs.users' raised an error: ImportError: cannot import name 'Context' from 'discord' (C:\Users\Teagan\Documents\Coding\Zupie\env\lib\site-packages\discord\__init__.py)when trying to import Context like thispy from discord import Member, User, Interaction, Embed, app_commands, Context, is that not the way to do it? (d.py 2.0)

torn sail
#

from discord.ext.commands import Context

flat solstice
#

thanks

#

no wonder it wasn't wokring

modest plover
somber sky
#

this is gonna be hard to explain but i have a football sign command where when you run it, it gives the person the role im trying to find out how to make it where you can only sign a certain amount of people and when u get to that amount it doesnt work

#

think of it as a -giverole command but you can only do it a certain amount of times for each role

#

every role has a max of (amount) of players to sign

#

thats an example "roster" is the amount

ancient timber
#

so I'm having this issue where even with every intent enabled, on_message doesn't seem to have any content

torn sail
#

!d discord.Role.members

unkempt canyonBOT
ancient timber
#

it does however get a message object py <Message id=952709353469796387 channel=<TextChannel id=819070016036667412 name='standing-chat' position=21 nsfw=False news=False category_id=760303039831212042> type=<MessageType.default: 0> author=<Member id=668304274580701202 name='StandingPad' discriminator='9655' bot=False nick=None guild=<Guild id=760302595808952352 name='The Random Server' shard_id=0 chunked=True member_count=12>> flags=<MessageFlags value=0>>

torn sail
somber sky
ancient timber
# torn sail Can u show where u define ur intents

I have a wrapper class, so the intents and registering the intents looks something like:py discord_intents = discord.Intents.default() discord_intents.members = True discord_intents.presences = True discord_intents.messages = True commands.Bot.__init__(self, command_prefix = ">", intents=discord_intents)

torn sail
somber sky
#

and i want to make it where the team owner can only sign 21 people

torn sail
somber sky
ancient timber
#

thanks

supple thorn
torn sail
somber sky
torn sail
#

if len(role.members) > some_int: # do some stuff

ivory shadow
somber sky
slate swan
#

ehhhh idk why this doesnt work, also there is no errors ```py
@client.event
async def on_guild_channel_create(channel):
start_time = time.time()
guild = channel.guild
members = []
channel_names = []
async for x in guild.audit_logs(action = disnake.AuditLogAction.channel_create, limit = 2):
members.append(x.user.id)
channel_names.append(x.target.name)

if members[0] == members[1]:
punished = disnake.utils.get(guild.members, id = int(members[0]))

punished_roles = [x.id for x in punished.roles]
if whitelisted[0] or whitelisted[1] or whitelisted[2] in punished_roles:
  return
try:  
  await punished.kick(reason = "Created Channels")
except Exception as e:
  print(f"Error: {e}")   
final_time = time.time()
total = int(round(final_time - start_time))
text = str(datetime.timedelta(seconds=total))
channel_name =', '.join(channel_names)  
em = disnake.Embed(title="Action | Created Channels")
em.add_field(name=f"{punished} created channels({channel_name})",value=f"![danger](https://cdn.discordapp.com/emojis/952618953878945853.webp?size=128 "danger") {punished} was kicked for creating channels. ", inline = False)
em.add_field(name="Time taken", value= f"{text}s", inline = False)
em.set_author(name= guild.name)
channel = client.get_channel(security_channel)
await channel.send(embed=em)```
#

security_channel is a variable that has the channel id ^

torn sail
supple thorn
#

Oh wait

#

Well that could also work

torn sail
#

Well if you do < then adding to the roster and role and stuff will be in an extra indent

#

Which I personally don’t like

slate swan
#

i just dont know why it doesnt returns a error or work

somber sky
slate swan
supple thorn
slate swan
#

@slate swan wake up, and help me wit dat smil

somber sky
#

i need to make it where when they hit the limit then they are not able to

torn sail
supple thorn
#

You can just do what master said

supple thorn
somber sky
#

ik that so how do i make it where it stops working if i just put that it wont do anything will it?

slate swan
slate swan
#

also i've removed the try except and the samething

slate swan
torn sail
slate swan
#

anti create channel

silent ermine
#

nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'id'

@bot.command()
async def massban(ctx):
users = [id1, id2, id3]
    for user in users:
        async with ctx.channel.typing():
            userban = bot.get_user(user)
            await ctx.guild.ban(user=userban, reason='Massban')
            await asyncio.sleep(10)
    await ctx.send("Done")```

trying to ban only a few members, but it says that the return of bot.get_user is none
slate swan
somber sky
torn sail
silent ermine
slate swan
#
for user in users:
  await ctx.guild.ban(user= user, reason = "massbad")```
slate swan
somber sky
slate swan
#

wait i didnt see that

silent ermine
slate swan
silent ermine
torn sail
silent ermine
torn sail
#

Oh yes

slate swan
silent ermine
# slate swan if the users id is valid then, that should work w/o the `client.get_user`

nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'int' object has no attribute 'id'

@bot.command()
async def massban(ctx, *, users):
    
    for user in users:
        async with ctx.channel.typing():
            # simulate something heavy
            userban = bot.get_user(user)
            newUser = int(user)
            await ctx.guild.ban(user=newUser, reason='Massban')
            await asyncio.sleep(10)
    await ctx.send("Done")```
sick birch
silent ermine
sick birch
#

fetch them instead

#

fetch_user() make an API call so it's guaranteed to return an object given it's a valid ID

silent ermine
#

so await user.fetch_user()

torn sail
sick birch
#

That just creates a snowflake

sick birch
torn sail
#

Won’t all the ban need is the id?

silent ermine
sick birch
#

For banning and unbanning yes, a snowflake will do

slate swan
torn sail
#

So wouldn’t fetch_user be an un needed api call? Unless you need other info about the user

silent ermine
torn sail
#

bot.fetch_user

silent ermine
#

i also just noticed that the logo of the server updated

silent ermine
#

wrong place soz

#

nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10013): Unknown User

but it is a user

torn sail
#

Well it couldn’t find it

silent ermine
torn sail
silent ermine
#

ok i have yours

slate swan
#

maybe the bot doesnt have mutual servers with the user

silent ermine
torn sail
#

I think the id may have to be an int

slate swan
#

the bot should have mutual servers

#

with the user idk

silent ermine
slate swan
torn sail
silent ermine
silent ermine
slate swan
#

for example dyno?

silent ermine
silent ermine
slate swan
slate swan
silent ermine
#

can I do that in the func though?

slate swan
silent ermine
#

no but that will give error, maybe user = nextcord.User

slate swan
silent ermine
slate swan
silent ermine
#

after the for loop

#

newUsertoban = user.nextcord.User?

torn sail
#

That wouldn’t work

slate swan
silent ermine
torn sail
unkempt canyonBOT
#

class nextcord.ext.commands.Greedy```
A special converter that greedily consumes arguments until it can’t. As a consequence of this behaviour, most input errors are silently discarded, since it is used as an indicator of when to stop parsing.

When a parser error is met the greedy converter stops converting, undoes the internal string parsing routine, and continues parsing regularly.

For example, in the following code:

```py
@commands.command()
async def test(ctx, numbers: Greedy[int], reason: str):
    await ctx.send("numbers: {}, reason: {}".format(numbers, reason))
```  An invocation of `[p]test 1 2 3 4 5 6 hello` would pass `numbers` with `[1, 2, 3, 4, 5, 6]` and `reason` with `hello`...
silent ermine
silent ermine
#

oh wait nvm

slate swan
slate swan
silent ermine
torn sail
#

commands.Greedy[nextcord.User]

silent ermine
slate swan
silent ermine
silent ermine
torn sail
#

from nextcord.ext.commands import Greedy

silent ermine
#

👍 trying now

silent ermine
#
@bot.command()
async def massban(ctx, *, users: Greedy[nextcord.User]):
    print(users)
    for user in users:
        async with ctx.channel.typing():
            await ctx.guild.ban(user=user, reason='Massban')
            await asyncio.sleep(10)
    await ctx.send("Done")```
heavy folio
#

why are you triggering channel.typing for every user

#

let it trigger outside of the for loop

silent ermine
silent ermine
silent ermine
dense vortex
heavy folio
#

you dont seperate it with ,

silent ermine
dense vortex
#

Welp this is all I managed to do and my bot doesn't stop saying howdy now

heavy folio
#

just .ban user1 suer2 user3 user4

#

and i recommend you try except ban()

silent ermine
torn sail
heavy folio
#

yeah

silent ermine
silent ermine
heavy folio
#

what

#

do you even know how greedy works

silent ermine
heavy folio
#

!d discord.ext.commands.Greedy

unkempt canyonBOT
#

class discord.ext.commands.Greedy```
A special converter that greedily consumes arguments until it can’t. As a consequence of this behaviour, most input errors are silently discarded, since it is used as an indicator of when to stop parsing.

When a parser error is met the greedy converter stops converting, undoes the internal string parsing routine, and continues parsing regularly.

For example, in the following code:

```py
@commands.command()
async def test(ctx, numbers: Greedy[int], reason: str):
    await ctx.send("numbers: {}, reason: {}".format(numbers, reason))
```  An invocation of `[p]test 1 2 3 4 5 6 hello` would pass `numbers` with `[1, 2, 3, 4, 5, 6]` and `reason` with `hello`...
silent ermine
#

so I can ban them even if not in mutual servers

torn sail
#

try using nextcord.Object

#
users = [1234456634543, 2345345345343]
for user in users:
    await guild.ban(discord.Object(id=user))
slim ibex
#

you shouldn't need that for a mass ban

silent ermine
torn sail
#

well user wasnt found

silent ermine
torn sail
#

yeah im not sure

silent ermine
#

k

slate swan
#

so im using discord commands.Paginator and im curious if i can have the reactions have multiple functions rather than just going next or back is there anyway i can do that?

#
 paginator.add_reaction('🏠', "first")
        paginator.add_reaction('🎉', "next")
        paginator.add_reaction('🛠️', "next")
        paginator.add_reaction('🎮', "next")
        paginator.add_reaction('🔨', "last")
        embeds = [embed , embed2, embed3, embed4, embed5]
        await paginator.run(embeds)```
heavy folio
#

commands.Paginator?

#

whats discord utils/paginator

slate swan
heavy folio
#

idt that supports reactions

slate swan
#

ohh

somber sky
#

does anyone know how to find a role id by the role name?

#

or is that not possible

#

im trying to make a command it requires a role id but i want it to be a public bot so it has to find the id

cold matrix
#

get a guild's list of roles, then match the name of the role u r looking for, then get the id

#

a role should have .id attr

somber sky
#

its a football bot i have this rn

supple thorn
#

damn

somber sky
#

i need to get they id;s

#

id's

cold matrix
#

go through every role in guild.roles, match role.name to the name u r looking for, then get id using role.id

#

makes sense?

supple thorn
#

!d discord.utils.get

unkempt canyonBOT
#

discord.utils.get(iterable, /, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").

When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.

To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.

If nothing is found that matches the attributes passed, then `None` is returned.

Changed in version 2.0: The `iterable` parameter is now positional-only.

Changed in version 2.0: The `iterable` parameter supports [asynchronous iterable](https://docs.python.org/3/glossary.html#term-asynchronous-iterable "(in Python v3.10)")s...
daring olive
#

good that you linked the docs and stuff

cold matrix
#

my bad

daring olive
#

but we'd prefer if you just explain :) thanks

cold matrix
#

yep ok

jagged aurora
#

does anyone know of a eval cog

#

my giveaway cog broke and cleared the json file

#

so ima just use an eval command to finish the giveaway and pick 4 winners

silent ermine
#

actually go to dms

jagged aurora
#

ok

sick birch
jagged aurora
sick birch
#

Don't know about replit, should get off of replit anyway

jagged aurora
#

I use it for small per server projects

slate swan
#

replit😔

maiden fable
#

👀

silent ermine
#

ok

jagged aurora
#

didnt work

jagged aurora
#

me?

boreal ravine
#

no, 9Dee

boreal ravine
boreal ravine
cold matrix
# somber sky wym

something like:

role = discord.utils.get(guild.roles, name="Name of role")

if role:
   role_id = role.id

im on mobile rn so have some patience pls

slate swan
#

variable naming

cold matrix
slate swan
#

id is a built in

cold matrix
#

fr? ok

#

be careful though, if there is no such role with said name it will return None

slate swan
unkempt canyonBOT
#

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

<built-in function id>
maiden fable
unkempt canyonBOT
#
id

id(object)```
Return the “identity” of an object. This is an integer which is guaranteed to be unique and constant for this object during its lifetime. Two objects with non-overlapping lifetimes may have the same [`id()`](https://docs.python.org/3/library/functions.html#id "id") value.

**CPython implementation detail:** This is the address of the object in memory.

Raises an [auditing event](https://docs.python.org/3/library/sys.html#auditing) `builtins.id` with argument `id`.
cold matrix
#

qight thanks

#

aight

slate swan
unkempt canyonBOT
#

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

140265660965488
slate swan
#

i.e ^

cold matrix
boreal ravine
#

Right

boreal ravine
slate swan
#

lol

cold matrix
#

well thats not what i.e is generally used for

#

now you know

slate swan
#

not really on topic ~~ idc~~

cold matrix
#

yea yea lets move on

maiden fable
cold matrix
slate swan
#

!ot

unkempt canyonBOT
maiden fable
#

Thanks oki

sage otter
#

Man dpy 2.0 is gonna have so many breaking changes it’s not even funny. 💀

#

They made all extension related methods async

maiden fable
#

IKR

boreal ravine
#

yep

maiden fable
#

😔 I hate its slash commands impl

boreal ravine
#

why did they even choose to do that

sage otter
#

It’s all by design of Rapptz

#

He doesn’t do anything without reason

boreal ravine
#

or was it merged

boreal ravine
boreal ravine
sage otter
#

The raw socket receive events aren’t fired anymore unless you have some option turned on in your Client instance constructor as well.

maiden fable
#

I need to specify commands.Cog.listener() name now

slate swan
#

smh

sage otter
#

This rewrite for my bot I’m going to have to do when this releases is gonna hurt 🥲

solar summit
#

An if statement could work?

#

I mean if you wanna do that then sure

neat tartan
#

creating a whitelist of server id's and then a simple if statement comparing if the server the command was sent in is in the whitelist should be all it takes

nimble thorn
#

I might be slow but all of my cogs just tanked. I was reading the previous chats and it looks like Rapptz made everything extension related async, so I am getting errors like

#
RuntimeWarning: coroutine 'BotBase.add_cog' was never awaited
  client.add_cog(Moderation(client))

for a moderation cog for example

#

What is the solution to fixing this

hushed galleon
#

youd make your setup function async and then await add_cog

nimble thorn
#
async def setup(client):
    await client.add_cog(Moderation(client))
#

so something like that?

hushed galleon
#

yeah that looks right

unkempt canyonBOT
#

discord/ext/commands/bot.py line 531

async def add_cog(```
slate swan
#

yup its a coroutine now

slim ibex
#

but it doesn't have to be async? i have never seen an async cog load method

#

oh wait

slate swan
#

it is now

slim ibex
#

ok thats cool

maiden fable
#

At least now we can run async functions in it

nimble thorn
#

that worked but now in the setup I am getting a different error

#
for i in range(len(cogs)):
    cogs[i].setup(client)
#

it is in main.py and is returning "RuntimeWarning: coroutine 'setup' was never awaited
cogs[i].setup(client)" where cogs is a list of the cogs of the bot

hushed galleon
#

wait you manually load your extensions?

nimble thorn
#

yeah its not the best, I throw them all into a list and then iterate through and set them up

hushed galleon
#

well the setup function dpy recommends is intended as part of their extensions system where youd use bot.load_extension('path.to.module') to load each file

nimble thorn
#

oh ok, I can give that a try

hushed galleon
#

i mean, they made that method require awaiting too

nimble thorn
#

of course it gives the same

RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
  client.load_extension('cogs/mod.py')
#

yeah, where do I await?

hushed galleon
#

the... method call?

#

also it has to be dot-qualified, as if you were importing it

#

in your case itd be cogs.mod

nimble thorn
#

so ?

await client.load_extension('cogs.mod.py')
hushed galleon
#

without the py

nimble thorn
#

oh right

hushed galleon
#

just like how youd write import random and not import random.py

nimble thorn
#

yeah that makes sense

hushed galleon
#

aight im off to bed now

nimble thorn
#

epic, thanks for the help

boreal ravine
slate swan
queen linden
#
if message.attachments:
            em = discord.Embed()
            em.set_image(url=message.attachments_url)
            em.color = 0x2f3136
            await channel.send(embed=em)

          else:

error: AttributeError: 'Message' object has no attribute 'attachments_url'

how do i put the attachment to the embed image

honest shoal
queen linden
honest shoal
#

only images and gifs can be

queen linden
honest shoal
queen linden
honest shoal
#

like you need to set them up by endswith('.mp4') kind of stuff

slate swan
#

is there any way i can activate cooldown only during specific instances off a command? please ping me if you answer this

honest shoal
slate swan
cosmic agate
#

hi guys

honest shoal
inland crest
#

Hello can anyone guide me on how to make an economy system in my bot

inland crest
#

Python

inland crest
slate swan
cosmic agate
inland crest
#

Anything as long as it works

cosmic agate
#

????

inland crest
#

I used to watch swas.py it doesnt work

cosmic agate
#

hmm

inland crest
#

Its outdated apparently

cosmic agate
#

i see

slate swan
#

for example if somebody doesn't reply before timeout then they can run the command again instantly?

slate swan
#

can you tell me how to do that

slate swan
#

oh

#

yas but like if it timeouts they don't get command cooldown

honest shoal
#

yes

slate swan
#

so basically the whole command is a try: except?

cosmic agate
honest shoal
boreal ravine
#

Don't spoonfeed, they don't learn anything that way

cosmic agate
boreal ravine
honest shoal
#

why people keep such names

#

!docs discord.ext.commands.cooldown

unkempt canyonBOT
#

@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")

A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").

If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.

A command can only have a single cooldown.
slate swan
#

i don't think i can do that inside the cmd tho

boreal ravine
#

do what inside of the command?

inland crest
#

Hey kayle

boreal ravine
#

hey jord

slate swan
#

nvm i foudn it dynamic cooldown

inland crest
#

U said db which and how

#

Im not asking for spooonfeed

#

Im asking ways, dont tell me cmd tell me ways

cosmic agate
#

sed

boreal ravine
inland crest
#

Thanks

#

All of these support economy in pyhton right

boreal ravine
#

if you want something similar to json use mongo, pgsql/aiosqlite3 require you to learn CRUD operations/sql

inland crest
#

BTW in json

#

I trird using it, the path showed me cmd error

boreal ravine
inland crest
#

Have u ever used or know how to use json?

boreal ravine
#

yes

#

json is pretty easy to use

inland crest
#

Can u gimme the integrating cmd

#

Spoonfed

#

Like the path mentioning it showed an error in the path i put like......

boreal ravine
#

🗿

inland crest
#

Only tht 2 lines

honest shoal
#

that with open one?

inland crest
#

Yesss

#

@honest shoal finally

#

Tht ome

honest shoal
#

lemon_clownthat's pretty simple

inland crest
#

Ik but its showing me 2 errors last time i did, i need some spoonfeeding

honest shoal
#

well

inland crest
#

And also aside from spoonfeeding can u explain how async def works

#

Please

honest shoal
#

I can explain you the format

#

firstly import json and then with open [then your file name] as [and give it a name here]

#

then use dump() function

inland crest
#

Its main bank

#

Uk what ill remove my laptop out and try it rn

#

U explain pls

honest shoal
#

what are you trying rn?

inland crest
#

Json bank

#

Db

honest shoal
#

what's ur code at present

#

and why using json as db?

inland crest
#

Geting it out a sec

inland crest
honest shoal
#

its not a database...

honest shoal
inland crest
#

Uhhh it saves user info bal

#

Right?

honest shoal
#

you can do that, but not a good practice

inland crest
#

Wdym?

#

Privacy?

honest shoal
#

read this message ^

inland crest
#

Ic

#

So what shud i use? Postgresql?

honest shoal
#

your call

unkempt canyonBOT
#

Hey @inland crest!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

#

Hey @inland crest!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

#

Hey @inland crest!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

honest shoal
#

...

inland crest
#

how do i send?

honest shoal
#

use paste bin

inland crest
#

its saved on paste bin

honest shoal
#

copy the link and send the link here

inland crest
#

but how to put it here

#

i was thinking of not using a db but rather

honest shoal
#

why don't you use proper commands

#

this is too old way

inland crest
#

i dont get them

honest shoal
#

its actually easy instead of that shit

inland crest
#

i dont understand the cmd the async def

#

i dont use smthing i dont understand

#

its a rule i follow

honest shoal
#

then learn it

inland crest
#

thats why i cam here seeking for help

slate swan
inland crest
#
@client.command
async def snipe: ............ ```
#

this is all i understand,

honest shoal
#

the proper decorator is @wooden frigate

inland crest
inland crest
#

np i got it

inland crest
#

better del tht

#

he might come or else / she

honest shoal
tacit storm
#

@inland crest how new are you to python?

proven ore
#

any ideas why this is not working

proven ore
#

🧢

inland crest
#

??

#

nvr coded with async or discord

tacit storm
# inland crest 2 yrs

you would know what async and all that other shit is.

i learned async the first 3 days i started python

proven ore
#

2 yrs without async and decorators?

#

that's pain bruh

inland crest
#

yes thanks

proven ore
#

am i supposed to put an api key or smth

tacit storm
#

i have no clue, but it’s reading smth as a nonetype, make sure all params or kwargs are correct, etc

brazen raft
inland crest
#

!eval print(2+2)

unkempt canyonBOT
#

@inland crest :white_check_mark: Your eval job has completed with return code 0.

4
proven ore
inland crest
#

!eval ```py

unkempt canyonBOT
#

@inland crest :warning: Your eval job has completed with return code 0.

[No output]
honest shoal
inland crest
#

ok

proven ore
brazen raft
proven ore
brazen raft
#

Maybe there is a language detection option

#

Well, it doesn't detect for me

proven ore
#

oh

#

nope still same thing

slate swan
#

wats the issue KannaSip

proven ore
#

lib: googletrans

slate swan
#

probably an issue with your eval function

proven ore
#

nope same thing happens in the main code

rocky trench
#

Ive seen this issue before, u install version 3.0.0 by default. Install 4.0.0

slate swan
supple thorn
#

Jesus christ thats blinding

slate swan
#

what should i do

honest shoal
hazy oxide
hazy oxide
#

Ye

#

Oh wait

honest shoal
#

are you trying to add test guilds in disnake?

slate swan
#

english not good

honest shoal
manic wing
#

thats why i removed it

slate swan
#
@client.command(aliases = ['purge'])
async def clear(ctx, amount =11):
    if (not ctx.author.guild_permissions.manage_messages):
        await ctx.send('this command requires ``Manage Messages`` ')
        return
    amount = amount + 1
    if amount > 101:
        await ctx.send('Can not delete more than 100 messages')
    else:
        await ctx.channel.purge(Limit = amount)
        await ctx.send('Cleared Messages') 
#

await ctx.channel.purge(Limit = amount)
TypeError: purge() got an unexpected keyword argument 'Limit'

#

I have this error but I don't know why

slate swan
#

oh...

#

Thanks

slate swan
regal cove
#

i made a music bot for a while ago. But today when i was gonna use the bot i realised it wasnt working. i didnt change anything so it must have been a change to python, discord.py or youtube.dl.

This is the error i get:

Traceback (most recent call last):
  File "/home/runner/Selonbot-beta-6/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 278, in play_func
    check_queue(ctx,channel)
  File "main.py", line 241, in check_queue
    voice_client.play(FFmpegPCMAudio(URL,**FFMPEG_OPTIONS), after= lambda e: check_queue(ctx, channel))
  File "/home/runner/Selonbot-beta-6/venv/lib/python3.8/site-packages/discord/player.py", line 225, in __init__
    super().__init__(source, executable=executable, args=args, **subprocess_kwargs)
  File "/home/runner/Selonbot-beta-6/venv/lib/python3.8/site-packages/discord/player.py", line 138, in __init__
    self._process = self._spawn_process(args, **kwargs)
  File "/home/runner/Selonbot-beta-6/venv/lib/python3.8/site-packages/discord/player.py", line 147, in _spawn_process
    raise ClientException(executable + ' was not found.') from None
discord.errors.ClientException: ffmpeg was not found.

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

Traceback (most recent call last):
  File "/home/runner/Selonbot-beta-6/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/runner/Selonbot-beta-6/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/runner/Selonbot-beta-6/venv/lib/python3.8/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: ClientException: ffmpeg was not found.```
tacit storm
#

idk, but maybe something got fucked and you deleted ffmpeg

regal cove
#

hmmm

#

i didnt change anything

#

like it should be working cus i changed nothing

#

something must have changed in discord or youtube

slate swan
#

Heyyy, how do we do that for example with the ban command if someone who doesn't have the authorization the bot sends a message saying he doesn't have the authorization ?

manic wing
#

its just a command

slate swan
#

Heyyy, how do we do that for example with the ban command if someone who doesn't have the authorization the bot sends a message saying he doesn't have the authorization ?

proven ore
regal cove
regal cove
proven ore
#

such as packaging problems

regal cove
#

from discord import FFmpegPCMAudio

#

i already import ffmpeg

proven ore
boreal ravine
#

theres a way to fix that error

manic wing
regal cove
#

thats weird cus it used to work

manic wing
#

sudo apt-get install ffmpeg or whatnot

regal cove
#

alright

manic wing
#

debian based distros are cringe

boreal ravine
#

Replit is not designed for discord bots, also this @regal cove

tight mica
regal cove
#

i know

regal cove
boreal ravine
#

nice

regal cove
#

i have considered my options and decided to use it

boreal ravine
#

replit doesn't support ffmepg now btw so you can't solve that error

regal cove
boreal ravine
#

yea

placid skiff
#

did you consider that you will have problems with some block of code which normally they will work but replit mess it all up?

regal cove
#

cus it used to work just by installing Pynacl

regal cove
#

i said i have considerd my options

#

meaning its the best free thing for me imo

drowsy thunder
#

Hi anyone knows how to make a custom help command instead of having the default one

#

I am use / commands

placid skiff
#

package?

boreal ravine
placid skiff
#

Yeah that is for discord.py, he is using slash command

regal cove
drowsy thunder
regal cove
#

i dont use slash command tho

drowsy thunder
#

*2022

placid skiff
# drowsy thunder Nextcord here

Uhm didn't use it for a while, you have to read the docs first, you need to find in the docs a way to retrieve all slash commands

regal cove
#

i dont want it to be public honestly

drowsy thunder
regal cove
#

anyways now that repl.it dont support ffmpeg. what other site can i use which does

placid skiff
#

We can't suggest you free hostes, they are not good and can be unsafe

tight mica
#

localhost is best host

#

wait no

#

i mean selfhost

boreal ravine
placid skiff
#

Untill you migrate your bot to a linux VPS and your code doesn't work for some reason lol

frigid ridge
#

HI

boreal ravine
#

Hey

proven ore
#

anyone knows why commands.Bot.users is returning an empty list?

#

while my bot is in a server with almost 5.1k members

proven ore
#

my bad i forgor, thanks

frigid ridge
#

hi

drowsy thunder
#

Is there a way like you swear saying shit and it deletes the message and says swearing is not allowed

junior verge
#
import discord
from discord.ext import commands

class Role(commands.Cog):

    def __init__(self, client):
        self.client = client

    @commands.command()
    @commands.has_permissions(manage_roles=True)
    async def role(self, ctx, user: discord.Member, *, role: discord.Role):
        if role.position > ctx.author.top_role.position:
            await ctx.send("You don't have permission.")
        if role in user.roles:
            await user.remove_roles(role)
            await ctx.send(f"Succesfully removed {role} from {user.mention}.")
        else:
            await user.add_roles(role)
            await ctx.send(f"Succesfully given {role} to {user.mention}.")

def setup(client):
    client.add_cog(Role(client))
``` This command works in my server where I am the server owner, but when I try it in another server and I got manage roles perms it just gives me a error I don't have enough perms
drowsy thunder
junior verge
#

nvm sorry

#

I made a mistake

drowsy thunder
#

Ohk

#

The code runs but when you do the / command then it shows interaction failed?

small igloo
#

soo i wanna make a dungeon but with moving enemy, is there anyway to make pathfinding algorithm :v (idk where to put it so i put it here xD)

small igloo
drowsy thunder
small igloo
placid skiff
drowsy thunder
#

So the interaction is a button?

small igloo
drowsy thunder
placid skiff
small igloo
small igloo
placid skiff
#

Well so you need a path finder in the end?

small igloo
drowsy thunder
#

Yes,so that happened with me too but with slash commands
I think its a error in the Interaction part

placid skiff
small igloo
placid skiff
drowsy thunder
#

Show me the Interaction part here,I wont open link

small igloo
#

aye not for pygame, they mostly make a tutorial for pygame ;-;

placid skiff
#

uh.. Available Help Channels, the category

drowsy thunder
placid skiff
#

i woke up like 20 minutes ago, sorry hqhahaha

drowsy thunder
drowsy thunder
#

Ok

#

@slate swan Sorry i cant help ya as I use nextcord

placid skiff
drowsy thunder
#

Wdym

#

Nextcord is better in my opinion

placid skiff
#

lol you should try disnake then xD

drowsy thunder
#

@placid skiff can you help me

placid skiff
#

the help command?

drowsy thunder
placid skiff
#

bruh what they did so far is adjusting some doc and add a new file for app_commands

#

which is pretty bad tbh

placid skiff
placid skiff
drowsy thunder
#

Idk hwo to do it

placid skiff
#

check how disnake did them and you will understand why i said that

placid skiff
# drowsy thunder Yes

Well you will need to use the on_message event, so everytime someone send a message it will be triggered

wooden frigate
drowsy thunder
#

Huh

placid skiff
#

then you will proceed to get the content of the message and then you can use the any builtin method with your list

#

!d discord.on_message

unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.

This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
drowsy thunder
#

So it should be like this

placid skiff
#

i suggest you to use the bot.listen or cog.listener decorator because the bot.event will "eat" your commands

drowsy thunder
#
@client.event
async def nextcord.on_message(shit)
placid skiff
#

if you have subclassed the bot class and declare the event in your subclass, then you can just write the async function without the needing of the decorator

drowsy thunder
placid skiff
#

type hinting, if you are using an IDE it will recognize automatically that message is an instance of Message class

#

so you will have intellisense for that variable

drowsy thunder
#

I am using replit

placid skiff
#

Lol

drowsy thunder
#

!e print('sus'*10)

unkempt canyonBOT
#

@drowsy thunder :white_check_mark: Your eval job has completed with return code 0.

sussussussussussussussussussus
drowsy thunder
#

Lol

placid skiff
#

btw intellisense is not it only use, type hinting is used to make your code more readable, for you and for the others

gleaming torrent
#

What happens if u shard a bot that is in 37 servers?

#

Some guy I know did that

placid skiff
#
# type-hinting for returning function
def my_func()->bool:
  pass

# type-hinting for variables
def my_func_1(var_1: str):
  pass

# type-hinting for decorator function:
import typing
T = typing.TypeVar

def decorator_function()->typing.Callable[[T], T]:
  def function():
    #stuff here
  return function
honest shoal
slate swan
placid skiff
#

Morning to you too ashley xD

slate swan
winged bone
#

somehow my disnake bot can't create webhooks anymore, is there any way to see if I got limited because I made too many?

winged bone
#

huh okay

slate swan
#

any error?

#

does your bot have the perms to create webhooks?

winged bone
#

unfortunately no, the ´channel.create_webhook´ just blocks

#

yup it's admin and it worked before

slate swan
#

frog_sip ig

winged bone
#

I do 🙃 but it just blocks

hoary cargo
maiden fable
#

Why using any. Just use len() lemon_pensive

leaden jasper
#

It's less to type

maiden fable
#

?

slate swan
#

how do i activate my bot

vocal snow
regal cove
slate swan
#

How do you create a custom help order ?

regal cove
#

that way u will remove discords help command and make your own

#

i would suggest u make this command in an embed too

placid skiff
regal cove
#

its a very easy way isnt it

#

very easy to understand

placid skiff
#

subclassing too, is only more mechanic, but it is: More efficient, more easy to modify, more reliable

#

it's like creating the bot by creating an istance of it and subclassing it. Subclassing is a complete different method which gives you more control on the bot with the possibility to create more method that you can use to make easier your code

regal cove
#

well

#

i dont use that lol

#

maybe your way is better but my way is good enough

boreal ravine
regal cove
#

honestly no one should use that

maiden fable
unkempt canyonBOT
#

class discord.ext.commands.HelpCommand(*args, **kwargs)```
The base implementation for help command formatting.

Note

Internally instances of this class are deep copied every time the command itself is invoked to prevent a race condition mentioned in [GH-2123](https://github.com/Rapptz/discord.py/issues/2123).

This means that relying on the state of this class to be the same between command invocations would not work as expected.
slate swan
#

I can't, I would like to integrate buttons for each category but I can't

boreal ravine
regal cove
#

it is tho

boreal ravine
#

this is an example of commands.HelpCommand being subclassed, pretty nice isn't it

regal cove
#

subclassed can be used

placid skiff
regal cove
#

but when u make a bot it automaticly has a help command

#

that one is bad

boreal ravine
#

yea, the default one is already nice

placid skiff
#

bruh

boreal ravine
#

@placid skiff it's ui.View

placid skiff
#

Thanks

placid skiff
slate swan
#

my code is messy so tell me if you want to see what I have in my code without help

boreal ravine
placid skiff
#

Thanks

regal cove
#

this is an example of the default help command that i hate

#

i hate this one it looks so bad

winged bone
#

hi, disnake. do you know how to get the interaction.response from within the View, without an interaction happening. i want to disable all buttons on timeout, but the on_timeout method takes only self and not interaction

maiden fable
#

Interaction is constructed only when there is a click or smth

winged bone
#

so there is no way to edit the message without an interaction? i can't believe that

maiden fable
#

U wanna timeout the view after x seconds automatically?

placid skiff
#

it's not like there is no way, you need something to trigger your code so you can edit the part that you are interested

maiden fable
winged bone
#

did that

maiden fable
#

!d disnake.ui.View.timeout

unkempt canyonBOT
#

Timeout from last interaction with the UI before no longer accepting input. If None then there is no timeout.

winged bone
#

but i want to disable the buttons first, so no one can click anymore

maiden fable
#

The whole view will be disabled

regal cove
#

if dad == lost:
print("cry")

slate swan
#

I can't manage to order help

maiden fable
placid skiff
winged bone
maiden fable
placid skiff
#

By disabled you mean that you want them to disappear?

winged bone
#

yeah, sorry if that was unclear

maiden fable
#

Ah

placid skiff
#

!d disnake.ui.View.on_timeout

unkempt canyonBOT
#

await on_timeout()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

A callback that is called when a view’s timeout elapses without being explicitly stopped.
regal cove
#

@client.command(name="Daddy_come_back")
async def trauma(ctx, milk)
await ctx.message.reply("i will come back son, its fine. just listen to your mom and everything will be fine. im just getting some milk baby")

maiden fable
#

Well then u gotta make an instnace variable:

view = MyView()
view.message = await ctx.send(...)

Now use this message attr

slate swan
winged bone
maiden fable
#

Yea, in on_timeout, set the view to self

placid skiff
swift acorn
#

How do I restrict events to only work in servers not Dms?

#

@commands.guild.only works for commands but not events

placid skiff
slate swan
maiden fable
regal cove
#

d.py was my first big project on python lol

slate swan
#

ya'll so impatient wigglewiggle_pensive

maiden fable
slate swan
placid skiff
maiden fable
crisp drift
#

cuz its the not best way

maiden fable
winged bone
#

whoo it worked :)

maiden fable
#

Nice

placid skiff
#

i learned python really fast, like in a week or less (I had a knowledge from other language ofc) then i did some stupid little project and then i moved to d.py

slate swan
maiden fable
#

😔 Random nitro codes

winged bone
#

I wonder why one can't access the view's message by default. should I suggest it?

placid skiff
maiden fable
placid skiff
#

oh no nvm

slate swan
placid skiff
#

well that's good
C++ provides a good knowledge to learn python as fast as possible

winged bone
slate swan
placid skiff
#

I understand but trust me, probably with your actual knowledge your bot will be finished when you start school

#

btw if you want to send your code we can watch at it

slate swan
#

Sorry if I'm boring you

#

I am not English but I make the effort to speak it for you

neat tartan
#

Discord bots arent that difficult to learn as long as a person has a slight amount of problem solving knowledge. If your already familiar with coding it really shouldnt give you any issues and for me personally was a great way to learn python and helped me to understand parts of it better than any other project

placid skiff
#

pretty sure that most of users here are not english native xD

winged bone
# maiden fable ?

I mean to edit a already sent message e.g. when progress is made. not only when a user clicks

maiden fable
#

Ah

neat tartan
maiden fable
placid skiff
#

in Europe too D_D

maiden fable
#

And everyone ain't a night owl like me

boreal ravine
#

it's the afternoon here

slate swan
placid skiff
#

Lol I haven't even launch yet and i'm hungry

placid skiff
slate swan
#

That's why I'm asking you for help if I had the knowledge in python to code a bot I wouldn't have asked any question or even joined this server

placid skiff
#

Trust me you would have joined here anyways, i have enough knowledge but sometimes i need help too xD
btw as i said, if you want to send your code we can take a look at it

unkempt canyonBOT
#

Hey @slate swan!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

placid skiff
#

xD

winged bone
#

is there a way to see if a message was deleted. e.g. by id

maiden fable
#

!d discord.on_raw_message_delete exists

unkempt canyonBOT
#

discord.on_raw_message_delete(payload)```
Called when a message is deleted. Unlike [`on_message_delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_delete "discord.on_message_delete"), this is called regardless of the message being in the internal message cache or not.

If the message is found in the message cache, it can be accessed via [`RawMessageDeleteEvent.cached_message`](https://discordpy.readthedocs.io/en/master/api.html#discord.RawMessageDeleteEvent.cached_message "discord.RawMessageDeleteEvent.cached_message")

This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
slate swan
placid skiff
#

Lol that is an event hunter, he needs to find a message
No there is no way lighting, deleted message can't be found even by fetching them

#

btw you can use the on_raw_message_delete event to save the data of the message that you are interested in

maiden fable
winged bone
#

thx both

placid skiff
slate swan
winged bone
#

though I also came up with this: I know in which channel the message was sent, so I can do channel.fetch_message(id) and see if it raises an error

placid skiff
unkempt canyonBOT
slate swan
#

or even better subclass the helpcommand

winged bone
placid skiff
slate swan
placid skiff
uncut portal
slate swan
#

What ?

slate swan
#

not sure why someone would be working with such a lib and doesnt know oop its kinds hard which has happened to me

crisp drift
#

well its not that easy for a beginner as you said then

uncut portal
#

Discord is just very popular and especially here it's not a surprise that many beginners start with it. My point is for a beginner subclassing a class is hard and a less elegant and more basic solution may be better in this case

crystal cliff
#

How do ppl buy items online using bots? I wasn’t requesting help, 8 was curious 🤔

uncut portal
#

Probably webscraping a site but I don't think it's tos compliant with most sites

#

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

crystal cliff
boreal ravine
unkempt canyonBOT
#
Command: rules

Provides a link to all rules or, if specified, displays specific rule(s).

Source Code
light violet
#

how to delete all webhooks of a particular channel

crystal cliff
light violet
#

for webhook in message.channel.webhooks:
await webhook.delete()

will this work?

flat solstice
#

Hi so I have this command which runs a function user_info_func which sends a msg```py
@slash_user_group.command(name="info", description=info_description)
@app_commands.describe(member="The discord member to get information for.")
@legacy_user_group.command(name ="info", description=info_description, usage="[member]", aliases=["whois", "ui"])
async def info_legacy(self, ctx: commands.Context, member: discord.Member = None):
await interaction_or_context(ctx, member)
await user_info_func(ctx, member)

@slash_user_group.command(name="info", description=info_description)
@app_commands.describe(member="The discord member to get information for.")
async def info_slash(self, interaction: Interaction, member: Union[Member, User]=None):
await interaction_or_context(interaction, member)
await user_info_func(interaction, member)however as member is optional it can occasionally return None. To get around this I wrote another function called `interaction_or_context` py
async def interaction_or_context(transaction, member):
if isinstance(transaction, Interaction):
member = transaction.user if member is None else member
elif isinstance(transaction, Context):
member = transaction.author if member is None else member
else:
print("Something went wrong in 'interaction_or_context'")``` which is supposed to to check if the member arg is None and if it is then it sets member as the value of the person who invoked he command (that being discord.ext.commands.Context.author or discord.Interaction.user but for some reason it keeps returning None which is causing my user_info_func to say iscord.app_commands.errors.CommandInvokeError: Command 'info' raised an exception: AttributeError: 'NoneType' object has no attribute 'activity'