#discord-bots

1 messages Β· Page 167 of 1

random obsidian
#

aha

shrewd apex
#
await inter.response.defer()
await inter.edit_original_response("string")
#

lol i think u need to start with basic python b4 discord bots

shrewd apex
#

yt moment

shrewd apex
unkempt canyonBOT
#

class discord.Interaction```
Represents a Discord interaction.

An interaction happens when a user does an action that needs to be notified. Current examples are slash commands and components.

New in version 2.0.
rare echo
random obsidian
#

wait

shrewd apex
rare echo
shrewd apex
#

async programming go brrr

#

lol and whats the error

random obsidian
#

its just let me enter 10 line of message

shrewd apex
random obsidian
naive briar
#

Just putting async in front of function definition doesn't make the whole function asynchronous

shrewd apex
#

bro discord.py is async and just adding async to def dosent make stuff async io operations are blocking by io it includes read writing to files

slate swan
#

How do I get a bot to connect to the voice channel to which a specified user is connected?

random obsidian
#

yeah
exactly!
do u have problem with that?

naive briar
#

requests is blocking 🍷

shrewd apex
#

use aiofiles

naive briar
#

!blocking

unkempt canyonBOT
#

Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.

What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:

import discord

# Bunch of bot code

async def ping(ctx):
    await ctx.send("Pong!")

What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.

async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!

rare echo
random obsidian
#

whatever

shrewd apex
#

channel_id whats that it dosent exist in the local function evironment

naive briar
#

Use aiohttp, it was installed along with discord.py

shrewd apex
#

think of functions like a vending machine it only knows and has what u enter in it and gives u some output

#

so u either pass channel_id in params or u declare it in the function

#

@naive briar all urs πŸ’

#

imma dip

naive briar
#

It blocks your whole program when it's fetching the webpage or API until it's finished

jovial lynx
#

How can a discord bot make my server more interesting and make people talk?

#

it doesn't even get a new message every 10 hours

#

how?

random obsidian
#

thank you for your help @shrewd apex @oblique sorrel @rare echo

#

i had to convert it to f-string , maybe its help me

#

or
use embed for that

rare echo
# jovial lynx how?

a discord bot won’t be groundbreaking for a server, if your server isn’t building a community then it’s just like every other server

random obsidian
rare echo
#

i’ll be back in ab 45 and can help APthumbsupcow

shrewd fjord
#

wdym

#

await site.json()

#

yes you can

#

wait no

#

xd
because you need to await it too lol

#

u can do

#

idk i forgor lol

#

you can double await it.......

#

data = await (await session.get()).json()

#

hm?

#

.....

normal harbor
#

can somebody join a VC with me so you can help me

shrewd fjord
#

πŸ’€

#

idk

#

how aiohttp takes loop args?

#

!d aiohttp

unkempt canyonBOT
#

Common data structures used by aiohttp internally...

shrewd fjord
#

!d aiohttp.ClientSession

unkempt canyonBOT
#
class aiohttp.ClientSession(base_url=None, *, connector=None, cookies=None, headers=None, skip_auto_headers=None, auth=None, json_serialize=json.dumps, ...)```
The class for creating client sessions and making requests.
shrewd fjord
#

then just remove it

#

xd

normal harbor
#

can somebody help me we're discord bot

shrewd fjord
#

or await client.fetch_channel(channel_id)

#

remove this πŸ’€

shrewd fjord
normal harbor
shrewd fjord
#

import discord

#

the first line

normal harbor
shrewd fjord
normal harbor
shrewd fjord
#

.........

#

what did u do? xd

normal harbor
shrewd fjord
#

show me

normal harbor
shrewd fjord
#

hmm you need to create env file

#

i think so

normal harbor
#

ok

shrewd fjord
#

@naive briar handle πŸ”«

slate swan
#

I tried to send a notification when a user connects to the voice channel with this code, but I get this error message. What should I do?
```RuntimeError: asyncio.run() cannot be called from a running event loop``````py
@bot.event
async def on_voice_state_update(member, before, after):
if before.channel is None:
toast('test')

shrewd apex
#

define channel_id = in the function

shrewd apex
shrewd apex
#

toast seems to be something i had seen in kivy why are u using it here?

#

if its related

slate swan
# shrewd apex the whole traceback please
Traceback (most recent call last):
  File "C:\Users\zarus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\client.py", line 409, in _run_event
    await coro(*args, **kwargs)
  File "d:\Other\ffgai-main\ffgai-main\discordbot.pyw", line 25, in on_voice_state_update
    connect()
  File "d:\Other\ffgai-main\ffgai-main\discordbot.pyw", line 19, in connect
    toast('Hello Python\U0001f40d')
  File "C:\Users\zarus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\win11toast.py", line 375, in toast
    asyncio.run(toast_async(*args, **kwargs))
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\asyncio\runners.py", line 33, in run
    raise RuntimeError(
RuntimeError: asyncio.run() cannot be called from a running event loop```
shrewd apex
#

whats this toast function?

slate swan
rare echo
#

with dpy? odd

shrewd apex
#

which toast uses in backend

#

and await it

slate swan
#

I was able to execute it!!!! Thank you so much!

shrewd fjord
shrewd apex
shrewd fjord
shrewd apex
shrewd fjord
oblique fern
#

Anyone have an idea?

#

nevermind

maiden fable
#

Oh what was the issue?

oblique fern
#

one of my send_messages was a send

maiden fable
#

Ah that explains

#

Also, it shouldn't have been Messageable.send()

#

Since Messageable means its a simple command (because Messageable represents a TextChannel)

oblique fern
#

yea the preceding object was wrong as well

maiden fable
#

And please say u pip installed discord.py and not discord

#

and what did u pip install?

#

pip install discord.py?

#

or pip install discord

#

Uh, run pip show discord.py

#

and pip show discord

#

yea lol

#

and can u try pip uninstall discord?

