#discord-bots

1 messages · Page 1101 of 1

elfin plume
#
    # Button Callback to respond to a button click
    async def button_callback(interaction):
      await ctx.edit(content="yo")

my problem is that, when the button is clicked, the original message isnt edited. I have already tried "edit_original_message" But that doesnt work aswell. Also, I get no error on "ctx.edit" so does anyone know the issue?

slate swan
#

ctx is not defined

pearl fjord
#

how do you do embed links in embed? like "Click here for more info!"

elfin plume
pearl fjord
#

its a def

#

it does not carry variables

#

maybe look into what variable scopes are

elfin plume
#

no its still async

#

because it needs to be awaited

pearl fjord
#

😐

slate swan
slate swan
elfin plume
#

oh so should i add

ctx = await client.get_context(interaction)
slate swan
#

nooo, you want to edit a message on interaction right?

elfin plume
#

yea

slate swan
#

is it a normal command or an app command?

elfin plume
#

i think its normal, basically its just a function to respond to a button click

#

and it edits that message

#

which the button was attatched too

sweet moat
#

hi! is there a way i could accomplish this?
file=discord.File('https://media.discordapp.net/attachments/000000000000000/000000000000000/banner.gif')
aka, sending an attachment url as a file attachment

clever hamlet
#

Can someone help me to make music bot (I'm new)

stiff fern
#
channel = interaction.client.get_channel(986468534391545976)
await interaction.response.channel.send_message(embed=suggestion_embed)

I'm trying to send the embed in a specific channel with slash commands but I guess I cant figure out what Im suppose to use get_channel with

#

The error I get with this is has no attribute get_channel

shrewd apex
#

only client.get_channel is enough

cerulean folio
#

what are these @bot statements?

#

I don't know how to use them

#

and what's ctx i see that everywhere but i don't understand it

slate swan
cerulean folio
#

I don't get it

#

there are built-in functions for commands?

slate swan
slate swan
cerulean folio
#

I just do something like

@client.event
async def on_message(message):
  if message.content.split(' ')[0] == command:
    msg_content = message.content.split(' ')[1:]
    #and I handle the rest here
slate swan
cerulean folio
#

oh !

#

how can I learn slowly how to do this?

slate swan
cerulean folio
#

I also have another issue

slate swan
cerulean folio
#

I really struggle with async functions so... my code is so big and in one file

#

And many things I could put into functions but i don't because it stops working

slate swan
slate swan
#

message_content is the first thing.

lyric apex
#

How to make font command?

cerulean folio
maiden fable
#

Anyone willing to help me complete my bot's rewrite? 👀

lyric apex
#

Like some bots he $font {text} and it gives the text in some stylish way

lyric apex
#

🙂

maiden fable
#

Yea lol

#

Ngl yr former pfp was better

vast sable
#

how long can a view/select/button last? i have reaction roles using a dropdown in my bot but after a period of time (a few hours ig) after the view is sent the interaction fails whenever I try to use it

#

is there a way to make it last infinitely

slate swan
#

#free-pr moment

#

i was thinking of making a tutorial site but its too much work.

#

no its not

#

you can make one using github pages easily with just some basic markdown knowledge

#

..

slate swan
# slate swan #free-pr moment

if youre gonna make a pr, make the Message typehint to disnake.Message as it shows an example of the class imported but not in the Nextcord example, and make the Nextcord example use good var naming

slate swan
#

you need to call the method

#

nextcord.Intents.all**()**

slate swan
#

also yeah, nextcord.Client was defined as client but bot.run was used to run the bot looli

#

🗿

maiden fable
#

Nice, never knew okimii wrote the docs

slate swan
#

bro im not that bad

slate swan
#

@vocal plover bro fix your examples😭

#

vco on the way to become next robin or wot

#

you did not💀

#

i want to learn how to use mkdocs now, sphinx is kinda boring

#

team2 is None

vast sable
#

look at what you're assigning the variable team2 from

#

whatever youre doing there, it's not finding it

shrewd apex
#

well what a shock it doesn't work now ||-_-||

left idol
#

in pycord how do i have multiple errors at once?

#
@stats.error
async def stats_error(ctx, error):
    if isinstance(error, commands.NotOwner):
        await ctx.respond("No Permissions", ephemeral = True)
#

this is for permissions testing but i want to add a cooldown

slate swan
#

use elif ?

left idol
#

ah ok

slate swan
#

hello how to make database for warnings

cloud dawn
slate swan
#

like when i say .warn t@g member {reason}

#

and when i say .warns t@g that member who got warn he say amount of warns

cloud dawn
#

Okay I got that but are you stuck somewhere?

#

What have you got so far?

slate swan
#

idk how to make a database for discord bots

cloud dawn
#

Did you have any database in mind of using?

slate swan
#

no

#

just to remember how many warns

cloud dawn
#

Have you done some research regarding databases?

slate swan
#

yes

cloud dawn
cloud dawn
#

Postgresql

regal pulsar
#

you dont need postgres for something that simple

slate swan
#

pg > any db

regal pulsar
#

true

cloud dawn
#

^ == True

cloud dawn
regal pulsar
#

oh lol

slate swan
#

sqlbased dbs > fancy dicts

#

yeah but i don't have host

cloud dawn
#

I'd use mongo if I'm coding in js.

cloud dawn
slate swan
#

idk how to start it on heroku

cloud dawn
#

replit supports sqlite

#

With aiosqlite basically a decent db

slate swan
#

🚶‍♂️ no, replit reverts the data, so you may find your data disappearing many times

left idol
#

in pycord,

    await ctx.defer()
    discordID = player.id
    robloxuser = bloxlink(discordID)
    if discordID in [92786442891169792, 897929889586507828, 556536867072245780]:
        a = 90
        b = 99
    elif discordID in [301480016657776642, 817386765874626571, 476537128428371970]:
        a = 0
        b = 10
    else:
        a = 35
        b = 99

    Spiking = np.random.randint(a, b)
    if Spiking <= 60:
        sgem = ":Bruh:"
    elif Spiking <= 70:
        sgem = ":Amethyst:"
    elif Spiking <=80:
        sgem = ":Sapphire:"
    elif Spiking <=94:
        sgem = ":Ruby:"
    elif Spiking >=95:
        sgem = ":Diamond:"
    embed = discord.Embed(title = "STATS", description = f"<@{discordID}>", color = discord.Color.blue())
    embed.add_field(name = "Spiking", value = f'{Spiking} {sgem}', inline = True)
    await ctx.followup.send(embed=embed)```
im currently trying this command but my embed isn't working? is something wrong with the way i defined a and b?
cerulean folio
#

guys I have a question:
Let's say I make a bot that's on a server, and it's very often used.
What's your techniques to run tests and updates on it, without shutting it down for a long time?
Like... github?

left idol
#

i tried the if discordID separately and it gives the right a and b

slate swan
#

at least that's what I would do

cloud dawn
#

As for the tests you could then just make a separate cog for developer commands.

cloud dawn
#

Coding a stable base is really hard tough so I recommend coding it until you are 100% certain you don't need to add anything more.

cerulean folio
cloud dawn
#

You can also keep a tracker on the Discord status site and update the base if there as a major outage. Using automated git solutions.

cerulean folio
#

when I create functions.py and run from functions import * in main.py it still says function doesn't exit

cerulean folio
cloud dawn
cloud dawn
cerulean folio
#

oh I googled it OK

short silo
#

If i do something like

ctx.response.send_message(file=file)

and then

ctx.response.edit_message()

how can i make the file disappear ?

cloud dawn
#

file=None

short silo
#

doesnt work

cloud dawn
#

delete

#

Why would you want to remove an embedded file anyways?

short silo
short silo
cloud dawn
#

You could try to clear attachments

#

ctx.response.edit_message(attachments=None)

short silo
#

NoneType object is not iterable, it says

cloud dawn
#

Send an empty iterable.

short silo
#

ok, thanks works

slate swan
#

        Premium = []
        Free = []
        Booster = []
        types = ['Premium', 'Free', 'Booster']

        for type in types:
            dictionary = f'./alts/{type}'
            if os.listdir(dictionary):
                print('true')
            elif not os.listdir(dictionary):
                types.remove(type)
        try:
            for type in types:
                dicti = f'./alts/{type}'
                if os.listdir(dicti):
                    for file in os.listdir(dicti):
                        if file.endswith('.txt'):
                            type.appennd("stuff")
        except:
            pass
            #not for now```
well yeah since type is a string whats a alternative way i can do that?
cloud dawn
dim sentinel
#
new=None

@spi.event
async def on_message_edit(before,after):
    global old
    global new 
    old=before.content
    new=after.content


@spi.command()
async def editsnipe(ctx):
    if new is None:
        em=discord.Embed(title="Edit snipe",color=discord.color.from_rgb(255, 234, 0))
        em.add_field(name="No edited messages found",value="L")
        await ctx.send(embed=em)

    else:
        em=discord.Embed(title="Edit snipe",color=discord.color.from_rgb(255, 234, 0))
        em.add_field(name=f"Before: {old}",value="",inline=False)
        em.add_field(name=f"Before: {new}",value="",inline=False)
        await ctx.send(embed=em)
#

help~

spring flax
#

what's spi?

dim sentinel
slate swan
regal pulsar
vale wing
vocal plover
dim sentinel
#
old_messages=None
new_messages=None
author=None

@spi.event
async def on_message_delete(before,after):
    global old_messages
    global new_messages
    global author
    old_messages=before.content
    new_messages=after.content
    author=after.author.id


@spi.command()
async def editsnipe(ctx):
    if old_messages is None:
        await ctx.send("> :x: There is nothing to snipe")

    else:
        em=discord.Embed(title="Edit snipe",color=discord.Color.from_rgb(255, 234, 0))
        em.add_field(name=f"Before: {old_messages}",value="",inline=False)
        em.add_field(name=f"After: {new_messages}",value="",inline=False)
        await ctx.send(embed=em)
``` why doesnt this work now
cloud dawn
vale wing
dim sentinel
vale wing
#

Don't get what for do you need to call the command to update contents of the sniped message

cloud dawn
#

Why not use OOP and a dict to solve this matter.

vale wing
#

You can just declare some global variable that stores the last deleted message

#

And yeah deleted messages can't get edited

dim sentinel
# vale wing And yeah deleted messages can't get edited
old_messages=None
new_messages=None
author=None

@spi.event
async def on_message_delete(before,after):
    global old_messages
    global new_messages
    global author
    old_messages=before.content
    new_messages=after.content
    author=after.author.id


@spi.command()
async def editsnipe(ctx):
    if new_messages is None:
        await ctx.send("> :x: There is nothing to snipe")

    else:
        em=discord.Embed(title="Edit snipe",color=discord.Color.from_rgb(255, 234, 0))
        em.add_field(name=f"Before: {old_messages}",value="",inline=False)
        em.add_field(name=f"After: {new_messages}",value="",inline=False)
        em.set_footer(text=f"requested by {author}")
        await ctx.send(embed=em)```
#

what about this

#

OH

vale wing
#

M hold up

#

Too many useless variables

dim sentinel
#

wait

dim sentinel
#

no no

#

i used on_message_delete

#

got my mistake

vale wing
#

Understandable

#
sniped_message: discord.Message | None = None

@bot.listen()
async def on_message_delete(msg: discord.Message):
    global sniped_message
    sniped_message = msg```
dim sentinel
vale wing
dim sentinel
#

I mean i wanna make a command

vale wing
#

Like what is that command supposed to do

vocal plover
dim sentinel
#

like i edited this message

#

i want to use the command

#

and get the previous thing

vale wing
#

So you want to store different versions of the message or smth

dim sentinel
#

the old message

fiery sphinx
#

How do I write a code bot keep it messages and ignores and downgrades user messages?

vale wing
# dim sentinel the old message

You should use some more complex structures than a variable. For example, create a dict with messages ids as keys and lists of messages contents as values and modify it in on_message_edit

stray adder
#

Any kind hearted legend coder pls help me to make meme bot

cloud dawn
vale wing
fiery sphinx
#

i'll send a video

cloud dawn
fiery sphinx
stray adder
vale wing
#

@fiery sphinx ok do you have python knowledge

stray adder
vale wing
#

I like how they rate their knowledge in percents

#

It's not a relative value dude

stray adder
#

Help

alpine cove
#

yea i didnt get it

vale wing
#

Can only suggest going to github and looking up

alpine cove
#

you may translate this vid

cloud dawn
# dim sentinel i see

More specifically OOP using a dict structure json { 267624335836053506: { 343944376055103488: { 169790484594556928: { "message": "Hello World" } } } } first id being the guild -> channel -> member

fiery sphinx
stray adder
cloud dawn
# stray adder

This code is as old as Discord itself almost. pass_context is deprecated for 4 years now.

vale wing
# fiery sphinx how bot can do it ?

So basically it listens for incoming websocket GUILD_MESSAGE events and checks the author id, if it doesn't match the given one it sends DELETE request to certain discord API endpoint (very easy explanation)

vale wing
#

Oh mo

fiery sphinx
#

i need code it

#

for my bot

cloud dawn
stray adder
cloud dawn
# fiery sphinx this so hard for me

Basically he/she is saying to check if someone send a message in the channel, if so delete the embed and re-post it. Do recommend some kind of rate limiter.

cloud dawn
#

I'm sorry but I can help solve coding related issues not how to install a bot.

stray adder
stray adder
cloud dawn
# stray adder Nop

Nextcord is basically the whole bots foundation, so unless you coded blindly without running the bot ever, this is hard to believe.

vale wing
#

Can't relate copypasting from not own projects

fiery sphinx
cloud dawn
dusky pine
#

seen too many discord bot skids

stray adder
fiery sphinx
# cloud dawn What part exactly is difficult/ don't you understand?
@client.event
async def on_message(message):
    if message.channel.id == 985883879825084446:
        if message.author.id == 977872735566987264:
            pass
        else:
            embed=discord.Embed(title=f"", description=f"{sos}", color=discord.Color.random())
            embed.set_author(name="EliteShop", icon_url="https://cdn.discordapp.com/icons/977827106337742858/2c99f79fa92ddb74d118e118efd28466.png?size=1024")
            embed.set_thumbnail(url="https://cdn.discordapp.com/icons/977827106337742858/2c99f79fa92ddb74d118e118efd28466.png?size=1024")
            embed.set_footer(text="Shop")
            bb = await message.channel.send(embed=embed)
            if message.author.id == 977872735566987264:
                pass
            else:
vale wing
dusky pine
cloud dawn
# stray adder Nop

You don't need to convince me, I'm asking you if you have a code related error.

cloud dawn
dusky pine
#

Honestly, just get a database like MongoDB or PostgreSQL and 90% of skids are not gonna be able to set it up

vale wing
#

Removed some files and gave no setup instructions

vale wing
dusky pine
vale wing
cloud dawn
vale wing
#

And it just describes bot's commands

dusky pine
#

Oh nice

stray adder
dusky pine
#

well non-skids can just read the errors and see you have to set a db up

#

seems good

vale wing
#

They might have issues with parsing environment variables next

dusky pine
#

hopefully you put .env in gitignore

cloud dawn
vale wing
#

Nah I use github secrets

dusky pine
vale wing
#

Very convenient thing tbh

fiery sphinx
# cloud dawn This is a good start, what is not working?

I can not fully explain what I mean, but I want when the first time someone wrote a message in a channel to send us a message, and the second time another user wrote a message, the previous bot message will be deleted and the same message will come and be sent above the second user.

vale wing
cloud dawn
dusky pine
cloud dawn
vale wing
#

So basically yml file that contains instructions for a runner to do

cloud dawn
dusky pine
#

oh ok

vale wing
#

And those workflows can get the values of github secrets and parse them as environment variables (or in some other conditions)

maiden fable
#

Anyone ever got this before?

fiery sphinx
# cloud dawn So you result in having 2 messages?

No no, infinitely, my idea is that every user in the channel writes a text and the next text is a continuation of the previous text and is a kind of fictional story, and in this section, the bot text should remain on the top page of the channel (like the video)

vale wing
#

Why tf is my internet slow now

cloud dawn
#

Github actions/ workflows only is efficient if you work in groups tough. I personally have never used it for personal projects.

vale wing
#

Nvm that's probably discord issues

vale wing
cloud dawn
vale wing
#

All of my workflows do though is just docker-compose up --build

fiery sphinx
# cloud dawn Yeah so then with this code, what exactly isn't working?

The first message that the user sends, the bot writes its message above his head, and in the second step, when another user sends a message, the bot must delete its previous message and place the same previous message on top of the new user, so a loop Infinity is created and I need to find a way for the bot to automatically advance from step 2 automatically.

vale wing
#

But still I only need to press one button instead of doing a sequence of actions

fiery sphinx
#
2 Bot : hello
3 New user : hi
4 (2).delete , Bot : hello
5 New user : hi
6 (4).delete , Bot : hello

```Like This

@cloud dawn
cloud dawn
dusky pine
maiden fable
#

Nice

dusky pine
#

all thanks to our sponsor NordVPN

cloud dawn
# fiery sphinx yes

I recommend using OOP, I don't really see another solution without using ugly global method.

heady sluice
#

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

fiery sphinx
alpine cove
cloud dawn
heady sluice
#

botvars > global vars

vocal plover
# unkempt canyon

this should probably be changed to subclassing the bot and adding attributes that way tbh

fiery sphinx
dusky pine
#

no intellisense = bad method /j

vocal plover
cloud dawn
vocal plover
#

because the same thing that intellisense uses is what reasons about your code and tells you if it's wrong

heady sluice
#

subclassing Bot and adding attributes that way, you're still making botvars

alpine cove
heady sluice
dusky pine
vocal plover
#

you're making botvars but in a way that a linter or language server can reason about

alpine cove
dusky pine
fiery sphinx
#

i have an shop

alpine cove
#

go on

fiery sphinx
#

and i want create my bot

#

for automatically buying

dusky pine
heady sluice
cloud dawn
#

Please stop this conversation, if someone is doing something against the ToS or CoC against this server or Discord please inform @novel apex.

dusky pine
#

does CoC mean clash of clans

cloud dawn
#

Code of Conduct.

dusky pine
#

oh

alpine cove
#

lol

dusky pine
#

sounds like a lame game

heady sluice
fiery sphinx
#

i need a code for bot get waiting for user send a message in a channel

dusky pine
#

wait for message to be sent in that channel?

#

!d discord.Client.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

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

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

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

This function returns the **first event that meets the requirements**...
dusky pine
#

no i'm not writing it for you

fiery sphinx
#

await client.wait_for("message") ?

dusky pine
#

Yep

fiery sphinx
#

um

#

this not working for me , cuz bot ignore it

dusky pine
#

don't know, that's the proper usage /shrug

#

what are your intents?

cloud dawn
#

A on message event is just fine.

dusky pine
#

ok

#

if that's really what he needs, there's no way this guy isn't a skid

#

you have to know what events are

fiery sphinx
dusky pine
#

are you sure you called it before the message is sent

shrewd apex
#

wdym by ignore u get no traceback?

#

why don't u just make a command which user uses to buy from shop?

#

like !buy apple

vocal plover
#

felt a bit too long to be a bot tag tbh

dusky pine
#

i've seen this tutorial before

shrewd apex
dusky pine
#

hey i saw this while looking (googling) for cogs

#

i think

fiery sphinx
#

@dusky pine

cloud dawn
vocal plover
#

most of the site is for beginners rn

#

the tips section especially is just for whoever needs the specific thing, it's not really skill-assessed

cloud dawn
vocal plover
#

the thing with that is I wanted to keep it lib agnostic

cloud dawn
#

Message could be confusing for starters.

cloud dawn
vocal plover
#

it does, stuff like command_prefix, guild_ids, help_command

cloud dawn
#

Those are keyword arguments

vocal plover
#

oh right you mean posargs

#

no it doesnt, but *args **kwargs is just the standard

cloud dawn
#

So you wouldn't need *args in ```py
class MyBot(commands.Bot):
def init(self, *args, **kwargs) -> None:
super().init(*args, **kwargs)

    self.last_message: Optional[Message] = None

...

fiery sphinx
dusky pine
cloud dawn
vocal plover
#

I'm trying to but I need to move literally everything around because the way dpy does app commands is so vastly different to nextcord and disnake that I can't just make separate tabs for each of them anymore because a lot of shared explanation doesnt work

cloud dawn
vocal plover
#

It's unnecessarily complex because you're never going to have multiple command trees on one bot, so why have it detached from the bot

cloud dawn
#

The fact you need to sync application commands yourself adds so much to this and the forced Client or Bot usage. Both having major downsides.

cloud dawn
vocal plover
#

lol, syncing commands myself is the bit of it i do like

#

I despise when auto sync is enabled by default because if I quickly need to run another bot on the same token I dont want to wipe all my global app commands

cloud dawn
cloud dawn
vocal plover
#

yeah

#

the issue is slash commands are an inherently worse dev experience than message commands

#

there's basically no way to do them in a way that doesnt suck for one reason or another

cloud dawn
slate swan
#

If someone has a status with a Spotify thingy playing, how'd I get to check which song is playing?

unkempt canyonBOT
#

property activity```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.

Note

Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [GH-1738](https://github.com/Rapptz/discord.py/issues/1738) for more information.

Note

A user may have multiple activities, these can be accessed under [`activities`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.activities "discord.Member.activities").
slate swan
cloud dawn
#

returns Optional[Union[BaseActivity, Spotify]]

#

!d discord.Spotify

unkempt canyonBOT
#

class discord.Spotify```
Represents a Spotify listening activity from Discord. This is a special case of [`Activity`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Activity "discord.Activity") that makes it easier to work with the Spotify integration.

x == y Checks if two activities are equal.

x != y Checks if two activities are not equal.

hash(x) Returns the activity’s hash.

str(x) Returns the string ‘Spotify’.
slate swan
alpine cove
#

what r u guys doing?

slate swan
#

!d disnake.Member.activities

unkempt canyonBOT
#

The activities that the user is currently doing.

Note

Due to a Discord API limitation, a user’s Spotify activity may not appear if they are listening to a song with a title longer than 128 characters. See #1738 for more information.

alpine cove
#

activities sure

slate swan
#

Can we have the bot listening to a song?

cloud dawn
haughty nova
#

Hello, I want to do a discord bot that is connected to my minecraft server but not actually connected. I want to make a command that when you want to ban someone ingame then you should go into discord and write !ban player reason and if its their first time being banned ingame it should write "Ban the player for 7 days" but if its the second time it should write "Ban the player for 14 days" and if its the third time it should write "ban the player for forever"

import discord
from discord.ext import commands

TOKEN = "Token"

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

@bot.command()
async def ban(ctx):
    await ctx.send("Du har bannet")

bot.run(TOKEN)```

and I am really new to python so I want help with how i should write it
slate swan
cloud dawn
cloud dawn
slate swan
#

Sadge.

cloud dawn
# haughty nova lmao good luck

I can do it like that since I host the bot myself with portforwarding, if you are using a host you will most likely need to making a custom java plugin.

#

And using an API as a bridge.

slate swan
cloud dawn
haughty nova
slate swan
cloud dawn
narrow grail
#

Ignoring exception in on_connect Traceback (most recent call last): File "/home/runner/ko/venv/lib/python3.8/site-packages/discord/client.py", line 382, in _run_event await coro(*args, **kwargs) File "/home/runner/ko/venv/lib/python3.8/site-packages/discord/bot.py", line 1041, in on_connect await self.sync_commands() File "/home/runner/ko/venv/lib/python3.8/site-packages/discord/bot.py", line 643, in sync_commands registered_guild_commands[guild_id] = await self.register_commands( File "/home/runner/ko/venv/lib/python3.8/site-packages/discord/bot.py", line 472, in register_commands prefetched_commands = await self.http.get_guild_commands(self.user.id, guild_id) File "/home/runner/ko/venv/lib/python3.8/site-packages/discord/http.py", line 353, in request raise Forbidden(response, data) discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access How to fix this?

upbeat otter
cloud cairn
#
@client.event
async def on_message(msg):
    if msg.author == client.user:
      return

    if msg.content == '!image ' + file:
      file = ''
      embed=discord.Embed(title='image', url="", description="Loading...", color=0x4ccfb2)
      await channel.send(embed=embed)
      await channel.send(file=discord.File(dir+'/'+file))
      print('Images: ', file)

Trying to make my bot send a specific photo from my ./images directory, but doesn't want to work.
Could use some help right about now

cloud cairn
#
dir = "./images"```
cloud dawn
#

I don't recommend renaming a function to another object.

maiden fable
#

Imagine doing that in C# 👀

cloud dawn
maiden fable
cloud dawn
cloud cairn
#

couldn't make it work before

#

it was spitting out permission errors, even if i ran the code as admin

upbeat otter
#

ghost ping smh

cloud dawn
cloud cairn
#

pretty new to python

maiden fable
cloud dawn
maiden fable
#

U using Android app when u saw the ghost ping?

cloud dawn
maiden fable
#

For some reason I also get ghost pings but apparently that's an app bug

#

Ah okay,

cloud dawn
maiden fable
#

Yup

cloud cairn
#

someone?

alpine cove
#

it mixes guilds, dms and other guild‘s channels up

cloud dawn
alpine cove
#

lmao

alpine cove
# cloud cairn What?

imagine getting a message by user#1234
discord will show a notification(lile this red dot) for both the dm with the user and some random guild

#

if you then go ahead and open that guild you will see ur dm with that user

upbeat otter
#

another ghost ping....wtf

alpine cove
cloud cairn
#

Well im not getting any ghost pings :/

upbeat otter
#

I swear I haven't visited this channel for 6 months and it's still the same. Basic python problems and ot talks

alpine cove
alpine cove
cloud cairn
cloud dawn
stray adder
#

Anyone help me..........

upbeat otter
alpine cove
#

ive been experiencing multiple bugs pn mobile recently

#

*on

maiden fable
alpine cove
upbeat otter
#

Hunter and Panda

alpine cove
upbeat otter
cloud dawn
stray adder
upbeat otter
#

and spoon-feed seekers....

stray adder
#

Aysheri....

cloud dawn
slate swan
#

saitamaOK i didn't even get the ghost ping, discord hates me

stray adder
#

i tried to make a meme bot but full of error i will give you replt link can u fix it for me

slate swan
#

indeed

stray adder
slate swan
#

the error pretty much tells you

stray adder
#

Thats only

slate swan
#

snippet

stray adder
slate swan
stray adder
#

@commands.command(aliases=["memes", "r/memes", "reddit"])
async def meme(self, ctx, subred="memes"):
msg = await ctx.send('Loading ... :Loading:')

    reddit = praw.Reddit(client_id='ID',
                         client_secret='SECRET',
                         username="USERNAME",
                         password='PASSWORD',
                         user_agent='AGENT')

    subreddit = reddit.subreddit(subred)
    all_subs = []
    top = subreddit.top(limit=350)

    for submission in top:
        all_subs.append(submission)

    random_sub = random.choice(all_subs)

    name = random_sub.title
    url = random_sub.url

    embed = Embed(title=f'__{name}__', colour=discord.Colour.random(), 
                  timestamp=ctx.message.created_at, url=url)

    embed.set_image(url=url)
    embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url)
    embed.set_footer(text=f'Bot')
