#discord-bots

1 messages · Page 222 of 1

potent spear
#

what's self.name.value?

slate swan
#

it the ID

potent spear
#

can you print it?

#

also
print(type(self.name.value))

slate swan
#

it say serverIDofOther say non self.name.value) say the ID

potent spear
#

print the type for me

slate swan
#

sure

potent spear
#

if it's a string, you'll have to convert it to an int

#

THEN the guild will be found

#

you should also check once you use get_guild if the guild isn't None (when you, for example, type an invalid ID)

slate swan
#

it print nothing werid

potent spear
#

nice

slate swan
#

soemthign wrong

potent spear
#

that means your code never gets executed

slate swan
#
        print(type(self.name.value))
        servernameofOther = self.name2.value
        serverIDofMain = interaction.guild.id
        serverIDofOther = bot.get_guild(self.name.value)
        serverOwnerIDofOther = bot.get_user(serverIDofMain.owner.id)
        serverOwnerIDofOther.send("Hi")```
slate swan
potent spear
#

sending a message is async btw => await

slate swan
#

it even got me this error Traceback (most recent call last): File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ui\modal.py", line 290, in _scheduled_task await self.callback(interaction) File "c:\Users\Ibrah\Desktop\Code\Python\main.py", line 1541, in callback serverOwnerIDofOther = bot.get_user(serverIDofMain.owner.id) AttributeError: 'int' object has no attribute 'owner'

potent spear
#

this is useless btw
serverOwnerIDofOther = bot.get_user(serverIDofMain.owner.id)

potent spear
#

because

#

serverOwnerIDofOther = guild.owner

slate swan
#

of the id

#

of the server of i enter that id

potent spear
#

guild.owner is already a user object...

#

you don't have to get the user again... would be useless

slate swan
#

ik

#

id delete

#

now got get the owner id of the server that i enter there id

potent spear
#

try and see 🤷

slate swan
#

guild.owner is the guild owner of the server that i on rn

#

that i do the command

#

but i want owner of other server that i enter there id

#

got it?

potent spear
slate swan
#

does other_guild just normal var right?

potent spear
#

yes, it's a better variable name than serverIDofOther lol

slate swan
#

ah

slate swan
#

the server now i want get the owner of that server

potent spear
slate swan
#

ok i dead

#

let me try#

#

IT WORK

#

THANK YOU! ❤️

potent spear
#

good luck

obtuse island
#

sup guys, how do i import a game.py file into my discord bot? When i use import game, the game loads but the bot doesn't

slate swan
#

@potent spear sorry for the ping but i found this code and I think that this is what i should do:

```, 
then replace:

```await channel.set_permissions(ctx.guild.default_roles, send_messages = True, reason = f'{ctx.author.name} unlocked {channel.name} with --server')```