#

Okay so the package is correct

#

I wish you had access to that lol

#

when r u running the function?

#

on_ready or what

#

Okay here comes sarth

#

He gonna solve yr queries

slate swan
#

missing sentinel error in requests usually get raised when rest is not ready

maiden fable
#

Nice name u got there sarth

#

request as in, u r sending an API request when the bot is not ready

#

API Request as in the fetch method

#

not the requests module

shrewd fjord
#

he is talking about web parsing or getting information from a web api.....

#

that's why catgal suggested aiohttp since this lib is not a blocking func

shrewd apex
#

whats happening here

shrewd fjord
#

what's blockink func? simply if u use requests module seems ok if the website's API is too good like doesnt even get host error then ok..... but some of them web need to get temporary down thus the API in this mean time if u use requests it will try to get info from web but it will fail as because the web is down, so using aiohttp which is asynchronous not gonna break ur other codes πŸ’€

#

ig i tried πŸ˜‚

#

"url"?

#

oh the actual web url?

shrewd apex
#

first time i see site without http

shrewd fjord
#

then ggood

shrewd fjord
#

but u sure mate u defined the url?

#

ok gooooood...

#

πŸ’€ nice

shrewd apex
#

ppl dont even know legb scope rule

shrewd fjord
#

what about channel_id?

maiden fable
shrewd fjord
shrewd apex
#

i am trying to explain from past few hours

maiden fable
#

Lmaoo

shrewd apex
#

pretty sure i have two-three replies

maiden fable
#

?

shrewd fjord
#

still uses https πŸ’€

maiden fable
#

Bro

shrewd apex
shrewd fjord
shrewd fjord
maiden fable
shrewd apex
#

man be using 0 indent like flexing pentagon co ordinates

#

bro read up legb scope rule

shrewd apex
#

bro u said 0 indent

shrewd fjord
#

here is scope

maiden fable
#

Lmao

shrewd fjord
#

phew phew

shrewd apex
#
x = 7  # 0 indent

def foo():
   ...  # 4 indent
shrewd fjord
#

maybe he meant like
x=y
y=z

shrewd apex
#

i have no idea

shrewd fjord
#

0 indent πŸ’€

#

ahh then?

#

ikr

#

i hope u have like this
url = ""
channel_id = 1234

shrewd apex
#

ok so whats ur problem send the traceback

shrewd fjord
shrewd apex
maiden fable
#

Good job

shrewd fjord
#

you should use f-string dawg this thing looks weird

#

i cant able to see anything cuz of yellow lines lmao

shrewd apex
#

this reeks of chatgpt and github copilot

#

okie

shrewd fjord
#

cookie

shrewd apex
#

altho those comments unecessary

slate swan
#

I'll try making copilot write docs for me

#

docs are boring

maiden fable
#

Go Study

shrewd apex
shrewd fjord
slate swan
#

what happened

shrewd apex
#

when writing wyvern

slate swan
shrewd apex
#

erroneus stuff half the time

maiden fable
shrewd apex
#

and it thought it was right

shrewd fjord
slate swan
shrewd apex
#

its blocking anywhere u use it

maiden fable
shrewd apex
#

in async context

maiden fable
#

PLEASE

shrewd apex
shrewd fjord
#

f i have also board after 1.5 months πŸ’€

#

me chillinnnnnnnn

slate swan
maiden fable
#

STOP IT DAMN IT

slate swan
shrewd fjord
#

YOOOOOOOOOO 90+ big brain

shrewd apex
#

bro so eveytime u instantiaate the class it bloacks

shrewd fjord
#

bloacks

#

quack

shrewd apex
shrewd fjord
#

zamn

slate swan
#

thats the intention

shrewd apex
maiden fable
#

Seriously bros lets get serious

shrewd apex
shrewd fjord
#

i am on good mood ngl

shrewd apex
maiden fable
#

Not u

shrewd fjord
#

need ducky here
πŸ¦†

maiden fable
#

Okay I am out before I lose my cool

slate swan
shrewd apex
slate swan
#

asher! lore

shrewd fjord
shrewd apex
slate swan
#

yeah ik knew, predictable

slate swan
shrewd apex
shrewd fjord
#

ok btw we are going to off topics

slate swan
#

dw this is ot3

#

until some mod enters

shrewd fjord
#

my bro just made this channel off topic respectttttttttt

shrewd apex
#

its not gonna tell u and happen u wont even notice but it happens

shrewd apex
shrewd fjord
#

sentinel

#

heard somewhere

slate swan
shrewd fjord
#

ayo this role name is cool

shrewd apex
#

reminds me of someone sarth uwu

shrewd fjord
#

me feeling good after the bone died from my throat πŸ’€

slate swan
shrewd fjord
shrewd fjord
shrewd apex
shrewd fjord
#

sadge

maiden fable
shrewd apex
#

they were partners in crime and in an uwutastic relation

slate swan
#

cause those things get triggered after the bot is running

shrewd fjord
#

WTF uwutastic? πŸ˜‚

shrewd apex
slate swan
#

*samarth

shrewd fjord
#

laughing irl 🀣

maiden fable
#

Wait she and sarth..........?

shrewd fjord
shrewd apex
vocal snow
shrewd fjord
shrewd apex
#

his name was samarth

maiden fable
#

Lets move this to ot everyone lmao

slate swan
shrewd fjord
upbeat otter
slate swan
shrewd apex
#

wtf

upbeat otter
#

lmaooo

maiden fable
#

Lmao sarth needs some some rest now

shrewd fjord
#

LOL

slate swan
#

stop hacking into others github accounts

shrewd apex
#

plotwist

upbeat otter
shrewd fjord
#

demn twist

maiden fable
shrewd apex
upbeat otter
shrewd fjord
#

πŸ“Ή

shrewd apex
#

wait bro i had nightmares over this

shrewd fjord
#

