#discord-bots

1 messages Β· Page 61 of 1

maiden fable
#

I'm confused... A webhook is sending a file?

drifting arrow
maiden fable
#

Yea

drifting arrow
# maiden fable Yea

Alright. So a service I am using is sending something to my discord server using a webhook.
The data it is sending is in the form of a json file.
I was given a shared_secret so I assume thats to authenticate.
But I can't figure out how to authenticate 😦

#

or how to get the json file..

maiden fable
#

Why r u even authenticating manually tho

drifting arrow
#

we can do 1 thing at a time yo

#

like. how to first get the data i want.

#

You able to help me or not?

maiden fable
#

I mean, u r sending requests to the api to get the JSON right?

drifting arrow
maiden fable
#

Or, the line where u do webhook.send or smth, u can do msg = webhook.send and the msg will be the Message object the webhook sends

drifting arrow
#

The service is sending to the discord webhook..
So when I go to a discord channel, I go to integrations and create a new webhook, I take that URL and give it to the service. then they send the data to that url

#

I want to pull whatever data it is sending

maiden fable
#

Can I get the link to the API? Also, u should consider sending the requests manually then

drifting arrow
#

Why would you need their api link?

#

There's really nothing to do here

maiden fable
#

Okay... Just send the requests yourself and access response.json and do whatever you want with it

drifting arrow
#

You've not really been of much help. Since I dont understand anything about web hooks you've basically asked the same questions over and over again.

#

Which is annoyingly frustrating. All I want is to grab the webhook data that is being sent to my discord server and I cant seem to figure it out

maiden fable
#

Dude, I literally told you. Send the requests to the API yourself using aiohttp, then access response.json, and u have the JSON that way. Then, use your webhook object to send the JSON

#

As simple as it gets

drifting arrow
#

I'm not sending anything using the webhook. The service is sending to me using the webhook

#

I supply them a URL to my channel webhook (Using the integrations in discord).

#

And they send the data to me..

#

Or at least suppose to..

maiden fable
#

That's what I'm saying... DON'T do that and instead use aiohttp and send requests to that service yourself

drifting arrow
#

No. I can't due to rate limits, it's better if they're sending the data to me.

#

without me making a request to their api

maiden fable
#

Then you're probably out of luck

slate swan
#

Hi im new onlogo_vscode

maiden fable
#

Hi

slate swan
#

from discord.ext import command

maiden fable
#

commands*

slate swan
#

Oh

#

Yes

#

Why i cant run it on logo_vscode

drifting arrow
slate swan
drifting arrow
# slate swan What you use

I use vscode to code everything then coz vs doesnt pick up all my packages I run my bots through cmd line

crimson plover
#

So if anyone gives a shit I got everything to work properly.. y9 and The Master...

maiden fable
slate swan
keen talon
drifting arrow
#

Β―_(ツ)_/Β―

azure scroll
#

none

#

sry just saw ur msg

crimson plover
#

does anyone know how to give give a description to these..
heres an example

torn sail
#

!d discord.ext.commands.command

unkempt canyonBOT
#

@discord.ext.commands.command(name=..., cls=..., **attrs)```
A decorator that transforms a function into a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or if called with [`group()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.group "discord.ext.commands.group"), [`Group`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Group "discord.ext.commands.Group").