with
```await channel.set_permissions(ctx.guild.roles, send_messages = True, reason = f'{ctx.author.name} unlocked {channel.name} with --server')
obtuse island
#

for more context here is how it looks. you can see that the bot doesn't loads

slate swan
#

i just found a video on discord utils and idk what to set it to

obtuse island
slate swan
#

nah sorry, i just started bro

obtuse island
#

oh mb

potent spear
slate swan
#

i did

potent spear
#

Show me where

slate swan
#

ctx.guild.roles

#

oh wait

#

was i not supposed to add the s

potent spear
#

What do you think that is? 🧠

vocal snow
slate swan
obtuse island
vocal snow
#

Well that doesn't change my answer

#

You have input() statements which must complete before the code after them runs

#

Are you actually trying to get input from the console or from discord?

slate swan
#

you can use await aioconsole.ainput() for a non blocking version

#

actually

#

that won't fix your problem mainly

#

you can run it in another thread

obtuse island
#

like an embed imput using reactions

naive briar
obtuse island
#

here is how it's supposed to look(inside should be the game)

slate swan
vocal snow
#

You know print() doesn't send a message to a discord channel right?

#

And input() doesn't read a message from a discord channel

obtuse island
obtuse island
vocal snow
#

How new to python are you? I'm not sure if I'll be able to explain if you're a beginner...

obtuse island
#

so you can try to explain

slate swan
#

u took this from chat gpt na get intents tho

slate swan
slate swan
slate swan
#

@vocal snow

#

!embed

#

umm typing finally

vocal snow
#

In discord.py, this is abstracted to the Messageable.send method

#

!d discord.abc.Messageable.send

unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.11)") of [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.11)") of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
vocal snow
#

when you use print(), it will print to the program's stdout (or a file, if specified via the file kwarg)

#

so there's a very big difference between the two, and they absolutely cannot be substituted for each other

slate swan
#

from docs??

vocal snow
#

as well as reading the source

slate swan
slate swan
vocal snow
vocal snow
slate swan
#

cuz i didnt learn it actually at some extent

#

@vocal snowbro listen how am i supposed to learn it cuz in docs also it gets ended i dont get what next i am suppose dto do

#

sry for continous pings

vocal snow
#

what do you want your bot to do?

shrewd apex
shrewd apex
vocal snow
#

and reading the docs won't help if you don't understand them;
you should make sure you understand intermediate level python first

slate swan
#

umm am actully making a bot like for anime purpose like there will be some boss fights to earn coins or something like that teaming up with other charachters

vocal snow
slate swan
#

lol

#

i have more ideas but am lazy to type it tho

#

lol

vocal snow
#

it's important you have a clear understanding of you want your bot to work

#

How does a player start playing the game?

#

Do they use a slash command? Maybe click a button?

#

And then, where are you going to store all the player data? Which database will you use

slate swan
vocal snow
#

There's a lot of planning that needs to be done before the actual coding happens

slate swan
#

@shrewd apexu made a pokemon bot?

shrewd apex
#

umm yea?

vocal snow
#

(The best pokemon bot)

slate swan
#

how check if a var is int

shrewd apex
#

totally not

slate swan
vocal snow
naive briar
unkempt canyonBOT
#
Nah.

No documentation found for the requested symbol.

vocal snow
#

typo

naive briar
#

🧐

vocal snow
#

!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. [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") may not be raised for an invalid type if an earlier check succeeds.

Changed in version 3.10: *classinfo* can be a [Union Type](https://docs.python.org/3/library/stdtypes.html#types-union).
slate swan
#

lol

vocal snow
#

no

slate swan
#

oh lol

shrewd apex
slate swan
vocal snow
#

I use WSL for all my linux needs ☺️

shrewd apex
shrewd apex
slate swan
vocal snow
#

can't you just ssh?

slate swan
#

@shrewd apexcan i ask a question??

#

pls

shrewd apex
#

i dont have to google commands for everything loooli

vocal snow
#

impossible !1!!!1

shrewd apex
tacit sandal
#

🪨

vocal snow
#

linux terminal consol good gui windows BAD

slate swan
#

from where did u got the pitures of it from official site??

tacit sandal
#

Windows best

shrewd apex
tacit sandal
#

Like?

shrewd apex
#

pokeapi showdown pokemondb and so on

slate swan
#

ya like?

slate swan
shrewd apex
#

but recently i compiled all of the images i gathered and made a bunch of prs to pokeapi

#

so most of the images are now available there

tacit sandal
#

But that's not good

shrewd apex
#

except the gifs i made pr not accepted yet tho

slate swan
#

wht id pr tho lul.

tacit sandal
#

U must give credit

slate swan
shrewd apex
tacit sandal
#

Oh whatever but I think it's better

shrewd apex
#

i didnt take ones from artists and stuff mostly the open sourced ones like showdown

slate swan
shrewd apex
#

plus it not economised

shrewd apex
shrewd apex
slate swan
#

sry for consuming so much of ur time tho

shrewd apex
#

np i am free rn

slate swan
shrewd apex
#

explain what?

shrewd apex
#

it literally means what is written i used the bot as my project to learn python

slate swan
shrewd apex
#

i did a few smol projects but nothing too big

slate swan
#

cuz i am a game dev but came on discord just for experience

shrewd apex
#

just dived in mostly

slate swan
shrewd apex
#

aight

slate swan
#

damn

shrewd apex
#

not recommended tho

slate swan
shrewd apex
#

i learnt stuff in all the wrong order

copper quest
#

Is this help channel?

slate swan
shrewd apex
#

if its smol we can help u out

slate swan
shrewd apex
shrewd apex
slate swan
#

ic

#

can i ask ur age tho

#

over 18?

shrewd apex
#

17

slate swan
#

oh ic

#

u in 11th ?

shrewd apex
#

no

#

12th

slate swan
#

oh ic

#

@shrewd apexthnx for giving me ur time

#

hello, i am currently doing a captcha verification, what is the most efficient way to check like every 0.2, 0.3 seconds if the captcha is expired while being able to guess and complete the captcha

shrewd apex
#

views

#

add a timeout

#

add a button and modal and u good to go

slate swan
# slate swan hello, i am currently doing a captcha verification, what is the most efficient w...

Hello! I can provide some general advice on how to efficiently check for captcha expiration while completing the captcha.

First, it's important to understand how captcha expiration works. Captchas typically have a time limit after which they expire and become invalid. This time limit is usually set by the website or service that is using the captcha.

To check for captcha expiration, you can use a timer function that runs every 0.2 or 0.3 seconds. This function should check the time elapsed since the captcha was first displayed and compare it to the captcha expiration time limit. If the time elapsed is greater than the time limit, then the captcha has expired and you should stop any further attempts to complete it.

To guess and complete the captcha efficiently, you can use automated tools like captcha solving services or machine learning models that are specifically designed to recognize and solve captchas. These tools can significantly reduce the time and effort required to complete a captcha. However, it's important to note that using automated tools to bypass captchas without permission is generally considered unethical and may be illegal in some jurisdictions.

Alternatively, you can try to manually solve the captcha by following the instructions provided, such as identifying certain objects or characters in an image. This can be time-consuming, but it's a legitimate way to complete the captcha without violating any rules or laws.

Overall, the key to efficiently checking for captcha expiration while completing the captcha is to use a timer function to monitor the time elapsed and to use automated tools or manual methods to complete the captcha as quickly and accurately as possible.

#

u can read if u want

slate swan
slate swan
#

lul

slate swan
#

did u use chat gpt lmao

slate swan
#

lol

stable current
shrewd apex
#

chatgpt no doubt

stable current
#

I wanted to see what I did wrong

stable current
#

k

blazing flint
#

adding multiple options to select from in an option?

slate swan
#

i wanna learn how to create a bot

unkempt mauve
#

on_guild_leave or on_guild_remove?

fading marlin
#

the latter

slate swan
#

are we supposed to use intents.message_content or intents.messages??

#

@slate swan

#

lol sry for ping

#

help?

#

pls

slate swan
#

!d discord.Intents

unkempt canyonBOT
#

class discord.Intents(value=0, **kwargs)```
Wraps up a Discord gateway intent flag.

Similar to [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.

To construct an object you can pass keyword arguments denoting the flags to enable or disable.

This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client "discord.Client").

New in version 1.5.
slate swan
#

read about them here what they add\

slate swan
#

plss

#

oof

#

?

#

i told you go to the docs i sent and read what they add and you decide what you need

#

nothing there to read

hushed galleon
#

there is plenty there to read

slate swan
#

really just scroll a bit

#

not sleeping is hard for but still i was not sleeping for 2 days

slate swan
#

i didnt actually found it anywhere

hushed galleon
#

you see this blue text here, you can click it to go to the doc page

slate swan
#

how to take ss?

hushed galleon
#

on windows, shift+windows key+S

slate swan
#

ty

hushed galleon
#

if you just want a summary, messages is how your bot knows when a message was sent in real time, while message_content is needed to access the text sent in that message (and is a privileged intent so it needs to be enabled in the dev portal beforehand)

addendum: fetching messages via the API (i.e. not real-time) will also return no content if message content isnt enabled in the dev portal

slate swan
#

bruh wht are these words

hushed galleon
#

hushed galleon
# hushed galleon

this is what your bot sees if you have messages enabled but not message_content (with some exceptions listed in the documentation)

hushed galleon
#

in other words you know when the message was sent, where it was sent, and who sent it, but not what was sent

hushed galleon
#

yes

slate swan
#

ic

#

ty

#

@hushed galleonsry for ping but pls help is there anything wrong

hushed galleon
#

what did your bot respond with?

slate swan
#

it was supposed to send that u choosed this or that

#

but it dosent

#

and now it dosent send the dm as well sed

wind radish
slate swan
wind radish
#

how is the interaction triggered? with !team up?

slate swan
#

so i gone for it

slate swan
#

a

#

u mean prefix right?

hushed galleon
#

minor pointer that message content isnt enabled so you're relying on one of the three exceptions for receiving message content, but regardless capitalize() likely isnt doing what you expect it to do

slate swan
#

?/

#

..

hushed galleon
#

if you need to receive message content outside of the exceptions, for example to recognize "!team up" when someone sends it inside a server, sure

#

!e as for capitalize(), here's what that looks like: py name = "Eren Yeager" content = "eren yeager" capitalized = content.capitalize() print(capitalized, "vs", name)