me shaking for some reason πŸ—Ώ

slate swan
#

@odd mango bro

maiden fable
#

Now who tf is savvy

shrewd apex
oblique fern
#

Anyone willing to help test a discord based game I've made using discord.py? It requires at least 3 players (but can be tested with 2) so if anyone can help me feel free to message or ping!

shrewd apex
maiden fable
#

what is the issue?

slate swan
#

just don't call that coro before the bot is running

shrewd fjord
#

i dont wanna miss these ot scenes πŸ’€

oblique fern
oblique fern
#

I don't know if it's ok to ask there haha

vocal snow
#

WHAT

#

😭 cogs

vague zephyr
#

wtf it's cogs not cocks lol

slate swan
#

Is there a way to get the voice channel a user is in based on their id?

vocal snow
#

!d discord.Member.voice

unkempt canyonBOT
slate swan
# vocal snow and a guild id, sure

How do I use my guild id? This is the current code

@bot.event
async def on_ready():
    member = bot.get_user(000000000000)
    await member.voice.channel.connect()```
vocal snow
#

first use bot.get_guild to get a discord.Guild object

#

then use guild.get_member to get a Member object

#

and then connect

slate swan
#

I was able to execute it!!!! Thank you so much!

buoyant quail
#

why do you want that? and how will it guess, which command is excpected to run?

#

if they have same names - you can make them both in one command

quick gust
#

ctrl + f2 in ur files

#

and search for the name

#

on Mac?

#

Idk of there's a ctrl on Mac

#

Or is ur ctrl key just missing

rare echo
#

strg

quick gust
#

strg

#

goofy ahh keyboard

#

search for it manually

#

or there might be another way depending on your editor, google it

junior terrace
#

hey i need help setting up a command, i need to kick every user in my server wich has written less than like 10 messages, is it possible?
i can't find anything online about that
i guess no one has ever needed to do that
do you guys think it is possible?

verbal hawk
#

Hi, I'm trying to send the date which is the given days + the time now, and another argument which is a specific member. Without the member argument it works fine, but with the member argument I get this error:
TypeError: unsupported operand type(s) for +: 'datetime.date' and 'Member'

The code:

async def fj(ctx, days, member: discord.Member):
    end_date = date.today() + timedelta(int(days))
    await ctx.send(end_date + member)```

I write `.fj 5 @user` 

It may has something to do with separating the arguments in the `.fj 5 @user`  command in a specific way but idk
fathom fjord
junior terrace
fathom fjord
#

well a kick command over a list ig?

junior terrace
#

and i can't get the list of users, just a dashboard online

#

pretty sad

torn sail
#

unless there are very little messages

torn sail
verbal hawk
#

I did not mean to add them lmao

vale wing
meager fulcrum
#

!e

import numpy as np


upper_brown4 = np.array([10,0,10])
print(upper_brown4.size)
print(upper_brown4[0])
print(upper_brown4[1])
print(upper_brown4[2])
print(upper_brown4[0:2])
unkempt canyonBOT
#

@meager fulcrum :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | 3
002 | 10
003 | 0
004 | 10
005 | [10  0]
slate swan
#

Hello, anyone know how i can do this in my code?

hallow sparrow
#

What library are you using?

hallow sparrow
#

Lemme look something real quick.

#

Hopefully someone else can help.

slate swan
#

Can i have some help, im tryna make a bot that plays music from youtube through a voice channel but i keep getting so many random errors to the point i just deleted it, can someone help me recode it?

#

And running the bot through UptimeRobot as a free way to keep it running

hallow sparrow
#

That’s against YouTube’s terms of service.

slate swan
#

il do it with spotify, soundcloud or something else then

sick birch
slate swan
#

i do.

sick birch
#

SoundCloud is doubtful but possible

slate swan
#

ok

#

how do i do it with spotify

sick birch
#

In general music sites don't want you streaming off platform which is why it's difficult

slate swan
#

i think i have an app in spotify dev

sick birch
slate swan
slate swan
oblique fern
slate swan
#

they are either still using prefix commands along with slash commands, or the content creator is dumb

#

They might be using a !sync command to sync their app commands, so a text command prefix would be needed in that case.

#

a !sync command isnt really a requirement, a slash command locked to a guild with owner check ( if the sync is more than just tree.sync()) or just an on_message will suffice

hushed galleon
#

tbf commands.Bot makes command_prefix a required argument, so you gotta write something for it

sick birch
#

That implies you should be using bot for app commands

#

Yet required command prefix

mental hollow
#

so I’m using on_user_update and I want to post to a guild that a member has updated their name/discrim/avatar

#

I’m using mongo db to store guild IDs and log channel IDs

#

before & after in on_user_update are instances of discord.User

#

not discord.Member, so there is no guild

#

so how would I go about doing this?

sick birch
mental hollow
#

and those are the 3 updates I’m looking for

sick birch
#

Have you tested locally to see if it really does/doesn't do what you want?

mental hollow
sick birch
#

I would say test on_member_update locally as it might be what you're looking for

mental hollow
#

So I looked at docs

sick birch
#

Ah yikes, looks like you'll have to do it manually then

sick birch
#

Yup

#

The issue is when a user is in multiple shared guilds

#

I suppose then you'd just send it to all of them

#

Should actually be pretty simple now that I think about it

guilds = filter(lambda guild: user in guild, bot.guilds)
mental hollow
#

I’ve never used filter/lambda in my life

#

πŸ₯²

slate swan
#

!d discord.Member.mutual_guilds

unkempt canyonBOT
#