slate swan
stray adder
#

Ok

#

Its been two days trying this😅

maiden fable
cloud dawn
short silo
#
@bot.event
async def on_message(Message : discord.Message):
    print(Message.content)

I am getting an empty string through this, what might be wrong

maiden fable
maiden fable
#

And sarth

#

And okimmi

cloud dawn
#

True, 26th of juli is my 2 year anniversary here.

maiden fable
#

And Hunter

#

And andy

alpine cove
cloud dawn
alpine cove
#

so this shouldnt affect me at all

cloud dawn
#

Mina got late to the game.

maiden fable
alpine cove
#

yea

maiden fable
cloud dawn
maiden fable
#

He left the server

cloud dawn
#

No he got banned.

maiden fable
#

Nvm he's here

#

@Caeden#7205

cloud dawn
alpine cove
maiden fable
#

He doesn't chat here anymore

cloud dawn
maiden fable
#

And yea, how can I forgot Robin!

cloud dawn
maiden fable
#

Robin the Helper

#

@Robin J#2415

cloud dawn
#

I will always see him as the guy who tried to combine py with js

cloud dawn
#

Unwritten rule hunter.

alpine cove
#

python script

#

thats actually a thing

#

wasnt py-script the browser version

cloud dawn
unkempt canyonBOT
maiden fable
#