unkempt canyonBOT
#

@hushed galleon :white_check_mark: Your 3.11 eval job has completed with return code 0.

Eren yeager vs Eren Yeager
hushed galleon
#

^ it doesnt produce the same string so your check isnt able to match those names correctly

hushed galleon
slate swan
#

one is capital one is small

hushed galleon
#

right, which means they are not equal strings, so when your check tries to do msg.content.capitalize() in pokemon_list, it will always return False

hushed galleon
#

whats done more commonly for case-insensitive comparisons is lowercasing both strings, as its simpler to understand: ```py

items = ["cookies", "cream", "sauce"]
x = "CoOkiEs"
x.lower() in items
True```

hushed galleon
slate swan
slate swan
hushed galleon
#

and make the strings in your list lowercase too

slate swan
#

this??

#

@hushed galleonsry for so much pings

#

it is working like this lol

paper sluice
#

do you have multiple instances of the bot running?

paper sluice
#

thats why the bot is sending multiple messages for one command

slate swan
#

but the bot is only taking message in dms

#

not on servers tho

#

thegamercracksducky_lemon help

glad cradle
slate swan
hushed galleon
#

what ryuga said, you probably have multiple versions of your bot running

slate swan
#

it is workin correctly now but i want to make the start command more cool tho so how can i lol (i know u are annyoed from me but i cant help it either)

slate swan
odd mango
#

checkout discord.Embed

slate swan
odd mango
#

docs

slate swan
slate swan
odd mango
slate swan
#

i would google it then

odd mango
#

also the bot code template you're using is quite outdated, read the docs or some gist to get a better and subclassed one

odd mango
#

to put it simply, you're just trying to put everything in one file and not using classes to make cogs.
subclassing the bot is the best method

slate swan
#

man when ppl type so much for me i actually feel awful

odd mango
slate swan
#

i should sleep i guess my eyes are burning cuz i didnt slep for 2day tho

odd mango
slate swan
#

guys can any one help me to know how use database

slate swan
#

lol ok

slate swan
#

lol

slate swan
#

!discord.embed

#

oof?

cloud dawn
#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, 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.

x == y Checks if two embeds are equal.

New in version 2.0...
slate swan
#

@cloud dawn

cloud dawn
#

?

slate swan
#

where should i add embed in here?

#

panda

#

shpuld i ping?

cloud dawn
#

Using the embed kwarg

slate swan
#

.

#

..

cloud dawn
unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.11)") of [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.11)") of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
slate swan
#

should i read this?

cloud dawn
#

Just look at what it takes

slate swan
cloud dawn
#

embed=discord.Embed(...)

slate swan
odd mango
slate swan
#

am asking am i supposed to send it after await command?

odd mango
#

embed = discord.Embed(...)
await channel.send(embed=embed)

slate swan
odd mango
#

its there

slate swan
#

ya ic ty

slate swan
#

its saying channel is not defined

odd mango
#

...

slate swan
#

lol

odd mango
#

what are you using? context?

slate swan
#

Show code

odd mango
#

should be message.channel.send(embed=embed) according to your code

slate swan
#

@slate swan

#

!d discord.Message.channel

unkempt canyonBOT
odd mango
#

LOL do not do discord.Embed(...)

slate swan
#

ooofoofoofofoofffff

#

You are not supposed to put that Dots there joeCollapse

odd mango
#

feed in its params

cloud dawn
#

It was an example lol

slate swan
#

Its just a placeholder to you to put params

#

oof

#

i just copied and pasted

#

oof

odd mango
#

these all are params

slate swan
odd mango
#

parameters

slate swan
#

of

odd mango
#

discord.Embed

slate swan
#

oh*

slate swan
#

Look at the first answer there is an example maybe you will understand it with it

#

not defined

slate swan
odd mango
slate swan
#

stackoverflow

#

You know it right ok

#

am actually feeling so awful

slate swan
#

but i want to learn

odd mango
#

UHHH violation of ToS

slate swan
odd mango
#

discord is a 13+ app 🚶‍♂️

slate swan
#

k i am 8th grader then

#

lul

#

13 now

odd mango
slate swan
#

"Ignoring exception in on_message" wht is this

odd mango
#

full traceback

slate swan
#

It means that there was error in on message event

#

hhuh?

slate swan
#

!traceback

unkempt canyonBOT
#
Traceback

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
        ~~~~^~~
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

slate swan
#

bro i actually did it

#

@slate swansry for ping

#

@odd mangosry for ping

#

sry for wasting ur time again

odd mango
#

👍

slate swan
#

damn i just came back

#

@odd mangousing images from official webs in dc is not wrong right

odd mango
#

its not

#

you can use any image you want

slate swan
odd mango
#

ofcousre unless it violates terms of service of the image provider or discord

slate swan
#

can i ask a question?@odd mango

#

is it day or night at ur place?

odd mango
#

it's night

slate swan
#

ic

odd mango
#

yeah about 00:30

slate swan
#

same here

#

just 29

#

00 29

odd mango
#

likewise

slate swan
#

mhm

#

oof

#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, 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.

x == y Checks if two embeds are equal.

New in version 2.0...
slate swan
#

ty

#

capital letters are a thing

slate swan
#

Embed must be with capital letter

slate swan
slate swan
slate swan
odd mango
#

python is case sensitive, so the documentation is made according to it, and accessed likewise via this bot

slate swan
#

umm in the embed can i add user avtar as well?

odd mango
#

yeah

slate swan
#

oh

#

!d discord.Embed.set_author

unkempt canyonBOT
#

set_author(*, name, url=None, icon_url=None)```
Sets the author for the embed content.

This function returns the class instance to allow for fluent-style chaining.
odd mango
#

message.author.avatar_url iirc

slate swan
#

hello, i am gettng this error when import from nextcord.ext import menu

ImportError: cannot import name 'menus' from 'nextcord.ext' (unknown location)
odd mango
slate swan
#

no, i imported "menus"

odd mango
slate swan
vagrant knot
#

hello all, somebody will and can help me with some python. it's for in my discord server to make a command

odd mango
slate swan
#

yeah thats more like it i think i made a typo

#

still same error but with "menu" now

slate swan
odd mango
slate swan
#

cause there is no such thing in nextcord

#

i belive it was in nextcord ages ago

odd mango
odd mango
slate swan
slate swan
odd mango
#

check the docs then

slate swan
#

well ill ask again

#

what are you trying to do @slate swan

#

so is it in dpy now?

odd mango
#

could be, i dont know anyways lol

slate swan
#

so if there are e.g more than 5 results, it should create another embed with new fields

#

mhm i see

#

can you tell me how to start cuz i have no idea

slate swan
#

oh right thanks

odd mango
#

that too for stable version

slate swan
#

those are the external package docs

odd mango
#

whaaa 😂

slate swan
odd mango
#

yeah its not there

slate swan
#

i will try it now

left dew
#

i get the error embed has no attribute edit

        msg = discord.Embed(description=f'Deleting this ticket in **5** sconds', color=0x303135)
        await ctx.channel.send(embed=msg)
        time.sleep(1)
        await msg.edit(description=f'Deleting this ticket in **4** seconds')
        time.sleep(1)
        await msg.edit(description=f'Deleting this ticket in **3** seconds')
        time.sleep(1)
        await msg.edit(description=f'Deleting this ticket in **2** seconds')
        time.sleep(1)
        await msg.edit(description=f'Deleting this ticket in **1** seconds')
        time.sleep(1)
        await msg.edit(description=f'Deleting this ticket in **0** seconds')```