property mutual_guilds```
Equivalent to [`User.mutual_guilds`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.mutual_guilds "discord.User.mutual_guilds")
mental hollow
#

sorry for the slow typing I’m on my phone

#

smth like that should work right?

slate swan
#

if before is your Member/User object. yes

mental hollow
#

alrighty ty

sick birch
#

TIL that existed

mental hollow
slate swan
#

you should be using the async mongodb driver for a discord bot (, its called motor ), you'll just have to add a bunch of awaits

#

!pip motor

unkempt canyonBOT
mental hollow
#

wait

#

I forgot

#

idk why I said I’m using pymongo

#

I am using motor aha

pliant gulch
#

Shouldn't your query be called via await/async syntax then?

#

If you are using Motor, find_one is a coroutine function. So if you don't await it you're not gonna get the expected behaviour

mental hollow
#

seems to work fine for everything else without await

#

Pretty sure it causes an error when I make it async

#

hold on let me jsk it and see

pliant gulch
#

Pretty sure that means find_one is not a coroutine function then

#

Perhaps you are using Motor but not in db.LOGGING

#

And or you made that interface without having the overhead method as a coroutine function

#

!e ```py
async def example() -> None:
print("Hello World")

example() # note: not awaiting the coroutine.

unkempt canyonBOT
#

@pliant gulch :white_check_mark: Your 3.11 eval job has completed with return code 0.

001 | <string>:4: RuntimeWarning: coroutine 'example' was never awaited
002 | RuntimeWarning: Enable tracemalloc to get the object allocation traceback
mental hollow
#

yeah I used jsk and await works fine too

#

this whole time I haven’t been using await tho and it seems to work fine

#

I’ll add await to make my code more asynchronousy.. thank you

pliant gulch
#

Can you show the db.LOGGING.find_one method?

#

If there is no problem great, but I'm kind of curious what your function looks like in order to make it work in that way

slate swan
#

πŸ’€ or maybe its "just working" but not working as it should

mental hollow
# pliant gulch Can you show the `db.LOGGING.find_one` method?

I’m importing database as db, and in my database.py file, I have:

import os 
from dotenv import load_dotenv
from motor.motor_asyncio import AsyncIOMotorClient

load_dotenv()

MONGO_CLIENT = AsyncIOMotorClient(os.getenv('MONGOURL'))

DATABASE = MONGO_CLIENT["Aziel"]

LOGGING = DATABASE["Logging"]
#

then I’m just using find_one on that

slate swan
#

the docs say that its a coro

mental hollow
#

pymongo?

slate swan
#

nah, motor

#

the return type is from pymongo because motor just wraps pymongo in a run_in_executor

mental hollow
#

weird…

#

I’ve got no clue how it works tbh

slate swan
#