Wait what the

alpine cove
maiden fable
maiden fable
cloud dawn
maiden fable
cloud dawn
#

But he was doing this api in js and wanted it to be the bridge between a dashboard and the bot.

vocal plover
#

My API is in Go, the bot in Python, and the site using Svelte kek

stiff fern
#
channel = discord.Client.get_channel(986468534391545976)
        await interaction.response.channel.send_message(embed=suggestion_embed)

Telling me I basically need id= but when I put id= it gives me another error w/ having positional arguments

cloud dawn
#

There is something you are not showing.

stiff fern
#

well I have response.channel.send_message bc Im trying to send it in a different channel

#
class suggestion(commands.Cog):

    def __init__(self, bot: commands.Bot) -> None:
        self.bot = bot

    @app_commands.command(name='suggestion', description='Submit a suggestion')
    async def suggestion(self, interaction: discord.Interaction):
        await interaction.response.send_modal(suggestion_modal())


class suggestion_modal(ui.Modal, title="Suggestion Prompt"):
    answer_one = ui.TextInput(
        label="Suggestion", 
        style = discord.TextStyle.short, 
        placeholder='Input the suggestion here', 
        required=True,
        min_length=10
    )

    async def on_submit(self, interaction: discord.Interaction):
        suggestion_embed = discord.Embed(
            title=self.title,
            description=f'**{self.answer_one.label}**\n{self.answer_one}',
            timestamp=datetime.now(),
            color=0x3f6782
        )

        suggestion_embed.set_author(name=interaction.user, icon_url=interaction.user.avatar)

        channel = discord.Client.get_channel(986468534391545976) # Need to fix this
        await interaction.response.channel.send_message(embed=suggestion_embed)