slate swan
#

i added this but nothing chaanged like the avatar not showing yet

odd mango
slate swan
#

bruh

#

then how the black part come

#

eh

odd mango
#

message = #get your message to edit
NewEmbed = discord.Embed(...)
await message.edit(embed=NewEmbed)

left dew
#

ohh okay tyy

odd mango
#

you are not using client.command()

#

you are using an on_message event

slate swan
slate swan
#

it was showing 9+ erreor

#

s()

odd mango
#

no no

slate swan
#

heh?

#

indentation

slate swan
odd mango
# slate swan bruh??
@client.command()
async def avatar(ctx: commands.Context, member: discord.Member) -> discord.Message:
    member = member or ctx.author
    embed = discord.Embed(title=f"{member.display_name}'s Avatar")
    embed.set_image(url=member.avatar_url)
    return await ctx.send(embed=embed)
``` this is what i would do
odd mango
slate swan
#

wht is -> this now

odd mango
#

ignore that

left dew
#
        msg1 = discord.Embed(description=f'Deleting this ticket in **5** sconds', color=0x303135)
        await ctx.channel.send(embed=msg1)
        time.sleep(1)
        msg2 = discord.Embed(description=f'Deleting this ticket in **4** seconds', color=0x303135)
        await msg1.edit(embed=msg2)
        time.sleep(1)
        msg3 = discord.Embed(description=f'Deleting this ticket in **3** seconds', color=0x303135)
        await msg2.edit(embed=msg3)
        time.sleep(1)
        msg4 = discord.Embed(description=f'Deleting this ticket in **2** seconds', color=0x303135)
        await msg3.edit(embed=msg4)
        time.sleep(1)
        msg5 = discord.Embed(description=f'Deleting this ticket in **1** seconds', color=0x303135)
        await msg4.edit(embed=msg5)
        time.sleep(1)
        msg6 = discord.Embed(description=f'Deleting this ticket in **0** seconds', color=0x303135)
        await msg5.edit(embed=msg6)```
slate swan
#

ic

slate swan
#

no need to add it

odd mango
#
@client.command()
async def avatar(ctx, member):
    member = member or ctx.author
    embed = discord.Embed(title=f"{member.display_name}'s Avatar")
    embed.set_image(url=member.avatar_url)
    return await ctx.send(embed=embed)```
#

work with this for now

odd mango
#

you need to edit discord.Message NOT discord.Embed

left dew
#

how do i get the message

odd mango
#

just store it in a var

slate swan
#

msg = await ctx.send(...)

odd mango
#

^^

left dew
#

huh

slate swan
slate swan
odd mango
#
        msg1 = discord.Embed(description=f'Deleting this ticket in **5** sconds', color=0x303135)
        UltimateMessage = await ctx.channel.send(embed=msg1)
        time.sleep(1)
        msg2 = discord.Embed(description=f'Deleting this ticket in **4** seconds', color=0x303135)
        await UltimateMessage.edit(embed=msg2)
        time.sleep(1)
        msg3 = discord.Embed(description=f'Deleting this ticket in **3** seconds', color=0x303135)
        await UltimateMessage.edit(embed=msg3)
        time.sleep(1)
        msg4 = discord.Embed(description=f'Deleting this ticket in **2** seconds', color=0x303135)
        await UltimateMessage.edit(embed=msg4)
        time.sleep(1)
        msg5 = discord.Embed(description=f'Deleting this ticket in **1** seconds', color=0x303135)
        await UltimateMessage.edit(embed=msg5)
        time.sleep(1)
        msg6 = discord.Embed(description=f'Deleting this ticket in **0** seconds', color=0x303135)
        await UltimateMessage.edit(embed=msg6)
odd mango
#

they are trying to edit the message

cloud dawn
#

Okay but time.sleep(1)

#

Why not use the build in datetime system

odd mango
left dew
#

okay tysm

odd mango
cloud dawn
#

<t:1992121212:R>

slate swan
#

<t:1680453929:R>

cloud dawn
#

<t:1680121212:R>

cloud dawn
#

<t:1680021212:R>

#

<t:1678121212:R>

slate swan
#

i think its enough of timestamps

cloud dawn
#

Lol

odd mango
#

save some api calls

cloud dawn
#

<t:1680464096:R>

left dew
#

oh

slate swan
#

never use time.sleep in discord bot use await asyncio.sleep(1) instead

left dew
#

okay

slate swan
#

!d asyncio.sleep

unkempt canyonBOT
#

coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.

If *result* is provided, it is returned to the caller when the coroutine completes.

`sleep()` always suspends the current task, allowing other tasks to run.

Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.

Example of coroutine displaying the current date every second for 5 seconds:
slate swan
#

but for this case timestamp will be better option

cloud dawn
#

Deleting message <t:1680464196:R>

slate swan
#

wht is this bruh

#

its a timestamp

cloud dawn
#

Relative time

slate swan
cloud dawn
#

If you need to repeat certain lines multiple times, there is a better way to do it.

tight fog
#

how do I tell a bot to use slash commands?

#

like do I need to import something and stuff

potent spear
cloud dawn
#

@unkempt canyon use slash commands

potent spear
#

those are called app_commands

cloud dawn
#

@unkempt canyon Wait does it repeat anything i say?

#

hmm

potent spear
#

it's not a parrot

tight fog
#

like for this, how do I change it to use slash commands instead of putting !

@dc.event
async def on_message(message):
    if message.author == dc.user:
        return

    elif message.content.startswith('!hello'):
        await message.channel.send('Hello!')
potent spear
#

well, that's not a command in the first place

cloud dawn
tight fog
#

yeah this is just reading messages and waiting for the keyword

slate swan
#

@slate swan @odd mango thank you for today guys

cloud dawn
#

fixed

tight fog
potent spear
cloud dawn
slate swan
#

arent there only client and bot @ ?

unkempt canyonBOT
#

@discord.app_commands.command(*, name=..., description=..., nsfw=False, auto_locale_strings=True, extras=...)```
Creates an application command from a regular function.
smoky sinew
#