!e ```py
async def a_condition_that_actually_returns_false():
return False

if a_condition_that_actually_returns_false():
print(1) # no error, but works!

unkempt canyonBOT
#

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

001 | <string>:4: RuntimeWarning: coroutine 'a_condition_that_actually_returns_false' was never awaited
002 | RuntimeWarning: Enable tracemalloc to get the object allocation traceback
003 | 1
pliant gulch
#

Reading the source code for Motor and I've got to say, what the hell lmao

slate swan
#

there can be such flukes πŸ€·β€β™‚οΈ

pliant gulch
#

Granted this is my first source dive of Motor but

mental hollow
#

I’m actually interested on how this is working now

slate swan
mental hollow
#

hold on

pliant gulch
#

From what I see Motor wraps using a bunch of base classes like Async that then wraps the synchronous function in a Future

#

Then it get's ran in another thread

mental hollow
#

that’s the difference between using await and not using await

sick birch
#

Or just unorthodox

pliant gulch
#

It's hard to read at least for me

mental hollow
#

whoops

pliant gulch
#

Because there is so much nesting going on

mental hollow
#

didn’t crop one of them

pliant gulch
#

It's not typed either

slate swan
mental hollow
#

that was the difference between using await/not using await

mental hollow
slate swan
#

you always need to await it

#

its a Future

pliant gulch
#

Does the pending future complete the query to your mongo DB?

slate swan
mental hollow
pliant gulch
#

It's a safe bet to await your Future's/coroutines, cause yea they can still execute in a way but you WON'T know when, causes issues like race conditions

#

That's why await is so good

mental hollow
#
for guild in before.mutual_guilds:
    data = await db.LOGGING.find_one({"_id": guild.id})

    if data is None:
        return

    async with aiohttp.ClientSession() as session:
        logWeb = discord.Webhook.from_url(data["loggingWebhook"], session = session)
        if before.name != after.name:
            embed = discord.Embed()
            embed.title = "This is an example of my code."
            await logWeb.send(embed = embed)

this code doesn’t wanna post my webhook

#

and it doesn’t give me an error either

pliant gulch
#

If this helps here's a good visual

mental hollow
#

sorry await is in my actual code

#

I just didn’t write it there cause I wrote that on my phone

pliant gulch
#

If it neither errors nor sends an embed, then you might wanna check if before.name != after.name:

mental hollow
#
    @commands.Cog.listener()
    async def on_user_update(self, before, after):
        for guild in before.mutual_guilds:
            data = await db.LOGGING.find_one({"_id": guild.id})
        if data is None:
            return
        if before.bot:
            return
        async with aiohttp.ClientSession() as session:  
            logWeb = Webhook.from_url(data["loggingWebhook"], session = session)
            if before.name != after.name:
                e = discord.Embed(colour = 0x2f3136)
                e.set_author(name = f"{before.name} changed their name!", icon_url = before.display_avatar.url)
                e.description = f"**Before:** {before.name}\n**+After:** {after.name}"
                e.set_footer(text = "This event occured:")
                e.timestamp = discord.utils.utcnow()
                e.set_thumbnail(url = before.display_avatar.url)
                await logWeb.send(embed = e)
#

my raw code

#

and I just changed my name

#

from Chaze to some random letters

#

Then from the random letters back to Chaze

#

so there is no reason it shouldn’t be called

naive briar
#

!d discord.on_member_update

unkempt canyonBOT
#

discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") updates their profile.

This is called when one or more of the following things change...
mental hollow
#

me and robin had this convo earlier lol

pliant gulch
#

Is data none?

#

Also your code errors when mutual_guilds is []

#

Because data isn't defined in the second if statement

#

If the for-loop never enters that is

mental hollow
#

data has a value

#

and it should be returned if it’s none

pliant gulch
#

Have you made sure your event callback is fired?

#

Like can you add a print/and or did you have one

mental hollow
#

I’ll try add one

#

"This resource is being ratelimited."

#

let me try my discrim

#

yup, it’s being fired

#
if before.discriminator != after.discriminator:
                e = discord.Embed(colour = 0x2f3136)
                e.set_author(name = f"{before.name} changed their discriminator!", icon_url = before.display_avatar.url)
                e.description = f"**Before:** {before.discriminator}\n**+After:** {after.discriminator}"
                e.set_footer(text = "This event occured:")
                e.timestamp = discord.utils.utcnow()
                e.set_thumbnail(url = before.display_avatar.url)
                await logWeb.send(embed = e)
#

that’s the code for sending my embed when a discrim is updated, that isn’t sent either

mental hollow
mental hollow
#

I’m using pycord

mental hollow
#

for pycord, it is

pliant gulch
#

Okay, pycord's send for Webhook is not a coroutine function

#

Fault on my part

#

I would remove the await and try again, if that doesn't work then make sure the webhook url is indeed the correct one

mental hollow
mental hollow
pliant gulch
#

Here in the source code it's non-coroutine

mental hollow
#

I think the source code isn’t updated

#

cause im using send as a coroutine in on_message_delete

#

works perfectly fine

pliant gulch
#

The link I just sent is from the master branch

#

And I checked the GitHub link of the documentation you sent me, it's invalid

#

Oh nevermind it works now?

#

Holdon a sec

#

Okay pycord is just confusing the hell out of me

#

There are two Webhook classes both with the same exact name

#

One is sync and the other is async

#

So I'm really lost at this point

mental hollow
#

Should probably report it to them at .gg/pycord

pliant gulch
#

I think it's been fixed on the master branch

#

But whichever commit hash I was just looking at had two

mental hollow
#

so conclusion is it’s a coroutine right?

pliant gulch
#

Should be

#

But I really don't know what the issue is in your code

#

At this point we've gone over any logic issues and it not being called

#

But those aren't the issue so I'm lost

mental hollow
#

aw

#

I’ll try ask in the pycord support server, ty for ur help!

slate swan
#

they just dont have it documented. they are really bad at documenting shit

marsh stirrup
#

Hello

#

I need help with doing somethin

#

It has to do with discord bots?

feral timber
#

What seems to be the problem?

mental hollow
#
for guild in before.mutual_guilds:
            data = await db.LOGGING.find_one({"_id": guild.id})
#

so that is returning None

vocal burrow
#

Selfbot

#

raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.

#

how to fix this

feral timber
#

Selfbot
Selfbots break ToS and are against our server rules

vocal burrow
#

k

alpine cove
#

lmao

pliant gulch
#

Was suspicious of data

mental hollow
mental hollow
#

so I’m ummm a bit stuck

#

I don’t really wanna use mutual_guilds anymore since that is only cached guilds

#

so not sure what to do

slate swan
#

So, I am using aiohttp to save the contents of a URL to a bytesIO object so I can send it as a file with discord.py and for some reason it just keeps erroring out, either valueerror null or request entity too large

pliant gulch
#

The cache is populated on gateway connection, it's updated when given certain events, etc

#

It will almost always be up to date, that is granted you don't block your own bot

mental hollow
#

so all mutual guilds should infact be cached?

pliant gulch
#

Yes

#

Like using time.sleep to desync any inbound events

mental hollow
#

ah I see

pliant gulch
#

That might cause your bot to have a "dead" cache

mental hollow
#

kk, noted that

#

right so now I will be using mutual_guilds

#

pycord server have told me this: "Don't reassign the value? Store the IDs in a collection and iterate over them when sending your webhook"

#

so that’s what I’m working with atm

pliant gulch
#

Yea you are re-assigning the variable you set

#

So your data would only be for the last mutual guild in the list

mental hollow
#

this is really confusing

#

maybe cause it’s 5AM

#

but idk what else to do/try

vocal snow
# mental hollow this is really confusing

well, that is because andy is very smart in the aspect of developing. so when andy explains something to someone who doesnt have the same knowledge, it may be looked at as confusing because andy is explaining something with the assumption it can be understood as simply as he/she understands the topic. so yeah it creates confusion. thats why you ask more and more. the more you ask the more you know. dont walk away misunderstanding the topic because one explanation didnt give you the knowledge needed. im sure andy would have been willing to break down the explanation.

pliant gulch
#

!e ```py
for i in range(10):
foo = i

print(foo)

unkempt canyonBOT
#

@pliant gulch :white_check_mark: Your 3.11 eval job has completed with return code 0.

9
pliant gulch
#

this is basically what your doing

#

Your should be doing logic inside of the body

mental hollow
#

so everything in for loop

#
    @commands.Cog.listener()
    async def on_user_update(self, before, after):
        for guild in before.mutual_guilds:
            data = await db.LOGGING.find_one({"_id": guild.id})
            if data is None:
                return
            if before.bot:
                return
            async with aiohttp.ClientSession() as session:  
                logWeb = Webhook.from_url(data["loggingWebhook"], session = session)
                if before.name != after.name:
                    e = discord.Embed(colour = 0x2f3136)
                    e.set_author(name = f"{before.name} changed their name!", icon_url = before.display_avatar.url)
                    e.description = f"**Before:** {before.name}\n**+After:** {after.name}"
                    e.set_footer(text = "This event occured:")
                    e.timestamp = discord.utils.utcnow()
                    e.set_thumbnail(url = before.display_avatar.url)
                    await logWeb.send(embed = e)
#

like so?

pliant gulch
#