Are the classes

vocal plover
#

The error is you're using the Client type, not an instance of it, so you're passing the ID to the self parameter of the class method

stiff fern
#

oh so do I need to do self, id? or something

#

Or am I using the wrong type of client

cloud dawn
stiff fern
#

what's the old fashion way 🤔

cloud dawn
#

Hmm I'd pass the bot object with the modal class.

stiff fern
#

alrighty

#

Im still a noob so imma little slow

slate swan
#

!d discord.Interaction.client

unkempt canyonBOT
slate swan
#

@stiff fern use this ¯_(ツ)_/¯

stiff fern
#

so discord.client instead of discord.Client?

#

o

#

Well it says property has no attribute get_channel

upbeat otter
upbeat otter
upbeat otter
#

client is a property of the Interaction class

stiff fern
#

right and in the api is says get_channel is a property off Client so wouldn't I have to use discord.Client

#

I mean Ive tried that too and it didnt work either

#
discord.Interactions.client.get_channel

I have it w/ interactions.client

upbeat otter
#

you have to have an argument which acts as the interaction placed for that specific button in the callback

maiden fable
narrow grail
#

is it possible to send a direct message trough interaction.response?

cerulean folio
maiden fable
narrow grail
#

thanks

narrow grail
slate swan
narrow grail
maiden fable
#