<t:1680464672:R>

smoky sinew
odd mango
#

they named it dc

slate swan
slate swan
odd mango
#

ofc its just a var name

slate swan
#

lol ic

#

cya

dull terrace
#

i have two bots set up on the same ip

#

will discord rate limit based on the ip or the bot?

dull terrace
tight fog
#

ok on second thought I am not gonna use slash commands

#

just gonna go old fashioned since there seems to be no good solutions to this

wooden shadow
#
    client.run(os.environ['TOKEN'])
  File "/home/runner/SaintModuleBot/venv/lib/python3.10/site-packages/discord/client.py", line 860, in run
    asyncio.run(runner())
  File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/home/runner/SaintModuleBot/venv/lib/python3.10/site-packages/discord/client.py", line 849, in runner
    await self.start(token, reconnect=reconnect)
  File "/home/runner/SaintModuleBot/venv/lib/python3.10/site-packages/discord/client.py", line 777, in start
    await self.login(token)
  File "/home/runner/SaintModuleBot/venv/lib/python3.10/site-packages/discord/client.py", line 612, in login
    data = await self.http.static_login(token)
  File "/home/runner/SaintModuleBot/venv/lib/python3.10/site-packages/discord/http.py", line 805, in static_login
    raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.```
#

i keep on getting this code when trying to pass in my token

#

i formatted my token as TOKEN=x , x = token value

#

and i didn't really use x i am just using that as an example

#
import os
intents = discord.Intents.all()
client = discord.Client(command_prefix='!', intents=intents)
@client.event
async def on_ready():
  print("We have logged in as {0.user}".format(client))

@client.event
async def on_message(message):
  if message.author == client.user:
    return
  if message.content.startswith('$hello'):
    await message.channel.send('Hello my people')

client.run(os.environ['TOKEN'])```
#

this was my code

blazing flint
#

its the token

#

your token is incorrect

slate swan
unkempt canyonBOT
#
Using .env files in Python

.env (dotenv) files are a type of file commonly used for storing application secrets and variables, for example API tokens and URLs, although they may also be used for storing other configurable values. While they are commonly used for storing secrets, at a high level their purpose is to load environment variables into a program.

Dotenv files are especially suited for storing secrets as they are a key-value store in a file, which can be easily loaded in most programming languages and ignored by version control systems like Git with a single entry in a .gitignore file.

In python you can use dotenv files with the python-dotenv module from PyPI, which can be installed with pip install python-dotenv. To use dotenv files you'll first need a file called .env, with content such as the following:

TOKEN=a00418c85bff087b49f23923efe40aa5

Next, in your main Python file, you need to load the environment variables from the dotenv file you just created:

from dotenv import load_dotenv()

load_dotenv(".env")

The variables from the file have now been loaded into your programs environment, and you can access them using os.getenv() anywhere in your program, like this:

from os import getenv

my_token = getenv("TOKEN")

For further reading about tokens and secrets, please read this explanation.

slate swan
#

i dont think you can add cooldown to each command

#

you need to add cooldown to each

tough mirage
#

what am I missing thats causing this error?

heres my code,
https://hastebin.com/share/owomeratep.python

error,

Traceback (most recent call last):
  File "c:\Users\Madth\Documents\Projects\discord slash\main.py", line 26, in <module>
    class Hello(commands.SlashCommand):
                ^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'discord.ext.commands' has no attribute 'SlashCommand'```
tight fog
#

are these two the same?

#

I wonder if I just ditch the discord.Client

scarlet aurora
#

how to do hybrid command on command group

slate swan
#

ty

tight fog
#

what is a decorator

#

ugh

#

see this is why I hate learning python and stuff because it literally consumes your whole day by waiting for hours and hours to get a response

#

what is arg

#
@bot.command(name='list')
async def _list(ctx, arg):
    pass
thin raft
#

an argument

tight fog
#

which is

thin raft
#

wdym

unkempt canyonBOT
#
Parameters vs. arguments

A parameter is a variable defined in a function signature (the line with def in it), while arguments are objects passed to a function call.

def square(n): # n is the parameter
    return n*n

print(square(5)) # 5 is the argument

Note that 5 is the argument passed to square, but square(5) in its entirety is the argument passed to print

tight fog
#

So parameter is like a variable to build a function and argument is an actual value used in the function

unkempt canyonBOT
#
Return statement

A value created inside a function can't be used outside of it unless you return it.

Consider the following function:

def square(n):
    return n * n

If we wanted to store 5 squared in a variable called x, we would do:
x = square(5). x would now equal 25.

Common Mistakes

>>> def square(n):
...     n * n  # calculates then throws away, returns None
...
>>> x = square(5)
>>> print(x)
None
>>> def square(n):
...     print(n * n)  # calculates and prints, then throws away and returns None
...
>>> x = square(5)
25
>>> print(x)
None

Things to note
print() and return do not accomplish the same thing. print() will show the value, and then it will be gone.
• A function will return None if it ends without a return statement.
• When you want to print a value from a function, it's best to return the value and print the function call instead, like print(square(5)).

#
Print and return

Here's a handy animation demonstrating how print and return differ in behavior.

See also: /tag return

thin raft
#

check this gif

tight fog
#

how come the 5 went to x

#

how does the code know to do that

#

oh

#

the function is my_function

#

then he reuses it down below and it references the earlier lines on what to do

#

ok that makes sense

#

so return just tells it to use the output

unkempt canyonBOT
#
Concurrency in Python

Python provides the ability to run multiple tasks and coroutines simultaneously with the use of the asyncio library, which is included in the Python standard library.

This works by running these coroutines in an event loop, where the context of the running coroutine switches periodically to allow all other coroutines to run, thus giving the appearance of running at the same time. This is different to using threads or processes in that all code runs in the main process and thread, although it is possible to run coroutines in other threads.

To call an async function we can either await it, or run it in an event loop which we get from asyncio.

To create a coroutine that can be used with asyncio we need to define a function using the async keyword:

async def main():
    await something_awaitable()

Which means we can call await something_awaitable() directly from within the function. If this were a non-async function, it would raise the exception SyntaxError: 'await' outside async function

To run the top level async function from outside the event loop we need to use asyncio.run(), like this:

import asyncio

async def main():
    await something_awaitable()

asyncio.run(main())

Note that in the asyncio.run(), where we appear to be calling main(), this does not execute the code in main. Rather, it creates and returns a new coroutine object (i.e main() is not main()) which is then handled and run by the event loop via asyncio.run().

To learn more about asyncio and its use, see the asyncio documentation.

tight fog
#

what does * do

unkempt canyonBOT
#
Pythonic way of iterating over ordered collections

Iterating over range(len(...)) is a common approach to accessing each item in an ordered collection.

for i in range(len(my_list)):
    do_something(my_list[i])

The pythonic syntax is much simpler, and is guaranteed to produce elements in the same order:

for item in my_list:
    do_something(item)

Python has other solutions for cases when the index itself might be needed. To get the element at the same index from two or more lists, use zip. To get both the index and the element at that index, use enumerate.

tight fog
#

alright found it, * allows for variable number of arguments

unkempt canyonBOT
#
Concurrency in Python

Python provides the ability to run multiple tasks and coroutines simultaneously with the use of the asyncio library, which is included in the Python standard library.

This works by running these coroutines in an event loop, where the context of the running coroutine switches periodically to allow all other coroutines to run, thus giving the appearance of running at the same time. This is different to using threads or processes in that all code runs in the main process and thread, although it is possible to run coroutines in other threads.

To call an async function we can either await it, or run it in an event loop which we get from asyncio.

To create a coroutine that can be used with asyncio we need to define a function using the async keyword:

async def main():
    await something_awaitable()

Which means we can call await something_awaitable() directly from within the function. If this were a non-async function, it would raise the exception SyntaxError: 'await' outside async function

To run the top level async function from outside the event loop we need to use asyncio.run(), like this:

import asyncio

async def main():
    await something_awaitable()

asyncio.run(main())

Note that in the asyncio.run(), where we appear to be calling main(), this does not execute the code in main. Rather, it creates and returns a new coroutine object (i.e main() is not main()) which is then handled and run by the event loop via asyncio.run().

To learn more about asyncio and its use, see the asyncio documentation.

slate swan
#

guys how create a discord channel by the bot

tight fog
#

is there a way for a bot to find out if there is a number in a string or not

naive briar
unkempt canyonBOT
#

@naive briar :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | Has no number
002 | Has number
naive briar
unkempt canyonBOT
#
await create_text_channel(name, *, reason=None, category=None, news=False, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel "discord.TextChannel") for the guild.

Note that you must have [`manage_channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") to create the channel.