Actually, I'm unsure what the mutual_guilds is for exactly

#

But this'll use data in respects to mutual_guilds

#

But your webhook is the same so it'll send in the same spot everything

mossy jacinth
#

How can I stop my bot from replacing all the text inside the txt file with the newest confession?

mental hollow
slate swan
#

I would also use aiofiles

mental hollow
shrewd apex
slate swan
#

hipithink

vocal snow
#

😠

shrewd apex
slate swan
#

Dont really want to talk about itπŸ˜…

shrewd apex
#

hunny bunny was so worried about u πŸ˜”

vocal snow
#

where is noid

slate swan
slate swan
shrewd apex
shrewd apex
pliant gulch
#

It should iterate through mutual_guilds then get the webhook for each

#

So yea it should do what you want

slate swan
slate swan
shrewd apex
slate swan
#

we should go to dms or otpithink

quick gust
#

No

slate swan
#

limit is increased based on server level.

#

Yeah I know

maiden fable
#

Who TF is this Okimii now..? @upbeat otter smh

slate swan
#

back to back scam

maiden fable
#

istg

slate swan
#

Whole lot of lies ik

shrewd apex
#

discord is a lie people on discord are liars

maiden fable
#

You being the biggest Yea you are right

shrewd apex
slate swan
#

I mean, everyone has lied in their lifepithink

#

yea but that identity thing is quite unique

#

huh

shrewd apex
#

identity fraud ducky_sphere

mossy jacinth
#

The third text in the .txt file was answered with No in the name value. Why is it still writing it in the file? I tried to use == "Yes" or "yes": before but it also didnt work...

slate swan
#

I literally just took a break due to some issues, how did i commit identity fraudπŸ’€

upbeat otter
#

I literally just wole up

#

woke

#

it's the same old okimmi

slate swan
#

Why cant you spell my name yet

upbeat otter
#

it's the same thing, I just happen to do that unwillingly

slate swan
#

mkpithink

maiden fable
maiden fable
unkempt canyonBOT
#

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.")
slate swan
mossy jacinth
#

Can I ask what happened?

maiden fable
#

You don't wanna ask

maiden fable
#

(if u r talking about the identity crisis)

slate swan
#

Why dont we stay on topicπŸ˜…

maiden fable
#

That too

slate swan
#

hunter i would think you still have the habbit of using !otpithink

maiden fable
#

!ot

unkempt canyonBOT
slate swan
#

yup

slate swan
#

OH

#

@slate swan HI

#

πŸ‘‹

#

How are u its been a minute

#

I never thought this day would come

maiden fable
#

Now who r u 😐
@upbeat otter smh

slate swan
slate swan
slate swan
#

May i ask, how is your OOP journey?

shrewd apex
slate swan
slate swan
shrewd apex
#

catfished sarth

slate swan
#

That's messed up

shrewd apex
#

ikr

slate swan
slate swan
#

I got busy and just stopped learning

#

mhm ic, where did you stopped? Iirc i was teaching you classmethods and staticmethods?

#

I actually need help on something rn that you might know how to do

tough lance
#

Hllo

slate swan
#

add me back

#

😒

slate swan
slate swan
#

it's great

#

sure 😭

quick gust
slate swan
#

Ikr, how are you infernum? I see you havent changrd with your cat pfpspithink

quick gust
#

Lmao I really haven't, and I'm alright how are you

slate swan
quick gust
slate swan
#

You too, i hope everyone has a good next year!

maiden fable
#

Seriously tho take all this to an OT

slate swan
#

we really should pithink 😭

upbeat otter
slate swan
#

you are

#

😳

maiden fable
#

Long story but Ashley was Eevee's alt who is Ash now and all of them are one person who's a guy

slate swan
#

eevee is ash?!?

maiden fable
#

Bro

slate swan
#

is ash an indian dude😏

maiden fable
#

Anyways
I have already melted my brain yesterday night by understanding this and I'm lucky mods didn't want/mute us for talking so OT so yea I'm out rn

maiden fable
slate swan
#

yes!

tough lance
#

Need help with something ot

#

Wanna migrate from sqlite to postgresql. The code itself isn't the problem, I just don't know how to transfer data.

upbeat otter
slate swan
#

is there an alternative method to sending an ephemeral message when using interaction?

slate swan
#
await interaction.response.send_message("message", ephemeral=True)

I already used this and need to send a second ephemeral message but I get

- This interaction has already been responded to before

So im looking for an alternative or how to use two in the same thing

maiden fable
#

interaction.followup

#

!d discord.Interaction.followup

unkempt canyonBOT
slate swan
#
- TypeError: 'Webhook' object is not callable
maiden fable
#

.send

light violet
#

mem= discord.User(id)

#

is this a correct method to fetch a discord user by id?

maiden fable
#

No

#

!d discord.Client.get_user

unkempt canyonBOT
#

get_user(id, /)```
Returns a user with the given ID.

Changed in version 2.0: `id` parameter is now positional-only.
light violet
#

ok

light violet
#

i mean not in any mutual servers

#

by id

shrewd fjord
slate swan
# maiden fable .send

what do you mean .send? interaction.channel.send doesnt have ephemeral and user.send goes to dm

light violet
shrewd fjord
shrewd fjord
light violet
shrewd fjord
slate swan
slate swan
upbeat otter
maiden fable
#

@light violet to get a user who isn't in yr bot's servers use fetch

light violet
#

ok thanks

odd mango
slate swan
light violet
#

ohk

normal harbor
#

can somebody help me code a discord bot if yes please join the VC0

slate swan
#

hello
discord.app_commands.errors.CommandInvokeError: Command 'create_ticket' raised an exception: TypeError: View.add_item() missing 1 required positional argument: 'item'

#

@shrewd fjord

shrewd fjord
#

!d discord.ui.View.add_item

unkempt canyonBOT
#

add_item(item)```
Adds an item to the view.

