#discord-bots

1 messages · Page 714 of 1

visual island
#

to get the guild use get_guild()

slate swan
#

and access those attributes via the class.

visual island
#

yes, for class attributes, use snake_case

tawdry perch
#

My code is far away from pep8, it's a big mess

slate swan
slate swan
shadow wraith
slate swan
#

bump

#

func and serverstats are underlined yellow in vsc saying that they are not defined?

    @tasks.loop(minutes=2)
    async def serverstats(self):
        guild = self.bot.get_guild(921714401814409227)
        stats_channel = guild.get_channel(921720659653054464)
        count = len(guild.members)

        await stats_channel.edit(name = f'Member Count : {count}')
        await func.start(serverstats)
visual island
slate swan
#

Do I need to put that bit on a on_ready event?

tawdry perch
velvet tinsel
#

What’s happening

#

I’m confused

shadow wraith
slate swan
visual island
slate swan
slate swan
shadow wraith
#

true

tawdry perch
slate swan
#

oh snake case is this he_llo thinkCat i thought it was CamelCase lmao

#

sorry icy Prayge

slate swan
visual island
slate swan
visual island
#

it should have a def __init__(self, bot):

slate swan
# visual island show your cog
import discord

from discord.ext import commands
from discord.ext.commands import Cog
from discord.ext import tasks

class ServerStatsCog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @tasks.loop(minutes=2)
    async def serverstats(self):
        guild = self.bot.get_guild(921714401814409227)
        stats_channel = guild.get_channel(921720659653054464)
        count = len(guild.members)

        await stats_channel.edit(name = f'Member Count : {count}')
        await self.serverstats.start()
    
    @Cog.listener()
    async def on_ready(self):
        print(f"[ServerStatsCog Loaded]")

def setup(bot):
    bot.add_cog(ServerStatsCog(bot))
#

oh yeah

visual island
#

yeah start it there

slate swan
#

Ok thanks

visual island
#

and remove await

slate swan
#

So like this?

class ServerStatsCog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.serverstats.start()
visual island
#

yes

slate swan
#

Nice

#

Thanks for the help 😄

shadow wraith
visual island
slate swan
#

is there a way to check if its a slash command or not without checking the prefix ?

tawdry perch
shadow wraith
#

which ot channel

slate swan
#

uh, I have imported get from discord.utils?

    stats_channel = guild.get_channel(921720659653054464)
AttributeError: 'NoneType' object has no attribute 'get_channel'
slate swan
tawdry perch
slate swan
slate swan
visual island
slate swan
#

Nope

visual island
#

anyways, change the guild.get_channel to self.bot.get_channel and get the guild from stats_channel.guild

slate swan
#

Ok

visual island
#

so that you dont need to get the channel manually

slate swan
#

Does it matter if the provided id for the channel is a vc?

heavy folio
#

idts

maiden fable
#

👀

visual island
maiden fable
#

don't mind me, I am just editing my profile for the server

visual island
#

as always, nitro flex

maiden fable
#

No

#

I can't edit the server pfp. Was changing my nick

slate swan
#

How do I find the count now

    count = len(guild.members)
AttributeError: 'NoneType' object has no attribute 'members'
maiden fable
#

guild is None

maiden fable
#

Wrong ID most probably

#

Also there's guild.member_count BTW

visual island
slate swan
maiden fable
#

Ok if it isn't

slate swan
visual island
#

stats_channel is a GuildChannel instance, it has guild attribute

slate swan
#

bruh

    guild = stats_channel.guild(921714401814409227)
AttributeError: 'NoneType' object has no attribute 'guild'
vale wing
#

Stats channel is not gotten properly

slate swan
#

It's a valid guild id

vale wing
#

Try printing your variables

slate swan
#

Ok

cedar stream
unkempt canyonBOT
#

wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
cedar stream
#

!d discord.Client.wait_until_ready

unkempt canyonBOT
#

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

Waits until the client’s internal cache is all ready.
cedar stream
#

This, not that b4

slate swan
#

oh really FLISH he should learn how to read

visual island
cedar stream
unkempt canyonBOT
#
Fat chance.

No documentation found for the requested symbol.

cedar stream
#

!d discord.TextChannel.guild

unkempt canyonBOT
cedar stream
#

It’ s not a method

gloomy cloud
shadow wraith
#

actually how do you get the bot count in disnake

cedar stream
slate swan
shadow wraith
#

bot counts like how much bots there are in a server

#

not a server, i mean the server the bot is in

slate swan
#

[member for member in guild.members if member.bot]

cedar stream
shadow wraith
#

ok and something like [x for x in ctx.guild.members if not x.bot] should also show the member count except bots

slate swan
#

Bot.members is not a thing ig

cedar stream
cedar stream
#

And I might have used wrong name

shadow wraith
#

ok but what's the member version of x.bot

cedar stream
#

False

shadow wraith
#

💀 not what i meant

slate swan
cedar stream
#

It’ s a bool

shadow wraith
#

oh

cedar stream
slate swan
#

!d discord.Client.get_all_members

unkempt canyonBOT
#

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

This is equivalent to:

```py
for guild in client.guilds:
    for member in guild.members:
        yield member
slate swan
#

hi

#

Yeah

shadow wraith
#

i don't use discord.Client

slate swan
#

I have a problem with selenium

cedar stream
shadow wraith
slate swan
#

Everything in discord.Client can be used in commands.Bot @shadow wraith

#

no

shadow wraith
#

then ask somewhere else

slate swan
#

webdriver

shadow wraith
#

this is not the right channel

cedar stream
slate swan
#

C:\Users\arouf\PycharmProjects\Bot\venv\Scripts\python.exe C:/Users/arouf/PycharmProjects/Bot/bot.py
Traceback (most recent call last):
File "C:\Users\arouf\PycharmProjects\Bot\venv\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Users\arouf\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\arouf\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] Le fichier spécifié est introuvable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\arouf\PycharmProjects\Bot\bot.py", line 3, in <module>
driver = webdriver.Firefox()
File "C:\Users\arouf\PycharmProjects\Bot\venv\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 144, in init
self.service.start()
File "C:\Users\arouf\PycharmProjects\Bot\venv\lib\site-packages\selenium\webdriver\common\service.py", line 79, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.

Process finished with exit code 1

shadow wraith
#

this is wrong channel, go ask somewhere else

shadow wraith
#

!d discord.ext.commands.Bot.guilds

unkempt canyonBOT
tiny ibex
#

Download it first

#

@slate swan

slate swan
#

what is geckodiver ?

tiny ibex
#

Geckodriver is used to interact with Firefox binaries

#

Just the way chromedriver is used for Chrome binaries

slate swan
#

I'm not very ....

#

strong

tiny ibex
slate swan
#

Please read the channel topic

#

yeah 2 min

tiny ibex
#

@slate swan please make a help channel

slate swan
#

ok

slate swan
#

How can I get the member count, I receive this error when I try this.

    count = len(stats_channel.guild.members)
AttributeError: 'Object' object has no attribute 'members'
``````py
    @tasks.loop(minutes=2)
    async def serverstats(self):
        stats_channel = await self.bot.fetch_channel(925350190016249936)
        count = len(stats_channel.guild.members)

        await stats_channel.edit(name = f'Member Count : {count}')
visual island
slate swan
#

above it?

visual island
#

yes

urban shell
#

hey, I'm trying to get the url of a member's banner
this is my code -

member = message.author
pfp = member.banner.url
#

I'm getting an Attribute error

slate swan
urban shell
#

I was referring SO

#

and came across this solution

slate swan
urban shell
slate swan
slate swan
#

they dont have a banner.

urban shell
slate swan
#

test it on someone who does shrug

urban shell
slate swan
urban shell
#

I was testing it on myself

slate swan
#

alr then

#

why are you using message ?

#

are you using it in an event thinkCat

slate swan
slate swan
#

yeah

urban shell
slate swan
#

i am want to make a function in which if a new user uses a command my bot will send a dm for this
is a database required?

urban shell
#

this is what I use to fetch the banner url

urban shell
slate swan
urban shell
#

not necessarily

#

you can use a JSON file as well

#

instead of a db

slate swan
#

You can send a GET request to https://discord.com/api/v9/users/{user.id}/profile to get a user's Banner, Banner color, bio & linked accounts

#

and json file doesnt like have a good relation with json

#

the json file resets as soon as the bot relaunches

#

pip install -U git+https://github.com/Rapptz/discord.py @urban shell

#

you dont have it installed.

urban shell
#

I referred SO

#

like you're doing rn

slate swan
#

make the bot print the version of discord.py you've got

#

discord.__version__

urban shell
slate swan
#

just do what i said FL_ANGERY

#

or

urban shell
#

😩

slate swan
#

cogs a using a listener as a command Dealwumpusit

urban shell
#

I don't wanna send the whole thing

#

and I'm pretty sure that's not the issue anyways

slate swan
#

okay

potent spear
urban shell
urban shell
manic wing
urban shell
#

nvm

#

I think I know what's wrong

potent spear
urban shell
#

2.0

potent spear
# urban shell 2.0

banner says this

Returns the user’s banner asset, if available.
so this means that the author doesn't have a banner

#

so maybe if you were to fetch the author, it might get the banner?

shadow wraith
#

how can i read what actions send a request to Discord Bot API and what don't

leaden hollow
#

Traceback (most recent call last):
File "c:\Primary\HawT\main.py", line 1, in <module>
import discord
ModuleNotFoundError: No module named 'discord'

potent spear
slate swan
#

how do you run the file? If you use the play button -> don't do that

leaden hollow
#

Oh lol

#

I forgot it was a reopened file

#

I was running it as code

#

not python file

slate swan
#

Understandable

slate swan
shadow wraith
#

huh so adding reactions, sending messages will send a request to discord's api

#

cool cool

slate swan
#

Ofcourse

shadow wraith
#

does this apply to aiohttp fetching?

slate swan
#

Note that the await thing was only for discord.py methods

slate swan
shadow wraith
#

cool cool

honest vessel
#

thats not even python

rapid walrus
#

oh right

#

;-;

boreal ravine
rapid walrus
#

ok

boreal ravine
#

making bots is boring

shadow wraith
#

kind of wish i had a github account

boreal ravine
#

make one then?

#

its free

shadow wraith
#

can bot groups also support @commands.guild_only()

boreal ravine
#

they are still a command object iirc

shadow wraith
#

technically they hold the commands

boreal ravine
#

ye ig

pliant gulch
#

They are a subclass of a Command class so they are command objects

modern fiber
#

Can somebody help me?

#

I need a command that gives the user role he has in a roblox group.
Also, if possible, for it to change his nickname. Actually, to add (Rank) @amber beacon to his nickname!

Here is the current code I got.

groupID = 9247039
robloxCookie = ""
xsrf = ""

@bot.command()
async def promote(cts, user: int, role: int):
    with requests.Session() as group:
        # get xsrf, its needed.
        group.cookies['.ROBLOSECURITY'] = robloxCookie
        xsrff = group.post('https://friends.roblox.com/v1/users/1/request-friendship')
        xsrf = xsrff.headers['x-csrf-token']
        # Promote user!
        url = f"https://groups.roblox.com/v1/groups/{groupId}/users/{user}"
        group.headers["Content-Type"] = "application/json"
        data = {"roleID": role}
        res = group.post(url)
        await ctx.send(res.json())
shadow wraith
#

to his discord username?

#

i mean nickname

#

to change his nickname just do nick=... in a {discord_member_obj}.edit()

#

and you can fetch the rank, and make it their nickname with fstrings x]

vale wing
#

Change cts to ctx, pretty sure you made a typo

#

Also better hints exist, I mean

async def promote(ctx, user: discord.User, role: discord.Role)```
#