The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.11)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.

Note

Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
naive briar
#

Read the docs

tight fog
#

@naive briar does this work too

async def add(ctx, number, member: discord.Member):
    try:
        number = int(number)
        await ctx.send(f'Adding {number} honks to {member}')
    except ValueError:
        await ctx.send('this is not a number bro')
naive briar
#

It will fail if there's a string in there

#

!e

int("Meow_1")
unkempt canyonBOT
#

@naive briar :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     int("Meow_1")
004 | ValueError: invalid literal for int() with base 10: 'Meow_1'
tight fog
#

it should go to except ValueError right

#

!e

async def add(ctx, number, member: discord.Member):
    try:
        number = int(number)
        await ctx.send(f'Adding {number} honks to {member}')
    except ValueError:
        await ctx.send('this is not a number bro')
unkempt canyonBOT
#

@tight fog :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     async def add(ctx, number, member: discord.Member):
004 |                                        ^^^^^^^
005 | NameError: name 'discord' is not defined
tight fog
#

!e

number = "hello there"

async def add(ctx, number):
    try:
        number = int(number)
    except ValueError:
        print('not a number')
unkempt canyonBOT
#

@tight fog :warning: Your 3.11 eval job has completed with return code 0.

[No output]
slate swan
#

guys how fix this error ```Ignoring exception in command <nextcord.application_command.SlashApplicationCommand object at 0x00000192DE7445B0>:
Traceback (most recent call last):
File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 848, in invoke_callback_with_hooks
await self(interaction, *args, **kwargs)
File "c:\Users\Ibrah\Desktop\Code\Python\main.py", line 1491, in crosserverschat
message1 = await interaction.send("CrossServer Chat StartUp", embed=embed, view=myview, ephemeral=True)
File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\interactions.py", line 564, in send
return await self.response.send_message(
File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\interactions.py", line 893, in send_message
await adapter.create_interaction_response(
File "C:\Users\Ibrah\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\webhook\async_.py", line 204, in request
raise NotFound(response, data)
nextcord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction

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

nextcord.errors.ApplicationInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10062): Unknown interaction```

hazy oxide
#

your command?

hazy oxide
slate swan
#

yes

#

i fix it!

#

thx btw

smoky sinew
#

then how would it run the send method

jolly basalt
#

can someone give me a discord.ext.commands.MinimalHelpCommand example please

shrewd fjord
#

!d discord.ext.commands.MinimalHelpCommand

unkempt canyonBOT
#

class discord.ext.commands.MinimalHelpCommand(*args, **kwargs)```
An implementation of a help command with minimal output.

This inherits from [`HelpCommand`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.HelpCommand "discord.ext.commands.HelpCommand").
shrewd fjord
#

Its better to make your own help command instead

smoky sinew
smoky sinew
#

it's mostly focused on HelpCommand though

jolly basalt
#

yeah ill try to read and understand ig

slate swan
#

guys why message.value not working in @bot.event async def on_message(message): await bot.process_commands(message)

shrewd fjord
#

!d discord.Message.content

unkempt canyonBOT
smoky sinew
#

message.value

unkempt mauve
#

Guys what is the function for response to mention?

slate swan
#

Can I set the footer of an embed to a timestamp? eg. <t:1680499624:R>

mighty sun
#

Hello everyone, I would like to link two projects discord bot but I can't do it... possible to help me if you like? I can send it to you omplet I have all prepared

vale wing
vale wing
#

!d discord.Embed.timestamp

unkempt canyonBOT
#

The timestamp of the embed content. This is an aware datetime. If a naive datetime is passed, it is converted to an aware datetime with the local timezone.

slate swan
#

Will it show up in the footers area?

vale wing
#

You can set it in the constructor

vale wing
slate swan
#

so it'd be the epoch as a string or what? For the timestamp

vale wing
#

datetime.datetime object

slate swan
#

it converts it itself?

vale wing
#

From what

#

Do you want current time or specific

slate swan
#

I'd like it to be a relative timestamp of when the embed was sent

vale wing
#

Yeah that's current time

slate swan
#

Eg. Sent <t:1680499624:R>

vale wing
#

!e ```py
from datetime import datetime