This function returns the class instance to allow for fluent-style chaining.
naive briar
#

Imagine

#

Why can't you just add an empty void into your view items

maiden fable
#

What would even be the use of that lmao

naive briar
#

Void

maiden fable
#

nice

slate swan
#

this is the full code !

paper sluice
#

myview = View() not View

slate swan
#

okay

slate swan
shrewd fjord
#

good

random obsidian
#

hello
how can i put an button on a message?

maiden fable
#

!d discord.ui.View

unkempt canyonBOT
#

class discord.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.
maiden fable
#

!d discord.ui.Button

unkempt canyonBOT
#

class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.

New in version 2.0.
golden depot
#

anyone help

#

please

#

how can i create slash commands

slate swan
#

is there a way to create event buttons ? or i need to put them inside commands ?

maiden fable
#

event buttons?

#

You mean send a button whenever suppose, a message is deleted?

slate swan
maiden fable
#

Ah

#

Well there is nothing like that
But you can implement something like that on your own!

slate swan
#

or something like that, cause when i restart my bot , my buttons don't work anymore, cause the command stopped

maiden fable
#

Do u know about botvars?

slate swan
maiden fable
#

!botvar

unkempt canyonBOT
#

Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:

bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"

@bot.command()
async def get(ctx: commands.Context):
    """A command to get the current value of `test`."""
    # Send what the test attribute is currently set to
    await ctx.send(ctx.bot.test)

@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
    """A command to set a new value of `test`."""
    # Here we change the attribute to what was specified in new_text
    bot.test = new_text

This all applies to cogs as well! You can set attributes to self as you wish.

Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!

slate swan
#

how can this help me ?

maiden fable
#

Wait I think there is a function like that

slate swan
#

OK

maiden fable
#

!d discord.on_interaction

unkempt canyonBOT
#

discord.on_interaction(interaction)```
Called when an interaction happened.

This currently happens due to slash command invocations or components being used.

Warning

This is a low level function that is not generally meant to be used. If you are working with components, consider using the callbacks associated with the [`View`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View "discord.ui.View") instead as it provides a nicer user experience.

New in version 2.0.
slate swan
#

cool

naive briar
#

!d discord.Client.add_view

unkempt canyonBOT
#

add_view(view, *, message_id=None)```
Registers a [`View`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View "discord.ui.View") for persistent listening.

This method should be used for when a view is comprised of components that last longer than the lifecycle of the program.

New in version 2.0.
slate swan
#

i also found this

maiden fable
#

What lib r u using?

slate swan
maiden fable
#

BTW Catgal how is he gonna get the view object?

maiden fable
slate swan
random obsidian
slate swan
#

Idk if it exists in discord py but in nextcord there's button callbacks

maiden fable
slate swan
maiden fable
#

Every fork took button callbacks from dpy only

slate swan
#

cool ! this worked after i restarted

maiden fable
#

Hey nice!

slate swan
naive briar
#

on interaction event probably

slate swan
#

callbacks stops working after restarting i think

naive briar
#

Not if you add the view to the bot using add_view

unkempt canyonBOT
#

examples/views/persistent.py lines 39 to 45

async def setup_hook(self) -> None:
    # Register the persistent view for listening here.
    # Note that this does not send the view to any message.
    # In order to do this you need to first send a message with the View, which is shown below.
    # If you have the message_id you can also pass it as a keyword argument, but for this example
    # we don't have one.
    self.add_view(PersistentView())```
maiden fable
#

But then I am confused how does this even listen to events on an already sent view?

#

I mean, I don't think the bot can "see" the view that was sent before it restarted (as long as on_interaction isn't used)

random obsidian
# maiden fable event buttons?

hello
i had read your message
i want from bot to make an button on itself message when sent , and then , that bot take an action on that

vale wing
wispy nexus
#

@gilded gust for some reason the ping works as a prefix but the "ya" doesnt

prefix = ["ya","@clear monolith"]

@client.event
async def on_ready():
    print("We have logged in as {0.user}".format(client))

@client.event
async def on_message(message):
    message.content = message.content.lower()
    cmd = message.content.split(' ')
    if message.author == client.user or message.author.bot or cmd[0] not in prefix:
        return
gilded gust
#

hhuh

#

!or

unkempt canyonBOT
#

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
#

!d discord.Intents.message_content

unkempt canyonBOT
#

Whether message content, attachments, embeds and components will be available in messages which do not meet the following criteria:

β€’ The message was sent by the client

β€’ The message was sent in direct messages

β€’ The message mentions the client

This applies to the following events...

naive briar
#

Also just use discord.ext.commands.Bot if you want to create text commands

wispy nexus
#

and it still doesn't work.

quick gust
#

u enabled them in your code?

#

!intents

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.

vale wing
wispy nexus
wispy nexus
#

i need to remodel all my code then

vale wing
#

You only need to do commands properly that's it

wispy nexus
#

after i learn how to use discord.ext.commands.Bot

#

(β•―Β°β–‘Β°)β•―οΈ΅ ┻━┻

vale wing
#

Why flip table

wispy nexus
wispy nexus
vale wing
#
  1. Inconsistent variable naming, instance of Bot should be called bot, not client
  2. Instead of parsing bot's mentions as prefix, use commands.when_mentioned_or
#

!d discord.ext.commands.when_mentioned_or

unkempt canyonBOT
#

discord.ext.commands.when_mentioned_or(*prefixes)```
A callable that implements when mentioned or other prefixes provided.

These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.

Example

```py
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'))
```...
wispy nexus
#

this really is going to take a long time

vale wing
#

Why do you think so

wispy nexus
#

i dont know how to use def

vale wing
#

Understandable

#

You need functional programming and OOP knowledge

#

So I suggest taking python courses

somber imp
#

Discord bot shouldn't really be one your first few projects

wispy nexus
#

3 months of my life just to make this bot do something simple

vale wing
#

^