!d disnake.Interaction.author

unkempt canyonBOT
maiden fable
#

@slate swan ^^^

stiff fern
#

how would you use Interaction.channel_id()

#

Like you put the channel in there but what purpose would it serve

upbeat otter
slate swan
#

lmao

slate swan
#

it'll just return the channel_id

regal pulsar
stiff fern
#

oh so it just returns something

regal pulsar
#

yeah

slate swan
regal pulsar
#

lmao

stiff fern
#

shrug setting a channel

stiff fern
#

Is there no way to send a interaction response in a specific channel because I can't find anything on it

slate swan
stiff fern
#

like being able to do
Interaction.response.send_message(embed=suggestion_embed, channel_id=986468534391545976)
would be nice

maiden fable
stiff fern
#

well it returns the response

slate swan
#

wut its actually the quite opposite, disnake changed it

stiff fern
#

oh I see what youre saying

maiden fable
#

Ig

slate swan
stiff fern
#

oo

slate swan
#

use http methods 😭

stiff fern
#

wouldnt http methods be more complicated

#

Oh no I did I just didn't include it since I didn't want to just post a wall of code cause then nobody would read it

slate swan
stiff fern
dull terrace
#

you can send a try except blank interaction response but its an extra api call

stiff fern
#

Oh nvm I see what youre saying cause I just saw it but I know how to fix it

slate swan
stiff fern
#

Oh its just skipping the extra step I see

slate swan
#

this may save you from getting a None as response from get_channel

stiff fern
#

Thank you 🙂

slate swan
#

huh?

stiff fern
#

😂

slate swan
#

fetch_channel makes an api call :)