In this case discord.Member

boreal ravine
#

but user in this code is supposed to be an integer

vale wing
#
await user.add_roles(role)``` to add roles
stark fog
#

Hello

slate swan
#

its a roblex id right?

stark fog
#

Does anyone know where the available channels category is?

#

oh nvm

boreal ravine
# vale wing Why?
        url = f"https://groups.roblox.com/v1/groups/{groupId}/users/{user}"

lol

stark fog
#

just found it

vale wing
#

Uh hold up

stark fog
#

sorry

vale wing
#

You kinda mixed everything in code so it confused me sry

modern fiber
#

No, basically,

#

I want so when user gets the role in the roblox group, and when he runs !update it gives him the role in discord server with the same name of one he has in roblox group

#

and if possible, for it to change his nickname like (Rank) @ornate flax

#

@vale wing

jade jolt
#

yea

cedar stream
#

403

jade jolt
#

not for me

cedar stream
#

Nvm

jade jolt
cedar stream
#
tame sierra
#

I used user.display_name but it stilled returned their username even though they have a nickname?

tawdry perch
#

!d discord.Member.display_name

unkempt canyonBOT
#

property display_name: str```
Returns the user’s display name.

For regular users this is just their username, but if they have a guild specific nickname then that is returned instead.
tawdry perch
#

Hmm

cloud bison
#

is there a way I can make sticky message?

tawdry perch
#

Sticky?

tame sierra
# maiden fable Show?
@bot.command()
async def view(ctx, user: discord.User, *, message=None):
    user_id = user.id
    username = user.name
    char_name = user.display_name
cloud bison
tawdry perch
#

Uhh

#

Never seen anyone make one

wicked atlas
#

I mean, you could make a bot that re-sends the message and deletes the old message everytime a new message is sent in that channel, but that could break in a few ways

cloud bison
#

sadly 😭

tame sierra
jagged root
#
async def suggest(ctx, *, query):

    if ctx.author.bot:
        return
    else:
        
        if "suggest" in ctx.content.lower(
        ):

            embed = disnake.Embed(
                
                description=
                f":bust_in_silhouette: ❘ **User:** {ctx.author}\n\n:bulb: ❘ **Suggestion:**\n\n{' '.join(ctx.message.content.split(' ')[1:])}",
        colour=0x4e5ece
            )
            channel = bot.get_channel(924998519432036393)
        await channel.send(embed=embed)```

```AttributeError: 'Context' object has no attribute 'content'```
potent spear
#

also, the else statement is useless, remove that line
you're returning in the if statement anyways

jagged root
#

ok

jagged root
potent spear
jagged root
#

kk

jagged root
# potent spear `if "suggest" in ctx.content....` should be `in ctx.message.content...`
async def suggest(ctx, *, query):

    if ctx.author.bot:
        return
    
        
        if "suggest" in ctx.message.content(
        ):

            embed = disnake.Embed(
                
                description=
                f":bust_in_silhouette: ❘ **User:** {ctx.author}\n\n:bulb: ❘ **Suggestion:**\n\n{' '.join(ctx.message.content.split(' ')[1:])}",
        colour=0x4e5ece
            )

            channel = bot.get_channel(924998519432036393)
        await channel.send(embed=embed)```
#

still doesnt work

#

@potent spear

potent spear
jagged root
#

oh

potent spear
#

what are you actually trying to do

jagged root
#

a suggestion command

potent spear
#

don't tell me in code language, tell me as a non-dev would say it

#

"If I say suggest shit" it'll do ...

jagged root
#

if i say suggest (suggestion) send an embed with the suggestion

#

@potent spear

potent spear
jagged root
#

ok what should i put then

potent spear
#

just your embed and the channel send shit

jagged root
#

nvm

#

k

#

testing

potent spear
#

also, I don't think a bot will ever use your command, you can simply remove that line, it's only handy in on_message events

jagged root
#
async def suggest(ctx, *, query):

    if ctx.author.bot:
        return

        embed = disnake.Embed(
                
                description=
                f":bust_in_silhouette: ❘ **User:** {ctx.author}\n\n:bulb: ❘ **Suggestion:**\n\n{' '.join(ctx.message.content.split(' ')[1:])}",
        colour=0x4e5ece
            )

        channel = bot.get_channel(924998519432036393)
        await channel.send(embed=embed)```

nothing
#

ok

potent spear
jagged root
#

wym

potent spear
#

the whole embed and channel etc is in the if statement

jagged root
#

hm

#

what i do lol

quick gust
#

... put it outside the if statement

leaden hollow
#

so I'm making a bot which can ask random questions, is there any way to send the question ID in footer like in this picture

potent spear
leaden hollow
#

I just declared a list in code

jagged root
quick gust
#

BRUH

leaden hollow
# potent spear ofc... if you have them stored somewhere
@commands.command(aliases=['T'])
    async def Truth(self, ctx):
        tr = ["Test Question 0",
        "Test Question 1",
        "Test Question 2",
        "Test Question 3",
        "Test Question 4",
        "Test Question 5",
        "Test Question 6",
        "Test Question 7",
        "Test Question 8",
        "Test Question 9"]
        rc = random.choice(tr)
        temb = discord.Embed(description=f"**Truth:\n**{rc}",color=0x2e72e8,)
        temb.set_footer(text='footer')
        await ctx.send(embed=temb) ```
this  is my current code
jagged root
leaden hollow
#