wispy nexus
somber imp
#

Lmao

vale wing
#

You can learn that stuff in a short period of time then practice on bot

somber imp
#

That pro feeling will weeks to actually happen ngl

vale wing
wispy nexus
somber imp
#

Rather 1 month of python learning and practice will make you much better

vale wing
#

Learning basics of functional programming and OOP can be done within one day

#

Then pure practice and extending knowledge

somber imp
#

Async programming too

slate swan
#

you will go super-Sayan when you learn OOP and how to use classes trust me

vale wing
#

Async programming can be learned from a discord bot

wispy nexus
#

me who is coding bots that do things only cus i know how to use if statements

#

and lists

vale wing
#

That's already cool but yeah functional programming and OOP are required

wispy nexus
#

i aslo know how to use while loops

slate swan
#

That's a good start :-)

wispy nexus
#

books and yt videos are so hard to follow for me

shrewd fjord
vale wing
#

What about online courses

#

Personally I strongly recommend stepik

naive briar
#

Examples pithink

shrewd fjord
#

stepik

wispy nexus
#

me who is poor

vale wing
#

There are free courses bru

wispy nexus
#

really?

#

interesting

vale wing
#

Most of python courses are free

shrewd fjord
#

;-;

vale wing
#

And personally I learned python from a book at like 10 years, then re-learned it on sololearn and then years of practice and docs reading

slate swan
#

where can you host python scripts to run 24/7 for example i need my loop to run forever?

naive briar
#

VPS

slate swan
naive briar
shrewd fjord
#

10 years + extra 5 years

slate swan
# wispy nexus interesting

Also try finding simpler projects to work on that don't involve complicated external libraries. Find ways to incorporate concepts into these projects that you're not very familiar with, so as to get some good Python practise going.

vale wing
naive briar
#

lol

shrewd fjord
#

guess ig

#

i think re-learned would take this long time πŸ’€

slate swan
#

its a loop with discord requests

shrewd fjord
slate swan
#

No I suck. :-)

vale wing
shrewd fjord
#

ahh i fould a video over a year ago, telling a best github project to learn whole python πŸ’€

shrewd fjord
wispy nexus
#

@vale wing the pro
mind tutoring me?

slate swan
vale wing
wispy nexus
shrewd fjord
#

REAL GIGA AGAIN FOUND

vale wing
#

And I barely understood functions then got completely stuck on OOP

shrewd fjord
#

bro i didnt even know how to do 4/2 while i was 10

#

🐸

vale wing
#

Because I didn't know english well that age

shrewd fjord
#

OOp

#

cul

#

demn u guys are smort

wispy nexus
#

who me?

#

ty ty

shrewd fjord
#

;-;

wispy nexus
#

|| ||

shrewd fjord
wispy nexus
#

_ _

vale wing
#

Btw that book that was my entrypoint to python programming was like "omg python 3 is out but it's bad, use python 2 πŸ€—"

shrewd fjord
slate swan
#

Why don't we have reaction perms in this channel but other topic chats do

shrewd fjord
#

u can also see other topics doesnt have channel cooldown but this channel has

#

xd

slate swan
#

Guess we're just misbehaved here

shrewd fjord
#

sed

vale wing
#

Programming is best to be learned by oneself imo

shrewd fjord
#

"resources"

shrewd fjord
#

πŸ—Ώ

wispy nexus
shrewd fjord
#

u will get more interest when u will complete some small projects

#

like printing hello world :)

slate swan
#

hi

shrewd fjord
#

halo

slate swan
#

i need examples/explanation how to connect to discord websocket using aiohttp, i don't understand websockets a lot

wispy nexus
shrewd fjord
#

create some big game with only python and get motivated πŸ’€

somber imp
shrewd fjord
#

ash

upbeat otter
upbeat otter
shrewd fjord
upbeat otter
vale wing
shrewd fjord
#

;-;

upbeat otter
#

typing on phone is hard, not my fault

shrewd fjord
upbeat otter
#

I was on laptop lmao

shrewd fjord
upbeat otter
# wispy nexus indeed

if you're gonna keep up with that attitude for learning things, you'll never make it to the top

upbeat otter
wispy nexus
upbeat otter
#

books dont do that

upbeat otter
shrewd fjord
wispy nexus
#

darn it all i want in to add "ya" as a prefix

#

screw the prefix then
ill learn it when i make my other bot

#

for now, ill just use the ping

slate swan
#

because no

vale wing
#

Connecting to websocket is very easy

slate swan
#

examples

vale wing
hushed galleon
unkempt canyonBOT
#

discord/client.py lines 591 to 597

async def connect(self, *, reconnect: bool = True) -> None:
    """|coro|

    Creates a websocket connection and lets the websocket listen
    to messages from Discord. This is a loop that runs the entire
    event system and miscellaneous aspects of the library. Control
    is not resumed until the WebSocket connection is terminated.```
slate swan
#

k

oblique fern
#

hey guys

shrewd fjord
#

hey ;-;

slate swan
#

i actually chatgpt'd it

shrewd fjord
#

πŸ—Ώ

shrewd fjord
oblique fern
#

yes it does.

shrewd fjord
#

Cool

late needle
#

hi

oblique fern
#
        button_view = ui.View()
        for i in range(len(self.submissions)):
            # add dynamic number of buttons to view
            button_view.add_item((ui.Button(label=f"Button #{i+1}", style=ButtonStyle.primary, custom_id=f"{i+1}")))
        await interaction.channel.send(
            embed=await MessageUtils.embed_message("message description example"), view=button_view
        )

I have this code that adds a dynamic number of buttons to a message labeled "Button #X" where x is a number.
What can I do now to:

  1. for the next 60 seconds:
  2. allow all members to click the button once, but disable it only for that member after clicking
  3. see which button is clicked / how many times
late needle
#

i have doubt

#

hlo

#

i need a code which store data of each and every user