stiff fern
#

If the channel gets remade and ID changes or something?

loud junco
#

hi

slate swan
stiff fern
#

So you'd use a try except for it

slate swan
#

send_message saves you from an api call if you're using fetch

slate swan
stiff fern
slate swan
#

payload.message_id

stiff fern
#

oh alright

heady sluice
#

😭

slate swan
#

in the code

#

fetch and send -
request 1 - getting the channel object
request 2- sending the message by entering the channel id in the endpoint

the http method directly uses the id in endpoint.

#

just re-read that snippet and youll see

#

i like Danny's GitHub avatar

#

imagine liking Danny himself 😔

heady sluice
#

no

slate swan
#

sus

maiden fable
#

What's x

slate swan
#
  • x does not have any key as message_id
  • learn how to spell
maiden fable
#

I agree on the folder name tho

slate swan
cloud dawn
#

I just noticed when you hover over the emoji when you want to select one it changes each time

slate swan
spring flax
#

is it possible to do embed.set_image with an image as a spoiler?

cloud dawn
slate swan
heady sluice
#

!d discord.Embed.set_image

unkempt canyonBOT
#

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

This function returns the class instance to allow for fluent-style chaining.
cloud dawn
#

Don't spoil it

heady sluice
#

hm

#

!d discord.File

unkempt canyonBOT
#

class discord.File(fp, filename=None, *, spoiler=..., description=None)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.

Note

File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
heady sluice
#

set spoiler=True here

heady sluice
slate swan
#

maybe that'll work

cloud dawn
#

||unsure||

heady sluice
#

women are getting more and more confusing to me everyday

slate swan
#

staph

cloud dawn
#

No means they definitely want it.

slate swan
heady sluice
#

tell reason

slate swan
#

all that kwarg does is attach SPOILER_ at the beginning of the filename, which appears as a spoiler on discord when uploaded

#

the set_image does nothing but uses that Attachment's link, which is not a spoiler in itself.

heady sluice
#

so you'd have to use the SPOILER_ when using set_image?

slate swan
#

wont work either, you can't spoil an image in Embed

heady sluice
#

that sounds cap

#

everything's possible you just gotta hack discord

slate swan
#

https://media.discordapp.net/attachments/343944376055103488/986656205629972560/SPOILER_IMG.jpg
url of this file, when you send this url it appears as normal image

maiden fable
#

U can set image as spoiler when the embed type is picture or smth

cloud dawn
maiden fable
# slate swan

I have read that somewhere. From where u got that?

heady sluice
#

I'm not able to try it out

unkempt canyonBOT
#

Virtual Environments

Virtual environments are isolated Python environments, which make it easier to keep your system clean and manage dependencies. By default, when activated, only libraries and scripts installed in the virtual environment are accessible, preventing cross-project dependency conflicts, and allowing easy isolation of requirements.

To create a new virtual environment, you can use the standard library venv module: python3 -m venv .venv (replace python3 with python or py on Windows)

Then, to activate the new virtual environment:

Windows (PowerShell): .venv\Scripts\Activate.ps1
or (Command Prompt): .venv\Scripts\activate.bat
MacOS / Linux (Bash): source .venv/bin/activate

Packages can then be installed to the virtual environment using pip, as normal.

For more information, take a read of the documentation. If you run code through your editor, check its documentation on how to make it use your virtual environment. For example, see the VSCode or PyCharm docs.

Tools such as poetry and pipenv can manage the creation of virtual environments as well as project dependencies, making packaging and installing your project easier.

Note: When using Windows PowerShell, you may need to change the execution policy first. This is only required once:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

maiden fable
#

Ah yea

slate swan
#

the bottom part

maiden fable
#

The heck is discum?

#

Also u can't ask for paid work

slate swan
#

discum is a selfbot library

#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

maiden fable
#

Ah

slate swan
#

can u for example set the cooldown after the async function?
like

    @commands.command()
    async def gen(self, ctx, accounttype):
     with open('cooldowns.json', 'r') as file:
        rere = json.load(file)
     @commands.cooldown(.)
stiff fern
#
channel = interaction.guild.get_channel(986468534391545976) or await interaction.guild.fetch_channel(986468534391545976)
        await interaction.response.send_message('Prompt submitted.', ephemeral=True)
        msg = await channel.send(embed=suggestion_embed)
        await msg.add_reaction('![Yes](https://cdn.discordapp.com/emojis/986643084718796810.webp?size=128 "Yes")')
        await msg.add_reaction('![No](https://cdn.discordapp.com/emojis/986643106835353691.webp?size=128 "No")')

        def check(reaction ,user):
            return str(reaction.emoji) == '![Yes](https://cdn.discordapp.com/emojis/986643084718796810.webp?size=128 "Yes")'
        
        reaction = commands.Bot.wait_for('reaction_add', check=check)
        if str(reaction.emoji) == '![Yes](https://cdn.discordapp.com/emojis/986643084718796810.webp?size=128 "Yes")':

Trying to figure out how to have it check when new reactions are added to a message but its saying I'm missing the event argument but I have it as reaction_add

#

unless im missing something else

velvet compass
#

!rule 5 9 Please don't ask for help with this type of project, and don't offer to pay people.

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

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

sick birch
slate swan
#

oh damn this command can include multiple rules at a time

stiff fern
#

oh alright

sick birch
#

If you dont it assumes that the first argument is the instance

stiff fern
paper sluice
#

U r still using ids lemon_pensive

sick birch
#

If you followed a YouTube tutorial it’s probably going to be called “client”, if you didn’t, it’ll probably be called “bot”

slate swan
#
class Counter(discord.ui.View):


    @discord.ui.button( label='0', style=discord.ButtonStyle.red, row=1)
    async def count(self, interaction: discord.Interaction, button: discord.ui.Button):

        await interaction.response.edit_message(view=self)

    @discord.ui.button(label='0', style=discord.ButtonStyle.red, row=1)
    async def count1(self, interaction: discord.Interaction, button: discord.ui.Button):
        number = int(button.label) if button.label else 0

        button.label = str(number + 1)

        await interaction.response.edit_message(view=self)

Dear, please tell me how to make the button can be pressed only by the one who entered the command?

cloud dawn
rocky hornet
#

whats the best way to dynamically add a cog-aware command?

paper sluice
#

What's cog aware command

rocky hornet
#

command that has .cog set correctly

#

Bot.add_command doesnt do that

paper sluice
#

Oh

rocky hornet
#

i'd imagine Cog.add_command to exist

#

but ofc danny didnt think about that

stiff fern
# sick birch If you followed a YouTube tutorial it’s probably going to be called “client”, if...

Well I have it named bot but I guess its not in the same scope as the class I'm trying to use it in so am I able to pass it in when I call the class?