By default the `help` attribute is received automatically from the docstring of the function and is cleaned up with the use of `inspect.cleandoc`. If the docstring is `bytes`, then it is decoded into [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") using utf-8 encoding.

All checks added using the [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") & co. decorators are added into the function. There is no way to supply your own checks through this decorator.
torn sail
#

description=

crimson plover
#

TheMaster did you see my fixed code above as well i got it working fully

torn sail
#

Yeah I saw. Definitely the way u are currently using is not ideal but I guess the ideal way just is not working

drifting arrow
# torn sail `description=`

You used discord webhooks before?
I'll explain the situation and see if you can help me.
A service I am using, uses webhooks and sends to the discord webhooks (right click a channel -> settings -> integrations -> webhooks, take that URL)
It is suppose to send a json file.
I was given a secret key.
Can you help me access all this? I dont want to constantly query the websites api and webhooks are suppose to alleviate that.

crimson plover
#

i mean.. i get no errors now... it throws the type in a message idiot if i dont put one in... and sends the normal message fine.... so id say its working without errors...

#

i geuss maybe its not ideal but i figured id post my working code

torn sail
crimson plover
#

i mean.. if it works.. it works right?

drifting arrow
torn sail
crimson plover
#

i mean its working flawless now for what i intend for it to do so..

torn sail
drifting arrow
#

So i cant use discord at all? I have to use their api anyway?

torn sail
drifting arrow
#

So the TL;DR - Just use the API like normal

#

I dont have a webserver 😦

torn sail
slate swan
#

aiohttp :p

#

i has both WebSocket and WebServer support

crimson plover
#

any examples anyone could show me?

silk fulcrum
crimson plover
#

adding descriptions to the image i showed before

drifting arrow
#

aahh i feel like I should just use the API like normal..

silk fulcrum
slate swan
crimson plover
#

i know how to add descriptions to the commands its the attributes underneath

wraith basin
#

@faint lightwhoa hi

crimson plover
#

or arguments

drifting arrow
crimson plover
#

where it says no description given

silk fulcrum
#

i forgot how exactly it is done so searching for an example

crimson plover
#

if i do !help addxp it will show the Add xp for a skill if i do !help command addxp it shows the rest name, skill,amount - no description given

drifting arrow
#

isnt that how you give a command a description?

crimson plover
#

i was curious how to add descriptions to those

slate swan
unkempt canyonBOT
#

discord.ext.commands.parameter(\*, converter=..., default=..., displayed_default=...)```
A way to assign custom metadata for a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")'s parameter.

New in version 2.0.

Examples

A custom default can be used to have late binding behaviour.

```py
@bot.command()
async def wave(ctx, to: discord.User = commands.parameter(default=lambda ctx: ctx.author)):
    await ctx.send(f'Hello {to.mention} :wave:')
silk fulcrum
#

its smth like this```py
"""
Options

name: str
some descr
"""```

slate swan
silk fulcrum
#

oh

slate swan
#

Want to add a description to an ext.commands command's argument?
⚠️ This is not for App/hybrid commands, use @app_commands.describe(...) for that instead (?tag optiondescription)

Use the desciption= kwarg in commands.parameter:```py
from discord.ext.commands import Context, parameter

tip: there is an alias named "param", you can import and use that instead of "parameter"

@..command(...)
async def say(ctx: Context, message: str = parameter(description="What should I say?")):
# need to add a default? you can do that using the default= kwarg
# parameter(description="What should I say?", default=None)
...

**Docs:** https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.parameter

Argument descriptions show up in the default help command, they default to "No description provided" in there if none is provided.

You can also change the "No description provided" to anything you want using the `default_argument_description` kwarg in `commands.DefaultHelpCommand` and pass that to the `help_command` kwarg in the Bot constructor.
**Docs:** https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.DefaultHelpCommand.default_argument_description

here's what i got from dpy server
silk fulcrum
#

?pin 1

#

:(

drifting arrow
crimson plover
#

im confused

drifting arrow
# crimson plover
async def addxp(self, ctx, name: str = parameter(description="Name of the person!") etc etc etc):
slate swan
#

whats so confusing in ```py
@command()
async def foo(ctx, bar: str = commands.param(description="uwu")): ...

slate swan
#

im faster, touch grass

drifting arrow
slate swan
silk fulcrum
#

no

slate swan
#

yas

silk fulcrum
#

ney

drifting arrow
#

You horse?

slate swan
#

ow

#

forgor to print 🀑

silk fulcrum
#

how is he gonna unimport str to prove that str is not defined

drifting arrow
crimson plover
#

i dont get it..

slate swan
silk fulcrum
crimson plover
#

im sorry im noob as shit..

silk fulcrum
silk fulcrum
#

wth

grim oar
#

of course its pylance

primal token
grim oar
#

Oh ok didnt read

slate swan
primal token
grim oar
#

printf

primal token
#

puts

slate swan
#

println!

grim oar
#

echo

silk fulcrum
grim oar
#

πŸ˜‹

drifting arrow
#

HEY!! πŸ˜„ good news

silk fulcrum
primal token
silk fulcrum
#

that would be good new

drifting arrow
#

idk how this works but if it works it works. \o/

primal token
#

kek

silk fulcrum
#

!tag itworks

drifting arrow
#

still NFI how this shit works for my webserver..

silk fulcrum
#

nfi

#

what deos taht maen

torn sail
drifting arrow
#

According to my friend, the VPS we're using is also a webserver. But I connect to it using remote connection. It's basically a virtual machine.

#

So idk how to send stuff to it xD

grim oar
#

No Freaking Idea

drifting arrow
#

Same

unkempt canyonBOT
#

The page contains all information about aiohttp Server API:

torn sail
#

You should get started with this

primal token
#

the whole problem screams XY to me ngl

silk fulcrum
grim oar
drifting arrow
#

Okay. So I need to create a webserver on my vps so I have a 'url'?

primal token
grim oar
silk fulcrum
#

c# is better System.Console.WriteLine

primal token
#

i never said it was in cpp...?

silk fulcrum
slate swan
torn sail
silk fulcrum
#

wtf CoffeeScript

#

lof

primal token
grim oar
#

Language of coffee snorters

slate swan
#

craes

primal token
#

I think your english teacher would care

silk fulcrum
primal token
#

kek im also bad at my spelling

torn sail
silk fulcrum
grim oar
#

printf, that looks like crap

primal token
slate swan
primal token
#

outside

crimson plover
#

Scotty doesnt know..

primal token
#

thats not the translation

torn sail
#

El tienes google translate

silk fulcrum
primal token
crimson plover
#

donde esta mi gato

silk fulcrum
#

ΠΊΡ€ΡƒΡ‚ΠΎ

grim oar
#

El gato very sexo wa mou shindeiru

primal token
#

if i used my spanish you probably cant translate it due to so much slang

torn sail
coral lodge
#

hello

silk fulcrum
#

hello

primal token
coral lodge
torn sail
silk fulcrum
coral lodge
primal token
silk fulcrum
#

maybe

crimson plover
#

gilipollas afuera de nuevo

torn sail
primal token
#

kek

coral lodge
primal token
torn sail
#

Mi esponal es bueno/buena

silk fulcrum
coral lodge
silk fulcrum
#

you cant really just copy it

#

and use

primal token
#

you can

silk fulcrum
#

there is config

coral lodge
crimson plover
#

sin niranja

primal token
#

who said you can't 😳

silk fulcrum
#

big config

coral lodge
primal token
#

if you have poetry and eyes youre fine

silk fulcrum
#

youll have to write it urself iirc

coral lodge
#

how do I change the cd on replit

crimson plover
#

im too drunk for this shit i was just trying to figure out how to make descriptions now

#

fml

#

Thanks for all the help especially. TheMaster and y9

torn sail
#

πŸ‘

coral lodge
primal token
#

I wouldnt recommend what youre doing

jagged adder
#

if im using wait_for within a discord bot, can i put a list under the acceptable content list?

ie i have this rn

confirm_msg = await bot.wait_for('message', check=lambda m: m.content.lower() in [atarglock, etarglock, 'other']

etarglock atm just = ['e1']

primal token
# primal token I wouldnt recommend what youre doing

Copying advanced code to have a bot that is customized for this specific server seems like a bad idea, even if youre going to customize/change it by the impression of your problem it looks like it wont be so easy.

coral lodge
crimson plover
#

its a pretty generic code i didnt do anything crazy

primal token
#

bro

silk fulcrum
coral lodge
primal token
#

The past two replies are so confusing as theyre giving me information i dont need nor want

silk fulcrum
primal token
#

The whole point is useless and irrelevant

jagged adder
#

or if not, how i could work it so that it accepts an input if it is within said lists

primal token
#

it looks correct to me, as the expression passed to the lambda object returns bool

jagged adder
#

then how come it wont accept something that is within one of those lists as an input ?

primal token
#

you can use not

jagged adder
#

i thought so too, but obv something is missing as it doesnt work

#

wdym

primal token
#

!e

print(1 not in [2, 3])
unkempt canyonBOT
#

@primal token :white_check_mark: Your 3.11 eval job has completed with return code 0.

True
primal token
#

the expression returns True as the int isnt in the list, is that what you wanted or am i getting confused with what youre looking for?

jagged adder
#

im wanting it to return true if it is in the list

#

the issue however

#
confirm_msg = await bot.wait_for('message', check=lambda m: m.content.lower() in [atarglock, etarglock, 'other']

is that atarglock and etarglock r lists too

#

and its within those lists i cant seem to get the check to work with

#

i know for a fact that etarglock == ['e1']
as i printed it the line prior to check

#

when i type e1 however

primal token
#

so youre trying to check if the message content is in the list that has nested lists?

jagged adder
#

i believe thats correct

#

i want it to check within atarglock and etarglock

#

so yes within nested lists

primal token
#

you can use * to unpack both of the lists into that parent list and check that list

jagged adder
#

u mean like

confirm_msg = await bot.wait_for('message', check=lambda m: m.content.lower() in [*atarglock, *etarglock, 'other']

?

primal token
#

yeah

jagged adder
#

ohhh

primal token
#

you can also use sum if its nested lists only

#

!e

print(sum([[1,2],[3,4]], []))
unkempt canyonBOT
#

@primal token :white_check_mark: Your 3.11 eval job has completed with return code 0.

[1, 2, 3, 4]
jagged adder
#

i think *etarglock is more readable in my code; lemme test it rq

primal token
#

well it wouldnt work as you have a string inside of the list

jagged adder
#

hmm

#

so u would do it like

#
in [sum([atarglock, etarglock, 'other']]

?

scarlet sorrel
#

Anyone know how to do voice to text from a vc with a bot?

primal token
jagged adder
#

knowing what id be trying to do, what would you suggest ?

primal token
#

either way sum returns the summed object so no need to cast it into a list and sum should only be used if nesting container types of the same type thats being nested and provided

vocal snow
vivid chasm
#

what the problem

vocal snow
unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot 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

intents = Intents.default()
intents.members = True

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

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

vivid chasm
#

to do it i am fully beginner

vocal snow
slate swan
vivid chasm
#

WHERE TO WRITE

slate swan
#

it tells you in the 3rd line of your error

vivid chasm
#

ok wait

#

idk how

slate swan
#

read above

scarlet sorrel
slate swan
jagged adder
scarlet sorrel
slate swan
vivid chasm
#

so bad server @eager sorrel

vocal snow
slate swan
slate swan
#

!d discord.Intents.all

unkempt canyonBOT
#

classmethod all()```
A factory method that creates a [`Intents`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents "discord.Intents") with everything enabled.
slate swan
slate swan
dim cosmos
#

dont use replit

scarlet sorrel
#

Yeah lol

dim cosmos
#

use an actual hosting service & and an actual code editor

scarlet sorrel
#

Unless you only wanna run it for 10 min at a time

dim cosmos
#

or use a script and still get 30m downtimes

scarlet sorrel
#

AWS offers free hosting for a year

#

And you can run whatever you want 24/7

dim cosmos
#

^^ vouch i use aws to host my bot

scarlet sorrel
#

Same

dim cosmos
#

usually averages 16-20 ms

scarlet sorrel
#

Yeah

#

And very fast uploads and downloads

#

Faster then my own internet

dim cosmos
#

he left

#

@scarlet sorrel i added a feature to my bot yesterday. its basically custom embed reactions. it worked fine but when i changed the reactions it broke

#

do u have any idea why that could happen?

#

keeps hitting me with the error unknown emoji or some shit

scarlet sorrel
#

The emoji is probably unknown

#

Is it a default one

dim cosmos
#

no

scarlet sorrel
#

The bot has to be in a server with it

dim cosmos
#

its in the server i was testing the bot in

#

and still gave me the error

scarlet sorrel
#

Did you change the id of what its trying to send everywhere its mentioned in the code?

dim cosmos
#

wdym

scarlet sorrel
#

Like if the id of the emoji is mentioned multiple times change all of them

dim cosmos
#

oh

#

i don't store the emoji id

#

i store the emoji name in the db & add it as a reaction

#

should i use id instead of name

scarlet sorrel
#

Yes 100%

dim cosmos
#

alr ill try when i get on pc

#

so store the emoji id fetch the emoji using its id & add it as a reaction?

slate swan
#
reaction, user = await bot.wait_for('reaction_add', check=check)```

Thanks, this fixed it.
#

how to make webhook? when ppl vote my bot on topgg i want it to send a message in specific channel id

dim cosmos
#

!d discord.Webhook

unkempt canyonBOT
#

class discord.Webhook```
Represents an asynchronous Discord webhook.

Webhooks are a form to send messages to channels in Discord without a bot user or authentication.

There are two main ways to use Webhooks. The first is through the ones received by the library such as [`Guild.webhooks()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.webhooks "discord.Guild.webhooks"), [`TextChannel.webhooks()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.webhooks "discord.TextChannel.webhooks") and [`VoiceChannel.webhooks()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.VoiceChannel.webhooks "discord.VoiceChannel.webhooks"). The ones received by the library will automatically be bound using the library’s internal HTTP session.

The second form involves creating a webhook object manually using the [`from_url()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Webhook.from_url "discord.Webhook.from_url") or [`partial()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Webhook.partial "discord.Webhook.partial") classmethods.

For example, creating a webhook from a URL and using [aiohttp](https://docs.aiohttp.org/en/stable/index.html "(in aiohttp v3.8)"):
slate swan
#

no

dim cosmos
#

what

slate swan
#

show code

dim cosmos
#

figure it out on ur own

slate swan
#

nah

#

got any voting bots?

dim cosmos
#

you'll never learn if you just skid

#

lol

crystal glen
#
@client.command()
async def letter(ctx, member: discord.Member = None):
    for member in ctx.guild.members:
        try:
            for role in ctx.guild.roles:
                if role.name == member.name[0] and role.name == member.name[0] not in member.roles:
                    await member.add_roles(role)
                    print(f'{member.name} has been given the {role.name} role.')
                else:
                    print(f'{member.name} does not have the {role.name} role.')
                    pass
        except Exception as e:
            print(e)
            pass

I have made roles from A to Z, And I want to give all the members the role that there name starts with, But I don't know why it's not working

crystal glen
#

idk

slate swan
dim cosmos
#

don't be a skid

slate swan
#

for topgg voting

#

😭

crystal glen
# dim cosmos why are u doing role.name == member.name[0] twice
@client.command()
async def letter(ctx, member: discord.Member = None):
    for member in ctx.guild.members:
        try:
            for role in ctx.guild.roles:
                if role.name == member.name[0] and role.name not in member.roles:
                    await member.add_roles(role)
                    print(f'{member.name} has been given the {role.name} role.')
                else:
                    print(f'{member.name} does not have the {role.name} role.')
                    pass
        except Exception as e:
            print(e)
            pass
slate swan
dim cosmos
crystal glen
#

Because some of them already have the role

#

So if they already have it, Skip it

dim cosmos
#

so you're basically adding a role to every member who doesn't have the role in the server

crystal glen
#

Was that a question or?

dim cosmos
#

confirmation

swift pumice
#
@bot.command()
async def buttontest(ctx):
    button = Button(label="click me",style=ButtonStyle.blurple)

    async def button_callback(interaction):
        await interaction.response.send_message("Hello!")

    button.callback = button.callback
    
    myview = View(timeout=180)
    myview.add_item(button)

    await ctx.send("button",view=myview)
``` idk why but it half works and half not, the message has a button but when i click on it nothing happens, any idea?
no error
crystal glen
#

I have made roles from A to Z, And I want to give all the members the role that there name starts with, But I don't know why it's not working

dim cosmos
#

also don't add buttons in the command

#

subclass buttons/select menus

#

always subclass them

swift pumice
dim cosmos
#

np

dim cosmos
#

ur doing view = myview

#

it should be view = myview()

swift pumice
#

yes?

dim cosmos
#

forgot the ()

swift pumice
#

oh ok thanks :)

dim cosmos
#

yw

#

lmk if it works

swift pumice
#

okay

swift pumice
#

now nothing happens if i run the command

dim cosmos
#

add try & except

#

to catch the error

crystal glen
#
@client.command()
async def letter(ctx, member: discord.Member = None):
    for member in ctx.guild.members:
        for role in ctx.guild.roles:
            if role in member.roles:
                continue
            if member.name[0] == role.name:
                if role in member.roles:
                    continue
                else:
                    await member.add_roles(role)

Will this work?

#

I have made roles from A to Z, And I want to give all the members the role that there name starts with, But I don't know why it's not working

crystal glen
#
@client.command()
async def letter(ctx, member: discord.Member = None):
    for member in ctx.guild.members:
        for role in ctx.guild.roles:
            if role in member.roles:
                continue
            if member.name[0] == role.name:
                if role in member.roles:
                    print(f'{member.name} already has the {role.name} role.')
                    continue
                else:
                    try:
                        await member.add_roles(role)
                        print(f'{member.name} has been given the {role.name} role.')
                    except Exception as e:
                        print(e)
                        continue

I did this and nothing happens

dim cosmos
#

what's the error

crystal glen
#

No error

dim cosmos
#

add a try & except

crystal glen
#
@client.command()
async def letter(ctx, member: discord.Member = None):
    for member in ctx.guild.members:
        for role in ctx.guild.roles:
            if role in member.roles:
                pass
            if member.name[0] == role.name:
                if role in member.roles:
                    print(f'{member.name} already has the {role.name} role.')
                    pass
                else:
                    try:
                        await member.add_roles(role)
                        print(f'{member.name} has been given the {role.name} role.')
                    except Exception as e:
                        print(e)
                        pass

#

I did this, But it only printed the ones that already have the role

#
@client.command()
async def letter(ctx, member: discord.Member = None):
    for member in ctx.guild.members:
        try:
            for role in ctx.guild.roles:
                try:
                    if role in member.roles:
                        pass
                    try:
                        if member.name[0] == role.name:
                            try:
                                if role in member.roles:
                                    print(f'{member.name} already has the {role.name} role.')
                                    pass
                                else:
                                    await member.add_roles(role)
                                    print(f'{member.name} has been given the {role.name} role.')
                            except Exception as e:
                                print(e)
                    except Exception as e:
                        print(e)
                except Exception as e:
                    print(e)
        except Exception as e:
            print(e)

I know this is weird and no body does this, BUT I DON'T GET ANY ERROR

dim cosmos
#

Idk Buddy.

slate swan
#

How to hire a dev to make a discord bot?

vale wing
#

You don't need 3 layer try-except bruh

#

Just leave the outer one

unkempt canyonBOT
#

9. Do not offer or ask for paid work of any kind.

crystal glen
vale wing
#

What is the query

swift pumice
#

how can i make a if in buttons like if he presses ➑️ the message edits to an other page but if he presses ⬅️ the message edits to an other page too?

slate swan
#

Ah I am sorry, I am just asking for a platform where I can hire .

I tried fiver but no luck most of them don't know anything

vale wing
#

SQL

vale wing
#

Cursor doesn't come out of vacuum yk

#

What query do you execute with that cursor

#

I don't see it in this code

#

What the heck is that string

#

With SQL query

#

It's f-string using % formatting and for some reason you are also trying to use SQL placeholders

#

It should be like this

await cursor.execute("SELECT role_id FROM reactionroles WHERE guild_id = $1 AND msg_id = $2 AND emoji = $3", (...))```
#

Also is this asyncpg or aiosqlite

vale wing
vocal snow
#

%s for MySQL placeholder

#

Instead of $n

vale wing
#

Ok sorry

slate swan
#

Can also use ?

#

And it's more used actually

#

Yeah, for SQL languages

#

Example

await cursor.execute("SELECTΒ *Β FROMΒ blacklistΒ WHEREΒ user_id=?",Β (user_id,))
#

No need of an f string, and just use ? for where the variable will go

swift pumice
#

how can i do this without it giving me errors?

glad cradle
#

what the ide says?

swift pumice
blazing star
#

can anybody teach me python?

swift pumice
#

idk

#

idk

#

i do

#

but whatever i try it doesnt work

glad cradle
#

if you run the code you get an error?

swift pumice
slate swan
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.

vocal snow
unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

swift pumice
tawdry tendon
#

hello

#

i need help

swift pumice
tawdry tendon
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

vocal snow
swift pumice
vocal snow
#

Send ur full code

tawdry tendon
#

can anyone help me?

#

@vocal snow can you help?

tawdry tendon
#

yes, i think

#

how can i check

vocal snow
#

pip show discord.py

spiral plover
#

Hello how can i install PIPENV? om win

tawdry tendon
#

1.7.3

#

how can i ypdate

vocal snow
#

you don't need to update

#

How are you loading the extension

swift pumice
# vocal snow Send ur full code
@bot.command()
async def help1(ctx):
    hi = Button(label="β¬…", style=ButtonStyle.blurple)
    subscribe = Button(label="➑", style=ButtonStyle.blurple)

    async def hi_callback(interaction):
        await interaction.message.edit("test")
    async def hi2_callback(interaction):
        await interaction.message.edit("test1")

        hi.callback = hi_callback
        hi2.call = hi2_callback
        myview = View(timeout=180)
        myview.add_item(hi)
        myview.add_item(hi2)

        await ctx.send("help", view=myview)```
tawdry tendon
swift pumice
#

btw hi zeffo

vocal snow
swift pumice
#

how are you

vocal snow
#

How are you loading the extension file

tawdry tendon
vocal snow
#

Not how you're importing the library

vocal snow
swift pumice
vocal snow
#

(!paste)

vocal snow
#

Yes

swift pumice
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

vocal snow
swift pumice
vocal snow
#

U probably mixed spaces and tabs

tawdry tendon
#

@vocal snow how can i use dpy 2.0

vocal snow
tawdry tendon
#

ok thanks

#

Now how can u use it

#

@vocal snow

swift pumice
#
async def help1(ctx):
    hi = Button(label="β¬…", style=ButtonStyle.blurple)
    subscribe = Button(label="➑", style=ButtonStyle.blurple)

        async def hi_callback(interaction):
            await interaction.message.edit("test")
        async def subscribe_callback(interaction):
            await interaction.message.edit("test1")
            hi.callback = hi_callback
            subscribe.callback.call = subscribe_callback
            myview = View(timeout=180)
            myview.add_item(hi)
            myview.add_item(subscribe)
            await ctx.send("help", view=myview)```
tawdry tendon
#

Bro

swift pumice
#

yes?

tawdry tendon
#

Your async def callback is overindented

silk fulcrum
#

why

tawdry tendon
#

Wdym why?

silk fulcrum
#

oh yes

#

o thought its a class

#

smh

tawdry tendon
#

And everything else under that

tawdry tendon
silk fulcrum
#

btw you dont use these callbacks anywhere

swift pumice
#

like this?

silk fulcrum
tawdry tendon
#

You can’t do that

silk fulcrum
#

you removed indents completely

#

he can

tawdry tendon
#

No

silk fulcrum
#

but that is not what he wants

tawdry tendon
#

He has to indent everything under the subscribe line once

silk fulcrum
#

except bot.run

tawdry tendon
tawdry tendon
swift pumice
tawdry tendon
#

I get the error

#

welcome isn’t a command

#
discord.ext.commands.errors.CommandNotFound: Command "welcome" is not found
silk fulcrum
#

what are you doing? I mean what command are you issuing

tawdry tendon
#

.welcome to show the welcome commands

silk fulcrum
#

why is it a group?

tawdry tendon
#

True

#

Should I do bot.command() instead

#

Or command.commands

silk fulcrum
#

@commands.command

#

if you are not planning to use it as a group

tawdry tendon
#

Ok thanks

swift pumice
#
async def help1(ctx):
    hi = Button(label="β¬…", style=ButtonStyle.blurple)
    subscribe = Button(label="➑", style=ButtonStyle.blurple)

        async def hi_callback(interaction):
            await interaction.message.edit("test")
        async def subscribe_callback(interaction):
                await interaction.message.edit("test1")
                hi.callback = hi_callback
                subscribe.callback.call = subscribe_callback
                myview = View(timeout=180)
                myview.add_item(hi)
                myview.add_item(subscribe)
                await ctx.send("help", view=myview)
            ``` can someone indent it for me? i still cant get it :(
#

Sry

tawdry tendon
#

Damn

#

Look

silk fulcrum
#

like yours

#

but you don't have anything like that

tawdry tendon
#

From async def hi_callback to the last line act like your copy and pasting but instead, don’t, press β€œshift tab”

silk fulcrum
#

so you should just remove one tab for all these lines

#

except subscribe =

tawdry tendon
#

But bot.run shouldn’t be indented

swift pumice
#

Thanks :D

tawdry tendon
#

Np

vale wing
#

Pretty sure edit message accepts kwargs only

#

!d discord.Message.edit

unkempt canyonBOT
#

await edit(*, content=..., embed=..., embeds=..., attachments=..., suppress=False, delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the message.

The content must be able to be transformed into a string via `str(content)`.

Changed in version 1.3: The `suppress` keyword-only parameter was added.

Changed in version 2.0: Edits are no longer in-place, the newly edited message is returned instead.

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
silk fulcrum
#

yes

#

and interaction doesnt have message attr iirc

#

!d discord.Interaction.message

unkempt canyonBOT
vale wing
#

For my knowledge it does

silk fulcrum
#

oh sry

slate swan
#

components interactions yeah

glad cradle
#

hey 9047064c7ec960627a11743bfa49b0af3e8dd702ef771cec3e908b5cd28b477e how are you?

wind wharf
#

Hello

#

May someone help me

#

I need help about my discord python codes

worldly badger
#

what do i do?
i've tried to uninstall an reinstall and it doesnt work

slate swan
#

use discord.py2.0

glad cradle
wind wharf
#

if you have got free time

glad cradle
#

send the code

wind wharf
#

I am really glad to show you

#

May I add you?

#

@glad cradle ?

glad cradle
#

idk

#

just show the code or explain your problem / error

wind wharf
#

I am trying to add a currency system on my discord server

#

my coding skills are not good enough

#

if you see

#

it can be better for you

glad cradle
#

you need a database

wind wharf
#

I created it

glad cradle
#

it's like economy commands right?

wind wharf
#

I did something but

#

if you see you can understand easly

glad cradle
#

ok so lemme see

meager chasm
#

me too can i copy ?

desert badger
#

can anyone tell me why it gets underlined ?

silk fulcrum
#

self is not defined

meager chasm
#

I think because self is not defined

#

But i am new to the discord pytohn

desert badger
meager chasm
#

yes in that method

#

different scopes

#

u need to have self as first parameter of all normal methods

fresh iron
#

i made a discord bot that can stream any movie in vc

meager chasm
#

ok

#

who asked tho

fresh iron
#

i can't see people with anime pfp's messages sorry

#

too irrelevant

meager chasm
#

ok

#

who asked tho

wind wharf
#

@glad cradle will you help me?

glad cradle
wind wharf
#

I can explain that first

#

someone must type +claim

#

if he didn't type before

#

else code will work and it will take messeage author's Id

#

and it will add infos into mainbank.json

#

this part is working

glad cradle
#

are you using a json file as a database? 😭

wind wharf
#

:(((

#

😒

#

my old friend said that too

#

bro just come to screen share

#

let me show you with voice chat

glad cradle
#

rn I can't

#

if you're self hosting or if you're using an host you can just use a database

#

it's much more better than a json file

slate swan
#

Hi! I was trying to make an embed command:


@bot.command(
    name='test',
    description='test'
)
async def clear(ctx):
    embedVar = Embed(title="test", description="test")
    await ctx.send(embedVar)```

But i get this error:
```TypeError: _Context.send() got an unexpected keyword argument 'embed'```
#
@bot.command()
async def unban(ctx, user: disnake.User = None):
    
    if user == None:
        await ctx.send(f'Poprawne uΕΌycie komendy: `?unban (ID uΕΌytkownika)`')

    else:
        await ctx.guild.unban(user)
        embed = disnake.Embed(title="UΕ»YTKOWNIK ODBANOWANY!", description=f"PomyΕ›lnie odbanowano uΕΌytkownika!\nNick: **{user.mention}**",  colour=0x00ff08)
        await ctx.send(embed = embed)


    bans = await ctx.guild.bans()

    if user is not bans:
        await ctx.send("nie ma go")```


how to answer if the user is not in the list of banned users?
#

ok

#

it wont send the command

glad cradle
#

lemme read

glad cradle
slate swan
glad cradle
slate swan
glad cradle
#
try:
    await ctx.guild.unban(user)
    ...
except discord.NotFound:
    ...
    # the user is not banned
slate swan
slate swan
#

ok

#

u know whats wrong?

#

🀦

#

wut?

#

all code is wrong

desert badger
#

what did i do wrong here, liek... why is it marked red

slate swan
#

80%

desert badger
#

i mean isnt notification defined

slate swan
#

notifications*

honest shoal
desert badger
#

i mean notifications is a list of all notifs

slate swan
glad cradle
desert badger
#
  • notifications also doesnt work
slate swan
#

just do for notification in get_notifications()

honest shoal
slate swan
#

@glad cradle this:?

@bot.command()
async def unban(ctx, user: disnake.User = None):
    
    if user == None:
        await ctx.send(f'Poprawne uΕΌycie komendy: `?unban (ID uΕΌytkownika)`')

    else:
        await ctx.guild.unban(user)
        embed = disnake.Embed(title="UΕ»YTKOWNIK ODBANOWANY!", description=f"PomyΕ›lnie odbanowano uΕΌytkownika!\nNick: **{user.mention}**",  colour=0x00ff08)
        await ctx.send(embed = embed)


    try:
        await ctx.guild.unban(user)

    except disnake.NotFound:
        await ctx.send("nie ma go na liΕ›cie!")```
#

ok

desert badger
slate swan
#

still not defined?

#

if you take the index out is it defined

desert badger
slate swan
#

user login

glad cradle
#

it should be a list of dict right?

desert badger
# glad cradle what's the return type of `get_notifications`
def get_notifications():
    users = get_users(config["watchlist"])
    streams = get_streams(users)


    notifications = []
    for user_name in config["watchlist"]:
        if user_name not in online_users:
            online_users[user_name] = datetime.utcnow()
        if user_name not in streams:
            online_users[user_name] = None
        else:
            started_at = datetime.strptime(streams[user_name]["started_at"], "%Y-%m-%dT%H:%M:%SZ")
            if online_users[user_name] is None or started_at > online_users[user_name]:
                notifications.append(streams[user_name])
                online_users[user_name] = started_at
            
        
    return notifications
slate swan
#

help

#

what’s the problem stritix

slate swan
glad cradle
slate swan
#

wdym by answer?

glad cradle
slate swan
glad cradle
glad cradle
desert badger
#

its empty it should include me tho

glad cradle
#

as you can see it's a list

desert badger
#

yes ?

glad cradle
#

so why you're trying to do notification[key]?

slate swan
#
    try:
        await ctx.guild.unban(user)

    except disnake.NotFound:

        await ctx.send("user is not banned!")```
honest shoal
slate swan
#

embeds?

desert badger
#

if im not wrong

slate swan
#

🀦

glad cradle
#

your indentation is messed up

honest shoal
#

they renamed it to embeds

glad cradle
slate swan
glad cradle
slate swan
glad cradle
#

now it's right

slate swan
glad cradle
#

it should

slate swan
glad cradle
#

you're using disnake

slate swan
#

and?

#

@glad cradle

@bot.command()
async def unban(ctx, user: disnake.User = None):
    
    if user == None:
        await ctx.send(f'Poprawne uΕΌycie komendy: `?unban (ID uΕΌytkownika)`')

    else:
        await ctx.guild.unban(user)
        embed = disnake.Embed(title="UΕ»YTKOWNIK ODBANOWANY!", description=f"PomyΕ›lnie odbanowano uΕΌytkownika!\nNick: **{user.mention}**",  colour=0x00ff08)
        await ctx.send(embed = embed)```
#

this unban command correct working

#


    try:
        await ctx.guild.unban(user)
        await ctx.send("ds")

    except disnake.NotFound:

        await ctx.send("user is not banned!")```

i have problem only with this one
#

if a user is already banned, it wont ban them again

#

unbanned*

slate swan
#

slow

glad cradle
pulsar solstice
#

I am building a rps game in discord.py So.. How can I check the button selected by the user and work according to it?

#

this is my code

slate swan
#

and if i use command ?unban [ID] and this user is not banned i want ctx.send("he is not banned")

pulsar solstice
#
@bot.command()
async def rps(ctx):
    random_rps=[":paper:", ":sissors:", ":dsrock:"]
    rps_choice = random.choice(random_rps)
    rbutton= Button(emoji=":dsrock:")
    pbutton= Button(emoji=":paper:")
    sbutton= Button(emoji=":sissors:")
    view = View()
    view.add_item(rbutton)
    view.add_item(pbutton)
    view.add_item(sbutton)
    await ctx.send("Choose your Move\n**in 3secs**", view=view)

slate swan
slate swan
#
@bot.command()
async def unban(ctx, user: disnake.User = None):
    
    if user == None:
        await ctx.send(f'Poprawne uΕΌycie komendy: `?unban (ID uΕΌytkownika)`')

    else:
        await ctx.guild.unban(user)
        embed = disnake.Embed(title="UΕ»YTKOWNIK ODBANOWANY!", description=f"PomyΕ›lnie odbanowano uΕΌytkownika!\nNick: **{user.mention}**",  colour=0x00ff08)
        await ctx.send(embed = embed)


    try:
        await ctx.guild.unban(user)
        await ctx.send("ds")

    except disnake.NotFound:
        await ctx.send("user is not banned!")```
#

smh, errors?

slate swan
#

you are banning someone and passing an object to the ban method wich is None, do check this if you have a ban command

pulsar solstice
#

pls help me too

swift pumice
#

Hi(sorry for bad english)

meager chasm
#

i ask in swaspy servre how to store python dicrionary and they say txt file is good idea ??

slate swan
#

they are wrong, you should be using a proper database

meager chasm
#

hmm i think i will use the txt file

slate swan
maiden fable
maiden fable
meager chasm
maiden fable
#

Not txt file ;-;

slate swan
meager chasm
#

I will show coe

maiden fable
#

But still... txt file, seriously?!

meager chasm
#
d = {   # dicarionary
    1: 2,
    'swas': 'py'
}
import json

json.dump(d, open('file.txt', 'w')) # writes the dicartionary to file

import json # imports the json

with open('file.txt', 'r') as f:
    dictionaray = json.load(f)  # gets dicatiaroary from txt file


print(dictionaray)


winged coral
#

You’re importing json twice

#

You’re not closing the file

maiden fable
#

and use w+ mode

meager chasm
silk fulcrum
#

how?

#

bots can stream??

meager chasm
#

no

#

he is using selfbot

silk fulcrum
#

...

meager chasm
#

and breaking lots of copyright laws!

slate swan
#

Hi i wanted to make an clear <amount> command but its not responding

@bot.command(
    name="clear",
    description="Clear specific amount of messages",
    options=[
        interactions.Option(
            type=interactions.OptionType.INTEGER,
            name="amount",
            description="How many messages you want to delete",
            required=True,
            )
    ]
)

async def clear(ctx, amount: int):
    await ctx.channel.delete(limit=amount)```
Error:
```TypeError: Channel.delete() got an unexpected keyword argument 'limit'```
slate swan
#

ok

meager chasm
#

delete is for delete channel

#

!d discord.TextChannel.purge

unkempt canyonBOT
#

await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=None, bulk=True, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.

You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.

Changed in version 2.0: The `reason` keyword-only parameter was added.

Examples

Deleting bot’s messages...
slate swan
#

ok thanks

#
@bot.slash_command()
async def embed(ctx, tytul):
    embed = disnake.Embed(title = tytul, description="Embed Description", colour=0xF0C43F)```
maiden fable
#

Hm

silk fulcrum
#

tytul

slate swan
maiden fable
#

You need slash commands/flags for that

meager chasm
#

what is embed crator comand

late kraken
#

How do I check if the type of a function is generator

slate swan
#

/embed [title]

maiden fable
silk fulcrum
#

crator

meager chasm
#

maybe u can use modal and stuffs

maiden fable
#

funcs are never generators

slate swan
silk fulcrum
#

generator?

maiden fable
#

funcs are.... Callables

late kraken
#

im if it returns a generator

slate swan
silk fulcrum
late kraken
#

a function that has yield

meager chasm
slate swan
#

/embed [title] [description]

maiden fable
#

def is a callable

silk fulcrum
#

ok..

late kraken
#

an example:

def f():
    for i in range(12):
        yield i
        
f()
Out[18]: <generator object f at 0x0000019FC80AC040>
type(f())
Out[19]: generator
maiden fable
late kraken
#

now I want to check if it returns a generator

slate swan
late kraken
maiden fable
unkempt canyonBOT
#
Noooooo!!

No documentation found for the requested symbol.

maiden fable
#

Urgh

#

!d collections.abc.Generator

unkempt canyonBOT
#

class collections.abc.Generator```
ABC for generator classes that implement the protocol defined in [**PEP 342**](https://www.python.org/dev/peps/pep-0342) that extends iterators with the [`send()`](https://docs.python.org/3/reference/expressions.html#generator.send "generator.send"), [`throw()`](https://docs.python.org/3/reference/expressions.html#generator.throw "generator.throw") and [`close()`](https://docs.python.org/3/reference/expressions.html#generator.close "generator.close") methods. See also the definition of [generator](https://docs.python.org/3/glossary.html#term-generator).

New in version 3.5.
maiden fable
#

This should be what u r looking for

late kraken
#

lemme try it

meager chasm
maiden fable
#

They can use isinstance and collections.abc.Generator

meager chasm
#

!d inspect.isgenerator

unkempt canyonBOT
maiden fable
#

Damn, python never fails to amaze me

slate swan
#

@meager chasm what do i have to put instead of ctx.purge(limit=amount)

glad cradle
#

Abc means abstract class right?

meager chasm
maiden fable
maiden fable
maiden fable
meager chasm
#

no

#

it gave error" CommandContext has no attribute purge"

maiden fable
#

Nvm

late kraken
#

for some reason I wasnt able import that

meager chasm
#

it is not discorapy

#

it is some other lib

late kraken
slate swan
#

lol

slate swan
meager chasm
#

which lib ur using

maiden fable
#

And what version

meager chasm
#

go to its docs

#

and figure it out

slate swan
#

ok

late kraken
#

aha this is even better inspect.isgeneratorfunction(f)

meager chasm
#

inspect has everythjing ☺️

late kraken
maiden fable
#

The return type is a generator

#

That function probably checks for the return type lemme see

late kraken
#

if it has yield, its different than just returning a generator

meager chasm
#

def f():
    return 1

def g():
    yield 1

#

here f and g are both function

#

but f() is int and g() is generator

maiden fable
#

But the return type is a generator type

meager chasm
#

and next(g()) is int

maiden fable
#

f and g are Callables

late kraken
#

you might be right

isinstance(f(), Generator)
Out[33]: True
isinstance(f, Generator)
Out[34]: False
white citrus
#
future: <Task finished name='discord-ui-view-timeout-183d2f8f17396132103875690f8a9e54' coro=<settings_document_admin_buttons.on_timeout() done, defined at c:\Discord\Maja Projekt\MajaSystem\modules\setup\buttons.py:24> exception=AttributeError("'settings_document_admin_buttons' object has no attribute 'message'")>
Traceback (most recent call last):
  File "c:\Discord\Maja Projekt\MajaSystem\modules\setup\buttons.py", line 28, in on_timeout
    await self.message.edit(view=self)
AttributeError: 'settings_document_admin_buttons' object has no attribute 'message'```
#
    @nextcord.ui.button(label="Delete the Role", style=nextcord.ButtonStyle.danger)
    async def del_admin_role(self, button, interaction):
        embed=nextcord.Embed(description=f"{config.DiscordTic} The role has been successfully removed!", colour=config.grΓΌn)
        button = self.children[0]
        button.disabled = True
        button.style = nextcord.ButtonStyle.grey
        await interaction.response.edit_message(embed=embed, view=self)
        await self.unset_admin_role(interaction)
            
    async def on_timeout(self):
        eb = self.children[0]
        eb.disable = True
        eb.style = nextcord.ButtonStyle.grey
        await self.message.edit(view=self)```
shrewd apex
#

how are u sending the view

white citrus
#

in a other file

shrewd apex
#

show how u are sending it πŸ—Ώ

meager chasm
white citrus
shrewd apex
#
view = settings()
view.message = await interaction.response.send_message()
#

u need a message attr for that u have to assign a message object to the view with a message attr which u will be using in on_timeout

white citrus
shrewd apex
#

yes

#

where u are sending that particular view class

white citrus
#
                        view_e = settings_document_admin_buttons(interaction, settings_data_admin)
                        view_message = await interaction.response.send_message(embed=error, view=view_e, ephemeral=True)```

so ig?
white citrus
shrewd apex
#

run it

white citrus
shrewd apex
#

no

white citrus
# shrewd apex no
Task exception was never retrieved
future: <Task finished name='discord-ui-view-timeout-b81cfd2501e31a87ca674178f25d5fdc' coro=<settings_document_admin_buttons.on_timeout() done, defined at c:\Discord\Maja Projekt\MajaSystem\modules\setup\buttons.py:24> exception=AttributeError("'settings_document_admin_buttons' object has no attribute 'message'")>
Traceback (most recent call last):
  File "c:\Discord\Maja Projekt\MajaSystem\modules\setup\buttons.py", line 28, in on_timeout
    await self.message.edit(view=self)
AttributeError: 'settings_document_admin_buttons' object has no attribute 'message'```

mhh
shrewd apex
#

ites view_e.message

shrewd apex
novel prairie
#
token
("xxxxxxxxxxx")
bot.run(token)``` why did this happened
white citrus
#
view_e = settings_document_admin_buttons(interaction, settings_data_admin)
view_message = await interaction.response.send_message(embed=error, view=view_e, ephemeral=True)
^ This is cog.py


    async def on_timeout(self):
        eb = self.children[0]
        eb.disable = True
        eb.style = nextcord.ButtonStyle.grey
        await self.message.edit(view=self)
^This is buttons.py```

@shrewd apex
so i must use self.view_message.edit()?
novel prairie
#

File "main.py", line 534, in <module>
token
NameError: name 'token' is not defined

slate swan
#

Hi

shrewd apex
#

no u are doing it wrong

#

it's so simple just follow what i said

novel prairie
#

df goin on with my code how can i fix it

white citrus
slate swan
#
token = ("BOT Token Here")

client.run(token)
#

why the parentheses

#

Yes

#

and why even use a variable

#

to store the token

grim oar
#

Ashley

white citrus
#

@shrewd apex

    @nextcord.ui.button(label="Delete the Role", style=nextcord.ButtonStyle.danger)
    async def del_admin_role(self, button, interaction):
        embed=nextcord.Embed(description=f"{config.DiscordTic} The role has been successfully removed!", colour=config.grΓΌn)
        button = self.children[0]
        button.disabled = True
        button.style = nextcord.ButtonStyle.grey
        await interaction.response.edit_message(embed=embed, view=self)
        await self.unset_admin_role(interaction)
            
    async def on_timeout(self):
        eb = self.children[0]
        eb.disable = True
        eb.style = nextcord.ButtonStyle.grey
        await self.message.edit(view=self)```
This is buttons.py
slate swan
#

va

grim oar
#

So rude

slate swan
#

what rude

#
import discord
from discord.ext import commands
from discord import Button, ButtonStyle


client = commands.Bot(command_prefix=commands.when_mentioned_or('!'))


@client.command()
async def buttons(ctx):
   msg_with_buttons = await ctx.send('iakw rin bahala dito', components=[[
       Button(label="ikaw",
              custom_id="bahala",
              style=ButtonStyle.red),
       Button(label="ikaw",
              custom_id="pud bahala",
              style=ButtonStyle.green),
   ]])

   def check_button(i: discord.Interaction, button):
       return i.author == ctx.author and i.message == msg_with_buttons

   interaction, button = await client.wait_for('button_click', check=check_button)

   
   msg = f"You just pressed{button.custom_id} the thing"
   await interaction.respond(msg)
shrewd apex
#

it would be better if someone else explains i am outside rn so can't explain thoroughly

glad cradle
#
print(__import__("discord").__version__)

I want to create a Bot all like that

grim oar
#

Tha ye crazy

shrewd apex
#

u can ask ashley she's smort

slate swan
grim oar
#

They should add async lambda

slate swan
#

I guess we all agree on that

grim oar
#

I am just a man with mediocre knowledge.

slate swan
#

nice

grim oar
#

They should add async lambda

white citrus
# white citrus <@656838010532265994> ```py @nextcord.ui.button(label="Delete the Role", st...

and this is cog.py

    @nextcord.slash_command(name="setup-administrator-role", description=f"Set the highest role. (Owner or moderator role recommended)", guild_ids=[config.TESTGUILD])
    async def _setup_administrator_role(self, interaction: nextcord.Interaction, role: nextcord.Role = SlashOption(name="role", description="Please select a role (Owner or moderator role recommended)")):
        
        if interaction.user.id == interaction.guild.owner.id:    
            
            if entry_true is not None:
                

                if interaction.guild.id == entry_true["_id"]:
                        
                        
                    if "admin_id" in entry_true:
                        
                        error = nextcord.Embed(title=f"{config.DiscordErrorEmoji} The Guild has already a Administrator Role.", description="Please delete the old one if you want to set a new one.",
                                                colour=config.rot)
                        view_e = settings_document_admin_buttons(interaction, settings_data_admin)
                        view_message = await interaction.response.send_message(embed=error, view=view_e, ephemeral=True)
                        return
                    
                    else:
                        ...
                        
                elif interaction.guild.id != entry_true["_id"]:
                    ...
                    
            elif entry_true is None:
                ...
        
        if interaction.user.id != interaction.guild.owner.id:
            ...        ```
grim oar
#

For one liner people

slate swan
#

join the organization nova

grim oar
#

Which one

slate swan
#

python

glad cradle
#

is there no way to do async lambda?

grim oar
#

How

slate swan
#

idk

white citrus
#

who can help me?

grim oar
slate swan
slate swan
glad cradle
white citrus
slate swan
#

dont care

grim oar
slate swan
grim oar
#

Ashley help him bro

white citrus
slate swan
#

!d help

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.
grim oar
#

Truly an underrated function 😫

glad cradle
slate swan
glad cradle
#

I've read rn that you can emulate async lambda with an async generator

grim oar
grim oar
glad cradle
#

!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.
grim oar
glad cradle
white citrus
grim oar
#

I am about to feel overwhelmed

glad cradle
#
key=lambda x: (await somefunction(x) for _ in '_').__anext__()

that's what I found

white citrus
slate swan
# white citrus edit the message in on_timeout

you can do it like so

class MyView(ui.View):
  message: discord.Message

  async def on_timeout(self) -> ...:
    await self.message.edit(...)  

''' and in your command'''

@bot.command()
async def no(ctx: commands.Context) -> None:
  view = MyView()
  view.message = await ctx.send("yes", view=view) #because the `send` method returns a Message object
#

#bot-commands

grim oar
#

But yes whatever async lambda ig!!

glad cradle
slate swan
#

how does "lol" and "😫" even relate

vocal snow
grim oar
#

that's for making a generator

#

Expression

slate swan
vocal snow
#

comprehension bro

grim oar
slate swan
#

nice

glad cradle
grim oar
slate swan
vocal snow
grim oar
#

[i for i in my ass] is comprehension!!

white citrus
# slate swan you can do it like so ```py class MyView(ui.View): message: discord.Message ...
@nextcord.slash_command(name="setup-administrator-role", description=f"Set the highest role. (Owner or moderator role recommended)", guild_ids=[config.TESTGUILD])
    async def _setup_administrator_role(self, interaction: nextcord.Interaction, role: nextcord.Role = SlashOption(name="role", description="Please select a role (Owner or moderator role recommended)")):
        
        if interaction.user.id == interaction.guild.owner.id:    
            
            if entry_true is not None:
                

                if interaction.guild.id == entry_true["_id"]:
                        
                        
                    if "admin_id" in entry_true:
                        
                        error = nextcord.Embed(title=f"{config.DiscordErrorEmoji} The Guild has already a Administrator Role.", description="Please delete the old one if you want to set a new one.",
                                                colour=config.rot)
                        view_e = settings_document_admin_buttons(interaction, settings_data_admin)
                        view_message = await interaction.response.send_message(embed=error, view=view_e, ephemeral=True)
                        return
                    
                    else:
                        ...
                        
                elif interaction.guild.id != entry_true["_id"]:
                    ...
                    
            elif entry_true is None:
                ...
        
        if interaction.user.id != interaction.guild.owner.id:
            ...        ```

thats my command
slate swan
#

jeez

vocal snow
crude frigate
#

Whats the best way to store discord user specified variables such as points or other things inside a class in a database so that after I restart the bot the created instances arent gone?

grim oar
#

bro that's crazy!!

slate swan
slate swan
vocal snow
white citrus
grim oar
#

why

vocal snow
grim oar
#

Why not arch or something popular bro

vocal snow
grim oar
#

That looks so good

glad cradle
vocal snow
#

wtf

grim oar
#

Lemme show mine hehe

glad cradle
#

it's called UwUntu

grim oar
#

πŸ˜‹

slate swan
grim oar
#

Got it off a YouTube video

#

isn't it ctx.message idk

glad cradle
grim oar
vocal snow
white citrus
#

@slate swan ?

grim oar
grim oar
late kraken
grim oar
#

neovim

late kraken
#

gotta check that out

glad cradle
vocal snow
#

i will probabkly use neovim

grim oar
vocal snow
#

if i can figure out to transgfer my vsc theme

grim oar
grim oar
glad cradle
#

is it that good?

grim oar
grim oar
glad cradle
#

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

Adds a reaction to the message.

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

You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/latest/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/latest/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.

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

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
glad cradle
#

he's using interaction

#

idk

vocal snow
#

!d discord.Interaction.message

unkempt canyonBOT
glad cradle
#

no, it's a library

maiden fable
glad cradle
#

from what I understand

grim oar
#

Are interaction and context same

grim oar
maiden fable
#

no

glad cradle
vocal snow
grim oar
#

Back in the day things were so simple bro

grim oar
white citrus
#

@grim oar can you help me? ahsley is gone

vocal snow
#

yes i can finally be arch man ☺️

grim oar
#

Sorry I don't know crap about interaction stuff now

grim oar
vocal snow
#

garuda look so much better

#

what arch has for pacakge manager

grim oar
#

What do you mean it looks better bro you can make arch look better too

#

pacman

vocal snow
#

yea but garuda dragonized is like KDE Plasma fork and it look very nice.

vocal snow
slate swan
#

πŸ—Ώarch is crux based

grim oar
#

DEs are bad!!

glad cradle
#

this chat has been transformed into a Linux chat

grim oar
#

They consume too much memory, run neofetch

vocal snow
#

yes because u have potato computer which cannot run them