ignore the image

potent spear
jagged root
leaden hollow
potent spear
leaden hollow
#

I just want to make custom ids

jagged root
#

or im dum xd

potent spear
potent spear
jagged root
potent spear
jagged root
#

it will return if bot sends the message not if a user does

potent spear
jagged root
#

statement is line?

potent spear
#

just select all those lines
and do shift+tab

jagged root
#

ok

potent spear
#

all the lines under the return

#

also, your colour will not work, you'll see

jagged root
potent spear
#

once

jagged root
#
                         ^
IndentationError: unindent does not match any outer indentation level```
potent spear
#

I wanna see all the code in that command

quick gust
jagged root
#

kk

quick gust
#

... u didn't do what Glitcherz told u to do...

cloud dawn
#

morning yall

jagged root
#

oh now

potent spear
#

🤦‍♂️
you probably didn't even know what shift+tab did

jagged root
#

Thank you so much @potent spear

#

it worked

#

im a bit dumb ik

potent spear
#

I highly suggest you to learn python before doing such projects

jagged root
#

i did but kinda forgot everything

cloud dawn
jagged root
#

ight

quick gust
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.

jagged root
#

thanks

manic wing
# jagged root
if ctx.author.bot: 
  return ``` this isnt necessary, considering commands cant be invoked by bots in the first place. ![pithink](https://cdn.discordapp.com/emojis/652247559909277706.webp?size=128 "pithink")
#

there is already a check

jagged root
#

kk

potent spear
#

as mentioned 1hour ago

boreal ravine
#

how do i give jsk access to other ppl too?

slate swan
#

ive read docs but i havent seen anything saying everybody can use it

boreal ravine
#

but ive seen people do it

slate swan
#

idk because jsk is only for bot owners

prisma spoke
#

Make a check ig

slate swan
#

no?

#

jsk takes the id from a owner kwarg or the application and makes it so the bot owner can only use it

#

maybe theres a new feature or something

boreal ravine
#

i dont wanna edit jsk internals

slate swan
boreal ravine
#

whats disjsk?

shadow wraith
#

!pypi disnake-jishaku

unkempt canyonBOT
slate swan
#

😳

shadow wraith
#

you mean this?

slate swan
#

yeh

#

had a typo in pypi

shadow wraith
#

wait so disnake has threads support (threads have been existing for like 10-30 days or something)

boreal ravine
#

they have existed longer than that

slate swan
#

yeah

#

maybe 5m

shadow wraith
#

what's the name for it 🤔

boreal ravine
#

!d discord.TextChannel.threads

unkempt canyonBOT
#

property threads: List[discord.threads.Thread]```
Returns all the threads that you can see.

New in version 2.0.
slate swan
#

thats cool

shadow wraith
#

!d disnake.TextChannel.threads

unkempt canyonBOT
#

property threads: List[disnake.threads.Thread]```
Returns all the threads that you can see.

New in version 2.0.
shadow wraith
#

nice

slate swan
#

a fork?

final iron
#

Dpy fork

slate swan
#

!pypi disnake

unkempt canyonBOT
shadow wraith
#

ive been using it for 2 days 😭

slate swan
#

ive been on it for maybe 2monthspithink

#

i love disnakes buttons tho

shadow wraith
#

💀

slate swan
#

lmao

shadow wraith
#

!d disnake.ui.button

unkempt canyonBOT
#

disnake.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.

The function being decorated should have three parameters, `self` representing the [`disnake.ui.View`](https://docs.disnake.dev/en/latest/api.html#disnake.ui.View "disnake.ui.View"), the [`disnake.ui.Button`](https://docs.disnake.dev/en/latest/api.html#disnake.ui.Button "disnake.ui.Button") being pressed and the [`disnake.MessageInteraction`](https://docs.disnake.dev/en/latest/api.html#disnake.MessageInteraction "disnake.MessageInteraction") you receive.

Note

Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://docs.disnake.dev/en/latest/api.html#disnake.ui.Button "disnake.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
shadow wraith
#

whats new

slate swan
#

!d disnake.ui.View

unkempt canyonBOT
#

class disnake.ui.View(*, timeout=180.0)```
Represents a UI view.

This object must be inherited to create a UI within Discord.

New in version 2.0.
shadow wraith
#

oh fuck there's timeouts which expires the buttons

slate swan
shadow wraith
#

damn

slate swan
#

old stuff lol

boreal ravine
#

for what? raw api?

shadow wraith
#

i forgor how to do basic python so does it go like class shitcordwtf(disnake.ui.View().timeout=180.0)

boreal ravine
#

iirc you can do that in dpy also

slate swan
#

you add it in super()

shadow wraith
#

oh so super().__init__(timeout=...)

boreal ravine
tawdry perch
#

Which one is better? ```py
if ctx.invoked_subcommand is None:
if not ctx.invoked_subcommand:

slate swan
tawdry perch
shadow wraith
boreal ravine
slate swan
shadow wraith
#

x[

shadow wraith
tawdry perch
#

I see

shadow wraith
#

!e

d = None
if not d:
  print("lol")
else:
  print("bru")
unkempt canyonBOT
#

@shadow wraith :white_check_mark: Your eval job has completed with return code 0.

lol
shadow wraith
#

nvm it does check if its none or false ig

tawdry perch
prisma spoke
boreal ravine
slate swan
#

i dont think you can

#

afaik the only way for more people to use it is to add more ids in the owner kwarg in the bot constructor

boreal ravine
#

that'll work?

slate swan
#

i think so yes

prisma spoke
slate swan
#

but i suggest you trust them as jsk can run anything on your local computer afaik

slate swan
#

just get_cog("Jishaku") and .add_check

boreal ravine
#

that'll work?

#

ic

slate swan
#

doesnt jsk run the code given in your local computer?

boreal ravine
slate swan
boreal ravine
#

ah ok

slate swan
#

!d discord.ext.commands.Cog.cog_check

unkempt canyonBOT
#

cog_check(ctx)```
A special method that registers as a [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") for every command and subcommand in this cog.

This function **can** be a coroutine and must take a sole parameter, `ctx`, to represent the [`Context`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Context "discord.ext.commands.Context").
boreal ravine
#

wait how would i pass the check?

quaint epoch
#

what's the difference between py print(member_object.name) and py print(member_object.display_name)?

boreal ravine
quaint epoch
#

so, if i want to give the name and discriminator then member.name is the way to go?

quick gust
#

yeah

slate swan
#

In short , the function is the check itself

slate swan
quaint epoch
slate swan
vale wing
slate swan
#

just string the member as said

quaint epoch
sick birch
#

if it's in an f string {member} works too

#

it automatically gets str()

slate swan
#

Yeah

#

i still have 347 functions to make out of like 1000

boreal ravine
#

y?

shadow wraith
#

how do you check if a message is sent in a channel using for loop

slate swan
#

cant tell rnpithink

sick birch
#

You can compare the ID of the channel the message is sent in to the ID of the channel you want to check against

#

using a simple if statement

shadow wraith
#

no im trying to do something like:

for message in channel:
  await message.add_reaction("emoji")
vale wing
#

😳

sick birch
#

Gonna get ratelimited really fast

#

But you can have if/else inside of the for loop

vale wing
#
async for m in channel.history(limit=10):
  #do smth```
#

Iirc

sick birch
#

I assume they were only giving pseudocode

slate swan
sick birch
#

Pretty sure channel.history() is a generator

slate swan
#

It's an AsyncIterator ig

#

!d discord.TextChannel.history

#

¯_(ツ)_/¯

unkempt canyonBOT
#

async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.

You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.

Examples

Usage...
sick birch
#

If you just want a list you can do .flatten() on it

slate swan
#

Yea

#

guess it is

sick birch
#

Then just loop over it like normal

#

So it's not a generator pithink

slate swan
#

It still would need to be awaited

jagged root
#
async def suggest(ctx, *, query):

    embed = discord.Embed(
        color=0xff0000,
        description=
        f":bust_in_silhouette: ❘ **User:** {ctx.author}\n\n:bulb: ❘ **Suggestion:**\n\n{' '.join(ctx.message.content.split(' ')[1:])}")

    if "!suggest + your suggestion here." not in ctx.channel.topic:
        return

    embed.set_thumbnail(url=ctx.author.avatar_url)
    channel = bot.get_channel(924998519432036393)
    msg = await channel.send(embed=embed)
    await msg.add_reaction("![chec_k1929](https://cdn.discordapp.com/emojis/925060447974096937.webp?size=128 "chec_k1929")")
    await msg.add_reaction("![cros_s293](https://cdn.discordapp.com/emojis/925060541335085056.webp?size=128 "cros_s293")")
    await ctx.send(f"✅ {ctx.author.mention}, succesfully sent your suggestion to [#924998519432036393](/guild/267624335836053506/channel/924998519432036393/).", delete_after=12)```
works but doesnt add reaction and send the confirmaton message
vale wing
#

Pretty sure you need to get emoji object to provide as an argument to add_reaction, lemme check

#

!d discord.Message.add_reaction

unkempt canyonBOT
#

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

Add a reaction to the message.

The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").

You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
slate swan
#

Nah that works too

vale wing
#

Seems like it doesn't

jagged root
#

hm

vale wing
#

Try getting emoji object

#

And providing it as an argument

slate swan
#

if your using vsc you can just copy paste the emoji lol

jagged root
#

and what about the confirmation it doesnt work ethier

vale wing
#

He's using guild emoji

slate swan
#

ah my bad

jagged root
#
``` that doesnt work too
vale wing
#

Not sure

#

Try to fix the reaction adding first

jagged root
# vale wing Try to fix the reaction adding first
async def suggest(ctx, *, query):

    embed = disnake.Embed(
            
            description=
            f":bust_in_silhouette: ❘ **User:** {ctx.author}\n\n:bulb: ❘ **Suggestion:**\n\n{' '.join(ctx.message.content.split(' ')[1:])}",
    colour=0x4e5ece
        )
    
    channel = bot.get_channel(924998519432036393)
    emoji1 = "![chec_k1929](https://cdn.discordapp.com/emojis/925060447974096937.webp?size=128 "chec_k1929")"
    emoji2 = "![cros_s293](https://cdn.discordapp.com/emojis/925060541335085056.webp?size=128 "cros_s293")"
    await channel.send(embed=embed)
    await msg.add_reaction(emoji)
    await msg.add_reaction(emoji1)
    await msg.send(f"✅ {ctx.author.mention}, succesfully sent your suggestion to [#924998519432036393](/guild/267624335836053506/channel/924998519432036393/).", delete_after=12)```
like that mate?
vale wing
#

Nono

jagged root
#

oh

vale wing
#

You didn't get the Emoji object

jagged root
#

sorry idk how

vale wing
#

I don't remember how properly but here's a method

discord.utils.get(ctx.guild.emojis, id=925060447974096937)```
vale wing
#

You didn't provide a required argument

vale wing
jagged root
#

ight

sage otter
#

!d discord.Client.get_emoji

unkempt canyonBOT
vale wing
#
await msg.add_reaction(bot.get_emoji(925060447974096937))```
@jagged root
jagged root
#

kk

vale wing
#

Please format your code

sage locust
#

So fellas, I got me this bot that needs to build a report and transmit to an admin, problem is this report takes about 35 seconds to assemble… I cannot seem to figure out how to run the task without blocking the discord client and causing a timeout.

vale wing
#

@slate swan you just didn't provide a reason argument

#

When using command

sage locust
#

I have tried acyncio.loop and all but it only ends in a runtime error

jagged root
#
@bot.command()
async def suggest(ctx, *, query):

    embed = disnake.Embed(
            
            description=
            f":bust_in_silhouette: ❘ **User:** {ctx.author}\n\n:bulb: ❘ **Suggestion:**\n\n{' '.join(ctx.message.content.split(' ')[1:])}",
    colour=0x4e5ece
        )
    
    channel = bot.get_channel(924998519432036393)
    
    await channel.send(embed=embed)
    await msg.add_reaction(bot.get_emoji(925060447974096937))
    await msg.add_reaction(bot.get_emoji(925060541335085056))
    await msg.send(f"✅ {ctx.author.mention}, succesfully sent your suggestion to [#924998519432036393](/guild/267624335836053506/channel/924998519432036393/).", delete_after=12)```

still doesnt work
vale wing
#

Hold up

#

msg = await channel.send(embed=embed)

#

msg is not defined

jagged root
#

oh

shadow wraith
# unkempt canyon

is there any other way to track every message sent in the channel and add a reaction to it other than receiving the history, im not gonna get blocked by discord api :[

final iron
#

!d discord.Guild.roles

unkempt canyonBOT
#

property roles: List[discord.role.Role]```
Returns a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of the guild’s roles in hierarchy order.

The first element of this list will be the lowest role in the hierarchy.
jagged root
#

fixed!!

#

@vale wing

vale wing
unkempt canyonBOT
#

help([object])```
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.

Note that if a slash(/) appears in the parameter list of a function when invoking [`help()`](https://docs.python.org/3/library/functions.html#help "help"), it means that the parameters prior to the slash are positional-only. For more info, see [the FAQ entry on positional-only parameters](https://docs.python.org/3/faq/programming.html#faq-positional-only-arguments).

This function is added to the built-in namespace by the [`site`](https://docs.python.org/3/library/site.html#module-site "site: Module responsible for site-specific configuration.") module.
shadow wraith
final iron
#

#bot-commands

vale wing
#

!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.
sage otter
#

I mean your bot already tracks messages

#

messages are appended into the internal message cache.

#

!d discord.Client.cached_messages

unkempt canyonBOT
#

property cached_messages: Sequence[Message]```
Read-only list of messages the connected client has cached.

New in version 1.1.
sage otter
#

You can process those 👌

shadow wraith
#

!d disnake.ext.commands.Bot.cached_messages

unkempt canyonBOT
shadow wraith
#

doesn't getting the history of a channel send a request to discord api

shadow wraith
boreal ravine
unkempt canyonBOT
#

async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.

You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.

Examples

Usage...
boreal ravine
#

limit=699999

tiny ibex
#

Nvm can someone tell me the endpoint to fetch user details with required headers

boreal ravine
#

wrong server m8

shadow wraith
#

does that send a request to discord API

shadow wraith
#

if you try reading history

boreal ravine
tiny ibex
#

Phone not verified

slate swan
#

is there a way you can get a timestamp accurate to the second instead of saying "in a few seconds" when its 30 seconds

shadow wraith
#

verify it

boreal ravine
#

loads of developers there

sage otter
#

They probably won’t say anything there either

tiny ibex
boreal ravine
sage otter
#

There’s two different discord api servers you can go to. The unofficial and official.

boreal ravine
#

^

#

owned by Danny one of them

tiny ibex
#

It's a discord bot and python related question and looks like this channel was made for that

sage otter
shadow wraith
sage otter
#

why wouldn’t it

#

well actually. Hmm

shadow wraith
#

i think the request bigger the more history wants to be readed

boreal ravine
shadow wraith
#

and that method is not cached?

slate swan
#

is there a way you can get a timestamp accurate to the second instead of saying "in a few seconds" when its 30 seconds

sage otter
#

no your message cache is only as old as your bots lifetime.

shadow wraith
#

well i have no __pycache__ folder so ¯_(ツ)_/¯

sage otter
#

no oogh

#

That’s different

boreal ravine
# tiny ibex It's a discord bot and python related question and looks like this channel was m...

ur question wasn't discord-bots related at all, you were asking about the endpoint to fetch user details, you can either ask in the official/unofficial api server, or you can go read ddocs https://discord.com/developers/docs/resources/user#get-user

Discord Developer Portal

Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.

sage otter
boreal ravine
slate swan
#

is there a different way?

boreal ravine
tiny ibex
boreal ravine
slate swan
tiny ibex
# boreal ravine ^

If someone asks you the same question but with dpy instead it suddenly relates to bots?

boreal ravine
#

depends on the context

tiny ibex
boreal ravine
tiny ibex
#

Just cuz I am asking it from, raw api doesn't change the aim

sage otter
# shadow wraith well i have no `__pycache__` folder so ¯\_(ツ)_/¯

So to re-elaborate. You could theoretically get a channels message history yourself. But it’s unlikely it will be all of them. Since your bots internal message cache is only as old as your bots lifetime and it also has a limit too. So realistically you would have to make a api call either way.

sage locust
#

You can get them

#

I have a deal for this

tiny ibex
lusty heron
#

Hey I have a problem with this code

slate swan
#

thanks

unkempt canyonBOT
lusty heron
#

Can someone check this code

#

It gives me this error
and say the error is "line 70, in update_status
users(user)[mode] = change
TypeError: 'dict' object is not callable"

sage locust
slate swan
#

user must be a key

#

And should be put in square brackets

honest vessel
#

() is function

lusty heron
#

Yes

boreal ravine
slate swan
#

Hmm?

slate swan
lusty heron
#

One sec

slate swan
#

Mhm

honest vessel
#

also this

#

status = users(user)["status"] needs change

honest vessel
lusty heron
sage locust
honest vessel
lusty heron
slate swan
honest vessel
#

that would be wrong i guess

lusty heron
#

Yes that too

#

I forgot to type

slate swan
#

Umm...m

#

Thats where the error was

#

So....you basically removed the erroring code

#

Ingenious

lusty heron
#

What

slate swan
slate swan
lusty heron
#

Oh ok thnx

honest vessel
#

@slate swanor it... happy?

boreal ravine
slate swan
slate swan
jagged root
#

why when i add embed.set_thumbnail(url=ctx.author.avatar_url) to my code it says AttributeError: 'Member' object has no attribute 'avatar_url'

#

please help

slate swan
#

Try adding a message attr after ctx

jagged root
#

didnt understand

olive osprey
#

https://paste.pythondiscord.com/loridaruji.py

Hi! I have this keyerror in my code:

    users[user][mode] = change
KeyError: <Member id=703671503954378782 name='down bad' discriminator='8487' bot=False nick='down christmas :snowman:' guild=<Guild id=897866866557603890 name='LateNight' shard_id=None chunked=False member_count=112>>```
slate swan
jagged root
#

lemme see

#

how can i check that

#

i think im in the lastest one

jagged root
slate swan
jagged root
#

okay

jagged root
jagged root
#

same error

honest vessel
#

@olive osprey@lusty heronwhy u change account and ask same Q?

slate swan
#

hes trying to be sneaky ofc

olive osprey
#

^atleast not yet

jagged root
slate swan
#

still have to do 300functions😠😔

honest vessel
#

its always "my friend"

#

"i ask for a friend..."

slate swan
jagged root
#

@slate swan

slate swan
#

why me

jagged root
#

xd

slate swan
#

Why not

#

cause im not smart

jagged root
#

why when i add embed.set_thumbnail(url=ctx.author.avatar_url) to my code it says AttributeError: 'Member' object has no attribute 'avatar_url'

slate swan
#

You're the smartest here as of now

#

idk about that one

jagged root
#

F

slate swan
#

see caeden is here

manic wing
unkempt canyonBOT
#
Nuh-uh.

No documentation found for the requested symbol.

manic wing
#

this is what it is ^

slate swan
#

hes smarter than me

manic wing
#

but its not documented

jagged root
#

OOF

#

so

#

what should i do

manic wing
#

ctx.author.avatar.url

#

which I doubt

slate swan
jagged root
#

should i update it?

manic wing
jagged root
#

i am

slate swan
#

have to do 300 more functions bye guys

manic wing
#

just try it

jagged root
#

[[package]]
name = "discord.py"
version = "1.7.3"
description = "A Python wrapper for the Discord API"
category = "main"
optional = false
python-versions = ">=3.5.3"

manic wing
jagged root
#

should i update it?

jagged root
manic wing
jagged root
#

worked!!

slate swan
#

no

jagged root
manic wing
jagged root
#

i use disnake

jagged root
slate swan
#

Pycord is way better imo but yea

manic wing
#

why tf did you say discord.py 1.7 if you use disnake x.x

#

i was right either way but still

jagged root
#

xd

manic wing
slate swan
manic wing
#

you're in the wrong place

slate swan
slate swan
#

I use pycord

slate swan
#

Ofc

#

soon will

#

Someone here was going to complete their 300 funcs

#

shhhh

#

smh give me a break ive already done 1000 no joke😠😔

slate swan
slate swan
#

cant tell rnpithink

#

project is already at line 1945 im still missing 300funcs

slate swan
manic wing
#

how many commands does your bot have

slate swan
#

not a bot

manic wing
#

anyone

#

how many commands do any of your bots have

slate swan
#

3

slate swan
dire folio
#

Like 10 or smth

slate swan
#

Cuz i only finished my two cogs yesterday so

#

smh

manic wing
slate swan
quick gust
slate swan
#

your help command is seggsy tho👀

slate swan
manic wing
outer violet
#

How do I get the number of commands in a cog?

manic wing
slate swan
#

i think i have covid

slate swan
manic wing
#

docs, crime and trivia are temp

slate swan
#

its smt else

#

☹️

manic wing
unkempt canyonBOT
slate swan
#

I’m pretty sure i have covid

slate swan
#

havent done my api wrapper because..................

#

Cuz my cough

dire folio
slate swan
prime marten
#

Hi. Iv'e heard a lot of comments that json isnt a good database to use if you are planning to have a bot in many servers, are there any other good and easy-to-use options?

manic wing
unkempt canyonBOT
#

Pybot.py line 90

embed4 = disnake.Embed(```
slate swan
slate swan
quick gust
slate swan
manic wing
prime marten
manic wing
slate swan
#

!pypi aiosqlite

unkempt canyonBOT
dire folio
manic wing
#

not really

slate swan
dire folio
#

Is that all?

manic wing
#

yes

slate swan
#

or import disnake as discord

dire folio
#

Thought there would be a lot more to do

manic wing
#

cough i do appreciate stars though 😳

slate swan
#

ill donate one

manic wing
#

i love github star donations <3

slate swan
#

if you star pybot ;))

manic wing
#

deal

slate swan
#

deal

manic wing
#

🤝

slate swan
#

done

#

pleasure doing business

manic wing
#

nods

slate swan
#

🕵️‍♂️

slate swan
#

@manic wing can i contribute?

#

not like i will much

manic wing
#

you can make pull requests

slate swan
#

ill do one later

dire folio
#

How to send a msg when someone has boosted a server

slate swan
slate swan
#

Lolll

#

havent even started its been 10 hours😔

slate swan
slate swan
slate swan
#

(╯°□°)╯︵ ┻━┻

dire folio
#

i did import disnake as discord and i got:

Traceback (most recent call last):
  File "main.py", line 1, in <module>
Traceback (most recent call last):
  File "main.py", line 50, in <module>
    bot = commands.Bot(command_prefix='$', intents=discord.Intents.all())
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 98, in __init__
    super().__init__(**options)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1107, in __init__
    super().__init__(*args, **kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 248, in __init__
    self._connection = self._get_state(**options)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 265, in _get_state
    return ConnectionState(dispatch=self.dispatch, handlers=self._handlers,
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/state.py", line 152, in __init__
    raise TypeError('intents parameter must be Intent not %r' % type(intents))
TypeError: intents parameter must be Intent not <class 'disnake.flags.Intents'>
slate swan
#

TypeError: intents parameter must be Intent not <class 'disnake.flags.Intents'>

#

and why😭

slate swan
#

oof,

dire folio
#

oh

slate swan
#

Such jokes are not to be made

dire folio
#

i did not realise

slate swan
#

just search and replace

sage otter
slate swan
slate swan
#

but it wont do anything

slate swan
outer violet
#

If I’m making a help command by subclassing it, how would I sort it by cogs? Or is it harder to sort by cogs?

slate swan
slate swan
manic wing
slate swan
manic wing
#

;)

slate swan
#

he aint wrong tho ;))

outer violet
slate swan
#

Caeden is smart

manic wing
#

:)

slate swan
#

hes loves his help commands

#

like to much

slate swan
slate swan
#

im not sure

#

Its alright

#

he didnt invite me smh

#

😔

outer violet
slate swan
slate swan
slate swan
unkempt canyonBOT
slate swan
#

get to topic ;))

sage otter
outer violet
slate swan
#

coughs

slate swan
#

not like i subclass help commands,just make a new command named help🏃

manic wing
outer violet
manic wing
#

how can you chat bad to this shit

manic wing
#
@commands.command(
        aliases=['h', 'commands', 'cmd', 'command', '?', 'helpme', 'helpcommand', 'cmds']
        )
    async def help(self, ctx: Context, command=None) -> None:
        if not command:
            embed = await self.utils.main_help_embed(ctx)
            return await ctx.send(embed=embed, view=DropdownView(self.data, ctx, self.utils))
     
        cmd = self.bot.get_command(command)
        if cmd:
            embed = await self.utils.specific_command(cmd, ctx)
            return await ctx.send(embed=embed)

        cog = await self.utils.get_cog_from_str(command)
        if cog:
            embed = await self.utils.specific_cog(cog, ctx)
            return await ctx.send(embed=embed)

        embed = await self.utils.no_command(ctx)
        return await ctx.send(embed=embed)
#

MY ENTIRE HELP COMMMAND

manic wing
#

FUCKING AMAZING

slate swan
sage otter
#

Caeden speaks of clean code but then the first thing I see when I open his shit is a wildcard import

manic wing
slate swan
#

caeden did you really did a wildcard import smh

slate swan
slate swan
manic wing
#

there is nothing wrong with wildcard imports if you know what you're importing and you use it all and made the file

slate swan
#

!pep 8

unkempt canyonBOT
#
**PEP 8 - Style Guide for Python Code**
Status

Active

Created

05-Jul-2001

Type

Process

slate swan
#

smh

#

not that hard to follow

#

and dont check my repos🏃

sage otter
#

and you have a json file for prefixes oogh

slate swan
#

what is the easiest way to create a button?

#

subclass view

#

without classes?

#

haha no

#

like, a package or something

#

no such thing

manic wing
#

uh, yes, yes there is.

sage otter
#

there’s discord-components or whatever that garbage is called

slate swan
#

if i am able to, i would like to avoid working with Classes i just hate it

slate swan
manic wing
#
view = disnake.ui.View()
view.add_item(
  disnake.ui.Button(
    ...
  )
)```
#

without subclassing

slate swan
#

what's the package?

slate swan
manic wing
#

nah i dont do shit like tha

slate swan
manic wing
slate swan
#

ohpithink

slate swan
#

i just subclass view like a normal person

sage otter
#

!pypi discord-components

unkempt canyonBOT
pliant gulch
#

Yikes

sage otter
pliant gulch
#

Is this the package that requires a wait_for

slate swan
sage otter
#

AMshrug I’m not here to judge, I’m here to give them what they want.

sage otter
#

They completely removed views.

pliant gulch
#

Ok it is that's a yikes

slate swan
#

Yikes

#

that sounds horrible

pliant gulch
#

That means you are required to make listeners for every button you have and you cannot concurrently in the same function wait for two different button presses

slate swan
#
TypeError: on_connect() missing 1 required positional argument: 'message'

pliant gulch
#

Not to mention if you wanted the button to be able to be pressed any number of times you would need to spawn that many Futures

slate swan
#
@client.event
async def on_connect(message):
    ctypes.windll.kernel32.SetConsoleTitleW("Anti AFK • Ready as {}".format(client.user))
    print('Logged in as: {}'.format(client.user))
TypeError: on_connect() missing 1 required positional argument: 'message'
#

My eyes

#

.format

#

why

slate swan
slate swan
#

Outcomes of a youtube tutorial

#

!f-strings

unkempt canyonBOT
#

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

slate swan
slate swan
#

lmao

#
@client.event
async def on_connect(message):
    ctypes.windll.kernel32.SetConsoleTitleW(f"Anti AFK • Ready as {client.user}")
    print(f'Logged in as {client.user}')
TypeError: on_connect() missing 1 required positional argument: 'message'

better?

#

!d discord.on_connect

unkempt canyonBOT
#

discord.on_connect()```
Called when the client has successfully connected to Discord. This is not the same as the client being fully prepared, see [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready") for that.

The warnings on [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready") also apply.
slate swan
#

Am drunk