Like if I did? I mean this wouldn't work but that's what I would think

class suggestion(commands.Cog):

    def __init__(self, bot: commands.Bot) -> None:
        self.bot = bot

await interation.response.send_modal(suggestion_modal(bot))

class suggestion modal(bot, ui.Modal, title="Suggestion Prompt"):
  #Need to access bot here

async def setup(bot: commands.Bot) -> None:
    await bot.add_cog(
        suggestion(bot),
        guilds=[discord.Object(id=981034070421155850)]
    )
slate swan
slate swan
#
class Counter(discord.ui.View):


    @discord.ui.button( label='0', style=discord.ButtonStyle.red, row=1)
    async def count(self, interaction: discord.Interaction, button: discord.ui.Button):

        await interaction.response.edit_message(view=self)

    @discord.ui.button(label='0', style=discord.ButtonStyle.red, row=1)
    async def count1(self, interaction: discord.Interaction, button: discord.ui.Button):
        number = int(button.label) if button.label else 0

        button.label = str(number + 1)

        await interaction.response.edit_message(view=self)

Dear, please tell me how to make the button can be pressed only by the one who entered the command?

paper sluice
slate swan
slate swan
#

private self lmao

slate swan
paper sluice
#

One letter variable names = good

slate swan
paper sluice
slate swan
paper sluice
#

No, I don't really ever use it

slate swan
#

¯_(ツ)_/¯

quaint epoch
unkempt canyonBOT
#

A Discord API Wrapper for Userbots/Selfbots written in Python.

quaint epoch
#

damn

#

that's illegal

#

and the name is sus too

paper sluice
slate swan
#

@discord.ui.button( label='0', style=discord.ButtonStyle.red, row=1)
async def count(self, interaction: discord.Interaction, button: discord.ui.Button):
if self.author == interaction.user:
await interaction.response.edit_message(view=self)
else:
pass

maiden fable
slate swan
slate swan
#

nvm

maiden fable
slate swan
maiden fable
#

ah

paper sluice
#

it's user

slate swan
#

..

maiden fable
#

if interaction.user.id == interaction.client.owner_id

paper sluice
maiden fable
slate swan
#

hunter go to sleep

maiden fable
#

I mean, interaction.author returns the author of the command and client.owner_id returns the id of the owner of the bot

slate swan
#

It's 10 pm only

slate swan
slate swan
maiden fable
slate swan
#

class Counter(discord.ui.View):


    @discord.ui.button( label='0', style=discord.ButtonStyle.red, row=1)
    async def count(self, interaction: discord.Interaction, button: discord.ui.Button):
        if interaction.author.id == interaction.client.owner_id:
            button.label = "123"
            await interaction.response.edit_message(view=self)
        else:
            button.label = "321"
            await interaction.response.edit_message(view=self)