print(datetime.now())```

unkempt canyonBOT
#

@vale wing :white_check_mark: Your 3.11 eval job has completed with return code 0.

2023-04-03 05:46:25.484971
mighty sun
#

my error :

slate swan
unkempt canyonBOT
#
Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.

mighty sun
#

just add intent ?

#

and i try ?

slate swan
vale wing
#

Embed timestamps don't support that

slate swan
#

what areas do?

naive briar
#

Anywhere that supports formatting 🤷

vale wing
#

I believe embed fields values/description and regular messages

slate swan
#

alright thanks

mighty sun
#

!paste

slate swan
#

@mighty sundid it worked?

#

adding intents?

#

if not then send full code

#

ya add intents

#

u here?

#

shall i explain?

mighty sun
#

I tried but it doesn't work I'll send it to you in private message@slate swan

naive briar
#

It doesn't work doesn't explain the problem

mighty sun
#

!paste

slate swan
#

huh?

mighty sun
#

@slate swan I sent you all in private message my friend

#

I'm sorry but I'm French and I try to do my best...

#

this is my problem

slate swan
#

heh?

mighty sun
#

my bot is a selft bot

#

mais je n'arrive pas a lancer le code que j'ai fais

slate swan
#

sending in dms is something i dont support

mighty sun
#

but I can't run the code I made

naive briar
#

Read the error

slate swan
#

cuz i am not ur personal assitance tho

mighty sun
#

ah ok sorry bro ^^

slate swan
#

yup intents missing

mighty sun
#

I didn't know sorry, I thought I could since I sent my tokens

slate swan
#

intents = discord.Intents.default()
intents.members = True
intents.messages = True
intents.message_content = True

#

do this

#

after import thing

mighty sun
#

even with a self bot I have to add that?

naive briar
#

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

mighty sun
slate swan
#

how do I get the guild icon again?

slate swan
slate swan
naive briar
unkempt canyonBOT
slate swan
#

there ppl smarter than me on this server wait for their response i g

naive briar
#

Read the docs

mighty sun
#

where ? wait I send you my different code here

#

@slate swan

slate swan
#

in the begining do import discord

mighty sun
slate swan
#

u didnt imported discord bruhhh

unkempt canyonBOT
#

Hey @mighty sun! I noticed you posted a seemingly valid Discord API token in your message and have removed your message. This means that your token has been compromised. Please change your token immediately at: https://discord.com/developers/applications

Feel free to re-post it with the token removed. If you believe this was a mistake, please let us know!

slate swan
mighty sun
#

yes a little bit but it's complicated I'm French, what should I do? import discord?

slate swan
#

do this

#

u r making it complex

mighty sun
slate swan
#

oof u added intents?

mighty sun
slate swan
#

intents = discord.Intents.default()
intents.members = True
intents.messages = True
intents.message_content = True

#

go read docs first bro

mighty sun
slate swan
#

import dc st 1st line oof

mighty sun
#

but I wrote it xD

slate swan
#

!resource

#

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

mighty sun
slate swan
#

now run bot hpefully it should work

cerulean ibex
#

using selfbot = bad ?

mighty sun
#

I am not looking to read the documents, I am looking for help because I am French

#

i use self bot

slate swan
cerulean ibex
mighty sun
slate swan
cerulean ibex
cerulean ibex
slate swan
#

lol

slate swan
# mighty sun

guess i cant help u now wait for other to come and help u are making it complicated

#

for me

mighty sun
#

then don't help me if you don't know how! I told you I was French!

#

..

slate swan
#

i am Indian tho

#

i still read docs

#

not saying i am Indian so i cant

#

Oof

mighty sun
#

so what? I didn't come to read documents I said I was looking for help

slate swan
#

cant*

#

first learn the thing u want to aim for

#

bruh this keirara guy typing so much

#

So the voice state intents give access to the member.voice,
but... you can't actually account for the time someone actually talks w/ these intents right...?
or is there a package I can use?
This would be for a custom function to add xp to user for each (x-amount-of-time) they talk...

vocal snow
#

I believe Py-cord does, but I cannot attest to how stable it is

vocal snow
slate swan
#

so can on_interaction classify as a cog listener?

naive briar
#

An event

slate swan
unkempt canyonBOT
#
Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.

shrewd apex
shrewd apex
#

maybe make a cache with userid and timestamp and check for updates then add xp

slate swan
slate swan
radiant bough
shrewd apex
slate swan
#

Is there no way to get the avatar url to default profile pictures?

vocal snow
unkempt canyonBOT
#

property display_avatar```
Returns the user’s display avatar.

For regular users this is just their default avatar or uploaded avatar.

New in version 2.0.
slate swan
#

So I can just change all of them to that I guess

#

it's an asset so it would be user.display_avatar.url to get the url i believe.

#

self.bot.user.avatar.url gets the bot's avatar url.

lament bronze
#

AttributeError: 'help' object has no attribute 'bot'

#

any help

slate swan
#

Code?

lament bronze
# slate swan Code?
class help(commands.HelpCommand):
    async def send_bot_help(self, mapping):
            self.previous = config["previous"]
            self.next = config["next"]
            self.stop = config["stop"]

            e1 = discord.Embed(color=co)
            e1.add_field(name="", value=f"", inline=False)
            e1.add_field(name="", value=f"", inline=False)
            e1.add_field(name="", value=f"", inline=False)

            e2 = discord.Embed(color=co)
            e2.add_field(name="", value=f"", inline=False)
            e2.add_field(name="", value=f"", inline=False)
            e2.add_field(name="", value=f"", inline=False)


            paginator = pg.Paginator(self.bot, [e1, e2], self.context, timeout=60, invoker=self.context.author.id)
            paginator.add_button("prev", emoji=f"{self.previous}", style=discord.ButtonStyle.blurple)
            paginator.add_button("end", emoji=f"{self.stop}")
            paginator.add_button("next", emoji=f"{self.next}", style=discord.ButtonStyle.blurple)
            return await paginator.start()
#

ignore the blank names and values I removed it when i sent code

#

invoker=self.context.author.id

#

is why im getting

#

AttributeError: 'help' object has no attribute 'bot'

golden portal
lament bronze
#

ur right i knew that

#

I thought it was self.context cus I use

#

nvm too much to explain

left dew
#

How do i make an embed send when a button has been pressed? i've tried this:

await interaction.response.send(embed=n)```
tulip frigate
#

how does this not return "false" ?

#

but if I put everything at True it returns True

#

im stuck here: I want to add someone to a list when he is: not muted, not deafened and not in an afk channel
what it rn does is following: it adds someone who is muted and deafened

naive briar
unkempt canyonBOT
#
The or-gotcha

When checking if something is equal to one thing or another, you might think that this is possible:

# Incorrect...
if favorite_fruit == 'grapefruit' or 'lemon':
    print("That's a weird favorite fruit to have.")

While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.

So, if you want to check if something is equal to one thing or another, there are two common ways:

# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
    print("That's a weird favorite fruit to have.")

# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
    print("That's a weird favorite fruit to have.")
naive briar
#

Not the same operator, but the same concept

tulip frigate
#

let me try that, one second

slate swan
#

How do i know where to add on code to a already existing code.

tulip frigate
#

finally man thank you so much @naive briar

vale wing
tulip frigate
vocal snow
#

you can just do ```py
if all((mute, deaf, afk)):

vale wing
#

Assuming those variables are strictly bools yes

vocal snow
#

they don't need to be

#

!d all

unkempt canyonBOT
#
all

all(iterable)```
Return `True` if all elements of the *iterable* are true (or if the iterable is empty). Equivalent to:

```py
def all(iterable):
    for element in iterable:
        if not element:
            return False
    return True
naive briar
#

!e

print(1 == True)
unkempt canyonBOT
#

@naive briar :white_check_mark: Your 3.11 eval job has completed with return code 0.

True
naive briar
#

True

#

Wait, I forgor yert

scarlet aurora
#

how do u get this pre built list

#
async def help(self, ctx, option = None):```
vocal snow
#

that's a slash command, not a normal text command

scarlet aurora
#

I am using a slash command

#

I'm using hybrid

scarlet aurora
raw quail
#
def test():
    old_links = []
    while True:
        try:
            base_url = ""
            with webdriver.Chrome(ChromeDriverManager().install(), options=chrome_options) as driver:
                driver.get(base_url)
                driver.implicitly_wait(7)

                title = driver.find_element_by_css_selector('').text.strip()
                link = driver.find_element_by_css_selector('').get_attribute('href')
                if link not in old_links:
                    return title, link
                
        except Exception as e:
            print(e)
        
        driver.quit()
        time.sleep(5)

i am trying to web scrapping every 5 mins(in code just test) and the sites are more than 100 but when i make codes with async def each site like this code, the bot is keep shut down. so i am trying to make with def but i don't know how to convert from title and link in def to async def
may i get advices what is good method to get the title and hyperlink of a new post every 5 minutes for more than 100 sites

supple cradle
#

@vale wing I fixed it!!

vocal snow
#

Is EmojiQuiz.get_db_data a classmethod or staticmethod?

slate swan
#

give EmojiQuiz class code

eager lily
vocal snow
#

please show it's code

#

or the whole EmojiQuiz class code

slate swan
lyric halo
#

i nedd help with my stats bot

#
def find_matching_data(id, date_str):
            with open('dnd.json', 'r') as f:
                data = json.load(f)

            matching_data = [item for item in data if item["id"] == id and item["date"] == date_str]
            if matching_data:
                return matching_data[0]
            else:
                return None

        data_item = find_matching_data(id, date_str)

        if data_item is None:
            await interaction.response.send_message(f"No data found for {selected_option}")
            return

this code scans for the matching data in dnd.json but it always responds with no data found but the data is present there

potent spear
slate swan
slate swan
#

damn levi is so cool@lyric halo

lyric halo
#

yeah

#

he is

potent spear
#

seems to be an infinite recursion

#

unless that "copied code" looks different in your IDE

lyric halo
#

im on my mobile rn ill check it up

slate swan
#

guys how fix this error ValueError: invalid literal for int() with base 10: 'visk0623\n'

slate swan
#

how make biot check the message have a ping

slate swan
#

@slate swan why u offline today?

unkempt canyonBOT
#

@shrewd fjord :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     print(int("meow"))
004 |           ^^^^^^^^^^^
005 | ValueError: invalid literal for int() with base 10: 'meow'
shrewd fjord
#

!e
print(int("123"))

unkempt canyonBOT
#

@shrewd fjord :white_check_mark: Your 3.11 eval job has completed with return code 0.

123
slate swan
#

but i want when it see a string just skip iot lol

#

u want it to be ignored?

shrewd fjord
unkempt canyonBOT
#

A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.

Warning

The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.

slate swan
shrewd fjord
slate swan
#

umm'

#

brooooo

#

bruh

#

set_image(*, url) wht is the in thid code used for?

#

@slate swan

slate swan
#

can yoguys like wtf is thisprint(serverIDofOther) if serverIDofOther == "None": print("") await interaction.send(f"Sorry But, We Found No Server With This ID :no_entry:!", ephemeral=True) return... serverIDofOther is none but it not doing anything in IF statue

vocal snow
#

There's a difference between None (NoneType) and "None" (str)

slate swan
vocal snow
#

And consider following pep8

slate swan
#

if serverIDofOther == "None":

#

and it say in consoal "None"

left dew
#

im wanting to get the content of a message in a tasks.loop() but how do i do it?

naive briar
#

Normally?

vocal snow
#

which message in particular?

slate swan
#

hw can i add image in embed?

vocal snow
unkempt canyonBOT
#

set_image(*, url)```
Sets the image for the embed content.

This function returns the class instance to allow for fluent-style chaining.
slate swan
#

ty

#

@vocal snowwht should i do is it is saying tht channel is not defined

#

pls reply

vocal snow
#

define it?

slate swan
#

@vocal snowhow can i get image url?

#

sry for silly questions

vocal snow
#

for which image

slate swan
vocal snow
#

so you have it saved on your computer?

slate swan
#

ya

#

. zeffo

slate swan
#

am abt the path

vocal snow
#

what?

slate swan
vocal snow
#

did you read the link?

slate swan
#

ya

vocal snow
#

How do I use a local image file for an embed image?
Discord special-cases uploading an image attachment and using it within an embed so that it will not display separately, but instead in the embed’s thumbnail, image, footer or author icon.

To do so, upload the image normally with abc.Messageable.send(), and set the embed’s image URL to attachment://image.png, where image.png is the filename of the image you will send.

Quick example:

content_copy
file = discord.File("path/to/my/image.png", filename="image.png")
embed = discord.Embed()
embed.set_image(url="attachment://image.png")
await channel.send(file=file, embed=embed)

slate swan
vocal snow
#

their filename is image.png

slate swan
vocal snow
#

ok

#

so change the code so it uses your filename

slate swan
slate swan
vocal snow
#

of course you have to change the path

slate swan
#

like attachment:/

slate swan