(((

#

only disnake has such alias

maiden fable
maiden fable
maiden fable
#

AH its a button

slate swan
slate swan
rose mountain
#

I made this randomizer bot recently

cerulean folio
#

I beg you guys someone help me structurate my code. The bot is working very well, but the code is sick, it's nested so much

maiden fable
slate swan
cerulean folio
#

I really need a mentor that could help me with it

stiff fern
#

graci

cerulean folio
#

💀

sick birch
#

You don't necessarily need to call a method on an instance, but things are a little bit different:

#

!e

print(int.__add__(1, 2))
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

3
sick birch
#

Same concept, different class

rose mountain
# slate swan Nice

I'm proud of it because I'm pretty sure I'm the first one to make a tf2 weapon randomizer as a discord bot

#

I've never seen it before even though I watch a channel who covers weapon randomizers

sick birch
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

3
sick birch
#

In this case python passes in the self variable automatically

rose mountain
#

I want to make it generate an image with the stats and weapon later

maiden fable
sick birch
#

All class methods can be called that way, with just the class

slate swan
sick birch
#

!e

class SomeClass:
  def __init__(self):
    self.x = "Hello, world!"
  def print_x(self):
    print(self.x)

instance = SomeClass()
SomeClass.print_x(instance)
unkempt canyonBOT
#

@sick birch :white_check_mark: Your eval job has completed with return code 0.

Hello, world!
sick birch
#

Really no need to be doing it, but I bet the esoteric folks like using it to make the code seem more esoteric-y

slate swan
#

never knew lmao

sick birch
#

Exactly yep

slate swan
#

god bless im not someone that does esoteric code

paper sluice
#

When u make classes ur basically manually setting attrs to the instance

sick birch
#

Because I believe calling a method like:

instance = SomeClass()
instance.some_method()

Is really just syntactic sugar for

instance = SomeClass()
SomeClass.some_method(instance)
#

not sure though, but the behaviour of operator overloading leads me to believe that

slate swan
slate swan
vale sierra
#
    @commands.command()
    async def balance(self, ctx, member:discord.Member = None):
        if member is None:
            self.member = ctx.author

    db = sqlite3.connect
    cursor = db.cursor()


    cursor.execute(f"SELECT wallet, bank FROM eco WHERE user_id = {member.id}")
    bal = cursor.fetchone()
    try:
        wallet = bal[0]
        bank = bal[1]
    except:
        wallet = 0
        bank = 0

    await ctx.send(f"Portefeuille -- {wallet}\n Banque -- {bank}")
``` This is the error i have with this part of code, i indent it so idk where it could be from, thanks for your help
slate swan
sick birch
#

Since there's no good reason to be doing it in the first place

vale sierra
sick birch
#

Indent everything from then on out up till the await ctx.send(...)

cerulean folio
vale sierra
slate swan
slate swan
sick birch
unkempt canyonBOT
slate swan
#
class Counter(discord.ui.View):


    @discord.ui.button( label='0', style=discord.ButtonStyle.red, row=1)
    async def count(self, interaction: discord.Interaction, button: discord.ui.Button):
        if interaction.user.id == interaction.guild.get_member(interaction.user.id):
            button.label = "123"
            await interaction.response.edit_message(view=self)
        else:
            button.label = "321"
            await interaction.response.edit_message(view=self)

If I click on the button, then it changes to 321, if a friend, then the same 321. Please tell me what is the problem

#

basically you can just ```bash
$python -m pip install black
$python -m black filepath

or

$python -m black . # to format your cwd

paper sluice
cerulean folio
#

wait what do u mean format my code?

#

what if it accidently messes it?

paper sluice
cerulean folio
#

I hate those things I'm traumatised XD

slate swan
cerulean folio
#

are you sure i have no risk of messing my code?

slate swan
sick birch
paper sluice
slate swan
#

just use interaction_check 😔

#

yoo anyone experienced with PY + Flask dm me really need help with parsing args

unkempt canyonBOT
#

7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.

slate swan
slate swan
#

bro what

#

its a python dc bot

#

with flask side

slate swan
#

still doesn't matter, read the channel topic

slate swan
#

nothing to do with web 0

#

flask isnt web-related, have a nice day ahead

sick birch
#

Not sure how you got flask and a discord bot to work side by side considering flask is blocking and discord.py is not, without threading of course

slate swan
#

i need to pass args from one route to another route

sick birch
cerulean folio
#

It's not what I meant by structuring the code

#

I meant splitting the project in multiple files

#

And avoid nested code and spaghetti

#

because I'm so struggling with async functions that I keep rewriting the same code many times

#

It could be lighter and more elegant

slate swan
cerulean folio
#

So I need someone experienced to like, guide me a little

unkempt canyonBOT
cerulean folio
#

But ig I won't find so, I'll try my best XD

slate swan
#

if youre dealing with messy code i would recommend to talk to someone noble or knowledgeable in python that can give suggestions and can help you with your problems and you should use black as its production standard.

slate swan
#
embeds.append(result_embed(user_data, dict({'sr_user' : await search_id(int(user_data['sr_id'])),'subject' : await search_id(int(user_data['subject_id'])),'reporter' : await search_id(int(user_data['reporter_id']))})))
``` can break this into diff lines
slate swan
slate swan
# slate swan author = ctx.author.id
class Counter(discord.ui.View):


    @discord.ui.button( label='0', style=discord.ButtonStyle.red, row=1)
    async def count(self, interaction: discord.Interaction, button: discord.ui.Button):
        if interaction.user.id == interaction.guild.get_member(interaction.user.id):
            button.label = "123"
            await interaction.response.edit_message(view=self)
        else:
            button.label = "321"
            await interaction.response.edit_message(view=self)
    @commands.command()
    async def counter(sefl, ctx: commands.Context):
        """Starts a counter for pressing."""
        await ctx.send('Press!', view=Counter())

no no, how to find out the id of the author of the second command and pass it to the first where is the button

slate swan
#

talk with sarth hes very smort

sick birch
#

If you want to access the author who ran the command, and you want to access that author inside of a view, you can pass it in like so:

class MyView(discord.ui.View):
  def __init__(self, *, author: discord.Member, ...):
    self.author = author
    ...
  async def interaction_check(...):
    # access the person who ran the command using `self.author`

@bot.command()
async def my_command(ctx: commands.Context, ...):
  view = MyView(author=ctx.author)
  ...

@slate swan (this was meant for you)

slate swan
slate swan
slate swan
# slate swan ?🥺

that check was the same as interaction.user.id == interaction.member.id
😔

#

see robin's example

#

nvm it does

shrewd apex
sick birch
#

mentions in embeds never ping

slate swan
#

^

slate swan
shrewd apex
slate swan
#

im trying to install discordpy 2,0 on pycharm, i installed git and it says there's no git in the path even tho i setup it in pycharm settings why?

sick birch
shrewd apex
#

ic

slate swan
sick birch
#

Can you show me what happens when you try it in pycharm?

shrewd apex
slate swan
slate swan
sick birch
# slate swan

🤔 it should be in your PATH if it works using command prompt

slate swan
#

just add it to the path if it isnt 😔

#

Use vsc

#

no

sick birch
slate swan
slate swan
slate swan
slate swan
# slate swan Use vsc

it should be personal preference if you are developing at the low level, pycharm is more hardcore kind

#

but usable by anybody, dont get me wrong

sick birch
#

Hmm not sure then, sorry my knowledge on Pycharm is limited and it's odd since you seem to have everything setup properly

slate swan
#

bruh man

#

restart pycharm

slate swan
paper sluice
slate swan
#

but i'll give it a shot again

shell wing
#
from discord_components import DiscordComponents, ComponentsBot, Button, SelectOption, Select
``` error :
```py

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

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ExtensionFailed: Extension 'try' raised an error: ImportError: cannot import name 'ComponentsBot' from 'discord_components' (/opt/virtualenvs/python3/lib/python3.8/site-packages/discord_components/__init__.py)

slate swan
#

Pycharm gives better performance?

slate swan
#

wait it is working

#

and inbuilt support for envs

#

bruhh

slate swan
#

pycharm is more for professional developers as it has more features compared to vsc, thats ash's point

#

features like?

slate swan
#

🙏

#

vscode has them too?

paper sluice
#

Pycharm specially made for python, vsc isn't

#

I hate typing on phone fml

slate swan
#

i prefer vsc tbh

slate swan
#

i dont find vsc lacking any feature pycharm has, lemme know if there's one.

paper sluice
slate swan
#

Pycharm doesn't even have extensions 💀

paper sluice
slate swan
#

they are called plugins

#

Yo tf

#

its ok lol

#

I called sarth by mistake

#

F mobil

paper sluice
#

Lol

slate swan
#

😍

slate swan
# slate swan 😳

sarth wouldve probably sent me a whole paragraph on why i shouldnt have called him

paper sluice
slate swan
#

There should be a confirm button

slate swan
stiff fern
#
def check(reaction ,user):
            return reaction.emoji

        reaction = await interaction.client.wait_for('reaction_add', check=check)
        if reaction.emoji == '![Yes](https://cdn.discordapp.com/emojis/986643084718796810.webp?size=128 "Yes")':
            print('Approved ')
            suggestion_embed.set_footer(text='Status: Accepted\n')
        elif reaction.emoji == '![No](https://cdn.discordapp.com/emojis/986643106835353691.webp?size=128 "No")':
            print('Rejected')
            suggestion_embed.set_footer(text='Status: Rejected\n')

So Im getting an error AttributeError: 'tuple' object has no attribute 'emoji' and it's referring to the first if statement but I don't have a tuple there so Im a bit confused

slate swan
slate swan
slate swan
slate swan
#

youre making him feel unimportant😢

#

..

sage otter
#

Day 42069 of waiting for Danny to release 2.0 already.

shrewd apex
slate swan
paper sluice
sage otter
slate swan
#

so contribute or else

sage otter
shrewd apex
#

lmao i read too many novels today

sage otter
#

it’s either dpy or hikari for me

slate swan
slate swan
slate swan
paper sluice
slate swan
sage otter
#

last solution seems rather reasonable ngl

slate swan
#

no diff

slate swan
slate swan
#

😩

#

i'd rather sleep

sage otter
#

it’s not the same if I’m not coding on my 42060x42069 megapixel 120 hz refresh rate monitor

slate swan
sage otter
#

So at school is impossible

slate swan
sage otter
slate swan
#

i need someone that understands me like pythons interpreter😔🙏

shrewd apex
#

i got goosebumps

slate swan
#

Hello!
How to do on_guild_join in cogs? (discord.py)

slate swan
shrewd apex
slate swan
shrewd apex
#

sad