#discord-bots

1 messages · Page 962 of 1

hoary cargo
#

well, disnake would be easier, meanwhile dpy maybe more stable, at least in the near future

cold sonnet
#

one thing people don't like about pycord is the effort

ashen notch
#

But I suppose lurking all the same

cold sonnet
#

which effort is not that much

ashen notch
#

Are they all at the same level of functionality as d.py yet?

hoary cargo
#

the pypi ver it is

cold sonnet
#

but pycord has voice receiving doesn't it

quaint epoch
ashen notch
#

Or is there still more work before they're in full parity?

quaint epoch
#

!d disnake.ext.commands.Bot

unkempt canyonBOT
#

class disnake.ext.commands.Bot(command_prefix=None, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

This class is a subclass of [`disnake.Client`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client") and as a result anything that you can do with a [`disnake.Client`](https://docs.disnake.dev/en/latest/api.html#disnake.Client "disnake.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.GroupMixin "disnake.ext.commands.GroupMixin") to provide the functionality to manage commands.
quaint epoch
#

why?

cold sonnet
ashen notch
#

Neat

cold sonnet
#

but I always think dpy is just more developed

#

and after the long break, they'll catch up

#

once....

hoary cargo
cold sonnet
#

it's cool tho

hoary cargo
#

yeah, that's why i said disnake it's easier, idk what was danny thinking about with that tree stuff when implementing slash

ashen notch
#

With more hands on the project now, I could see it getting cleaned up. For dpy I mean

#

Now that it's not solely Danny calling the shots

#

(unless he retook full control)

#

Laaaaaaaaaame

cold sonnet
#

danny has the most contact to discord out of all forks
I think he can see into the future

quaint epoch
ashen notch
#

If that was the case he'd be swapping more towards api calls

#

Like leaning into that more than some of the intents and stuff

quaint epoch
ashen notch
#

Exactly

quaint epoch
#

no more getting, only fetching

cold sonnet
#

discord doesn't allow that many

ashen notch
#

For now

cold sonnet
#

if discord would allow that many api calls, they wouldn't force slash commands onto us

#

they just wanna spare

ashen notch
#

Fair point

cold sonnet
#

did I say something stupid

quaint epoch
cold sonnet
#

nah I guess I didn't

ashen notch
#

No

#

Wait what?

cold sonnet
#

irony

ashen notch
#

Oh thank god

hoary cargo
#

how this makes sense? i mean, bro, that's contradictory

ashen notch
#

Haven't actually peeked at the slash command integration

quaint epoch
#

but most of my code does use api calls, i do use get occasionally say looping through members to unban for a temp ban command.

cold sonnet
#

Danny didn't like slash commands but that doesn't mean he'll make it harder so you don't use it

cold sonnet
#

right

hoary cargo
#

discord adding slash commands so devs will switch from classic prefix commands
danny just mixing them together and make slash commands dependent on the prefix commands mikedone that's quite stupid because in september the enforcement for message intent will kick in

quaint epoch
cold sonnet
#

but how do you use slash commands with multiple bots

cold sonnet
#

without prefixes

ashen notch
#

Sorry, bad joke

cold sonnet
#

you can't have the same command in two bots?

ashen notch
#

I think it'll list both commands, right?

quaint epoch
cold sonnet
#

maybe

ashen notch
#

Otherwise you'd have mad conflicts when another bot joins with a similar/same command

cold sonnet
#

let's ask him

hoary cargo
#

well, he hates slash commands anyway, that's why he quit the development first time lol

cold sonnet
#

I like it

hoary cargo
#

cursed

ashen notch
#

I don't.... HATE it

cold sonnet
#

I don't like how you make both embeds anyway

#

but Idk I just like it

#

maybe I'm too positive

hoary cargo
#

it should be illegal to like it

cold sonnet
#

wait... do famous bots have slash commands already?

hoary cargo
#

most of them

cold sonnet
#

it's been a while, they should

#

I haven't even seen a single one of them

hoary cargo
#

they didn't rewrite, they just added the slash commands on top of the prefix ones

#

since it's a moderation bot, most probably got the message intent

#

same for dyno and other popular bots

#

🗿 tbh, i kicked both dyno and mee6 from my servers and just coded my own custom moderation bot, now i feel free that i have absolute control

stuck oyster
#

Sorry, Is there a way to get a channel's topic

#

yes

unkempt canyonBOT
stuck oyster
#

alright

ashen notch
#

Eh, to a point

#

At least for us, being able to easily track infractions is not something we could live without

sick birch
#

No warn system just yet

ashen notch
#

Our infrastructure is pretty solid

#

And the Discord log is.... less than ideal

sick birch
#

Willing to bet that’s coming up soon

cold sonnet
#

Discord will never make a voice channel maker voice channel or a birthday system, my bot stays alive

hoary cargo
#

i have a log channel for everything lmao, deleted/edited messages, bad word time out, server edit (channels name, perms, roles) discord can't beat that yet gigachad

ashen notch
#

We broke it out to several

#

As well as a mod alerts channel further up the list

hoary cargo
#

audit log is bad

ashen notch
#

God we have so many channels..

#

So.... very... many

hoary cargo
sick birch
#

Overshoot so easily

ashen notch
sick birch
#

We should move them either all the way up top or all the way down bottom 😉

hoary cargo
#

the logs are pretty vague, for example with deleted messages, they show you they've been deleted, but not their content, or message editing

ashen notch
#

It would make it so much worse for us

ashen notch
sick birch
ashen notch
#

Very very handy when folks are spamming or dropping nsfw shit then deleting it real quick

hoary cargo
ashen notch
#

And it's not like we even hide it!

#

We don't obfuscate that we have this level of tracking

#

But folks just don't think about it

sick birch
#

And metricity is open source too isn’t it

ashen notch
#

I think so?

#

Let me double check

#

Logging them off-platform is (I think)

#

But we restrict it to just being tossed in that channel

fossil aspen
#

yo can someone help me with something
i need a cmd to remove everyone from a role so basically
;removerole and itll automatically remove everyone from the member role

ashen notch
#

Discord won't accept those logs for reporting, though

#

@fossil aspen Why?

#

Seems like it'd only be used for malicious purposes

fossil aspen
hoary cargo
ashen notch
#

True, but that's a level of GDPR hassle I'd rather not have to deal with

fossil aspen
sick birch
fossil aspen
fossil aspen
sick birch
#

You need the role object

#

If it's a command you can get that by typehinting to role

spring flax
#

Nevermind

hoary cargo
#

🗿 that's so cursed, imagine no cogs and all your code in your main file

sick birch
#

You can seperate them into files

fossil aspen
#

i just need the cmd made so i can copy nd paste yk

sick birch
hoary cargo
ashen notch
#

I'm also not overly comfortable with us just giving a command like that

#

It seems more likely to be used maliciously than usefully

fossil aspen
sick birch
#

If you decide to start learning (i encourage you to!), don't do youtube tutorials before you go down that rabbit hole

fossil aspen
#

i dont do that shit i just need it for event purposes

sick birch
#

!resources can get you started

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.

hoary cargo
ashen notch
#

Depends on the channel/presenter. We've got a couple channels earmarked in our resources that we trust

sick birch
spring flax
#

What's seo?

sick birch
#

And personally I find the whole medium of videos to be lackluster when it comes to learning

#

Search engine optimization. Doing certain things with your content to get it higher ranking

#

For example, putting a lot of random keywords into your descriptions to get your video hoisted in the search results

#

And also making long titles with lots of common words

flat solstice
dull terrace
#

what's the non-dumb way to check if 3 days has passed since the saved date wheeze

vale wing
#

Wth is this

flat solstice
vale wing
#

Use datetime module

manic wing
vale wing
#

It would be much easier

(datetime.now() - your_saved_date).days```
#

And you could store dates as timestamps

dull terrace
vale wing
#

Timestamp is actually a number

#

Seconds since epoch

dull terrace
#

just thinking how to store it in a db

#

blob or int?

vale wing
#

!e py from datetime import datetime print(datetime.now().timestamp())

unkempt canyonBOT
#

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

1649360091.528525
vale wing
#

In postgres you can just use TIMESTAMP type its convenient as heck

dull terrace
#

hmm okay thanks, ill give this a shot 7739monkathink

sick birch
#

I’m waiting for panda to finish the base infrastructure

cold sonnet
#

panda

#

the one liner guy

#

oh I know panda pretty damn well

stiff nexus
#

bots cant get changes in on_user_update if the user is bot.user? - like if the bot itself changes avatar or something the event wont pick up the data?

also:
if u have 2 on_connect event in 1 cog will both work?

manic wing
#

so as long as you have a different function name it will work just fine

slate swan
#

!e
print(poop)

unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | NameError: name 'poop' is not defined
slate swan
#

bruh

#

!e poop = "ok"
await ctx.send(poop)

unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 2
002 | SyntaxError: 'await' outside function
slate swan
#

???

#

!e poop = "ok"
ctx.send(poop)

unkempt canyonBOT
#

@slate swan :x: Your eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | NameError: name 'ctx' is not defined
manic wing
#

#bot-commands

slate swan
#

ok dude

stiff nexus
#

i had 2 on_connect events when the bot get connected only 1 event works

manic wing
#

¯_(ツ)_/¯

ember frigate
#

Hello everyone, I am trying to build a bot which buys new coins on gate.io, but I can't get the data from the website via request (or maybe I'm a bit dumb). Could anyone please help me?

stiff nexus
#

i dont get it

lofty pecan
#

Hi there, so I'm currently writing a bot, and I need him to take inputs from the user one after another. But for some reason it just spams the input messages and doesn't take what the user sends in

#
await ctx.send('Enter the description of the character: ')
desc = bot.wait_for('message', check=check, timeout=30)
await ctx.send(f"{name}'s description added")``` Imagine that I have several of this consecutively
#

and then I want to add those information in a dictionnary like this

with open(f'{name}.json') as file:
        content = json.load(file)  

    content[name] = {'age': age,
                     'gender': gender,
                     'picture': picture,
                     'hex': hex,
                     'desc': desc,
                     'universe': universe
                    } 

    await ctx.send('Character successfuly added to the database!')```
#

but as I said it seems to be broken

#

What I get is the following

#

so would anyone have an idea about what's going on?

#

and how to let the bot take the information in and store before moving on to the next question

median gale
#

man

#

i have 4 discord bots

#

that i was hosting on replit/uptimerobot

#

but now i see that uptime robot has stopped hosting replit servers

slate swan
median gale
#

so does anyone know where i can continue hosting my bots

#

for free?

slate swan
lofty pecan
#

I feel like hex is supposed to be an internal command

#

maybe that's why?

#

yeah still buggy

slate swan
lofty pecan
#

Command raised an exception: OSError: [Errno 22] Invalid argument: '<coroutine object wait_for at 0x000002BDCC9BD140>.json'

lofty pecan
slate swan
#
with open(f'{name}.json') as file:
        content = json.load(file)  

    content[name] = {'age': age,
                     'gender': gender,
                     'picture': picture,
                     'hex': hex,
                     'desc': desc.content,
                     'universe': universe
                    } 

    await ctx.send('Character successfuly added to the database!')```
lofty pecan
#

wh

#

what that's exactly what I typed

slate swan
lofty pecan
#

yes

#
with open(f'{name}.json') as file:
        content = json.load(file)  

    content[name] = {'age': age,
                     'gender': gender,
                     'picture': picture,
                     'hex': Hex,
                     'desc': desc,
                     'universe': universe
                    } 
slate swan
#

U typed {"desc" : desc} but it should be desc.content

lofty pecan
#

why?

slate swan
#

it will save the "message"

lofty pecan
#
await ctx.send('Enter the description of the character: ')
desc = bot.wait_for('message', check=check, timeout=30)
await ctx.send(f"{name}'s description added")
    ```
#

that's the description part

slate swan
#

Im talking abt the saving part

lofty pecan
#

okay but why .content

#

why just there?

slate swan
slate swan
lofty pecan
#

no it doesn't do anything

slate swan
lofty pecan
#

the bot just spams the input without letting me input anything

#

and with that weird coroutine stuff

slate swan
#

you have to await it

lofty pecan
#

how so

slate swan
#

or else it will return a coroutine object and not the return value of the coroutine

lofty pecan
#

I assume the with is the problem

slate swan
#

its not.

#

i already said the problem.

lofty pecan
slate swan
#

!d discord.ext.commands.Bot.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/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
lofty pecan
#

await what

slate swan
#

a coroutine

lofty pecan
#

okimii what do I have to await

#

HAAAAAA

slate swan
#

what is self.client

lofty pecan
#

I think I get it

slate swan
#

bro

slate swan
stuck oyster
lofty pecan
#

desc = await bot.wait_for('message', check=check, timeout=30) innit?

slate swan
lofty pecan
#

🥺

slate swan
lofty pecan
#

omg of course

stuck oyster
# slate swan so what is not working

Well, the full command is a transcript command. It is supposed to give a list of all the users that talked in the channel but only showed the user that used the command

slate swan
lofty pecan
#

well now it works

slate swan
#

lol

stuck oyster
lofty pecan
#

I just have this issue Command raised an exception: FileNotFoundError: [Errno 2] No such file or directory

slate swan
lofty pecan
#

lol

lofty pecan
slate swan
#

👍

lofty pecan
slate swan
#

Ohspeechless

lofty pecan
lofty pecan
ashen notch
#

Figure I'll ask again since it's a new batch of folks here. I'm wanting to make a server bootstrapping script. One that will let people give a server layout (categories, channels, roles, etc) as a script to make it easier to develop for a bot. I was wondering if anyone knew of a way to test something like that without having to actually make x number of guilds during testing. Rather not have to make a server, delete it, make a server, delete it, rinse and repeat. Anyone know of anything like that?
Something like a testing endpoint for this or a ready made Discord API mockup that you can test requests like this against

lofty pecan
#

welp I'm sorry but I don't know at all, I hope you'll find an answer

#

as you can see I don't know why my bot can't find a json file so this is beyond my level of expertise haha

slate swan
#

i expect a script and not a public bot.

ashen notch
#

Generates a guild based on a configuration file, yeah. I know how I'm going to do that bit (and yeah it's going to be a script)

#

It's just the testing I'm not stoked about

slate swan
#

ah

ashen notch
#

Since I don't want to be constantly making guilds and deleting them

slate swan
#

well im not quite sure on how i would be tested, i would suggest you check the developer portal and the idea seems limited to newer bots

ashen notch
#

Nah, the functionality has been around for creating guilds like this. At worst I might just have to mockup my own API to make sure I'm getting the right stuff but ehhhhh

slate swan
#

well testing it without actually making a request i doubt you could, searching for an endpoint that is for testing i doubt the api has one. the idea of running a script for developers seems idk limited as people are scared of token loggers and it would be limited to bots that are in 30 or less guilds iirc

ashen notch
#

It'd mostly be useful for us here on PyDis

#

It's so that people can set up a dev server for themselves when they fork the repo

#

Especially since our bot config has a fuck ton of channels that need to be made and IDs retrieved

slate swan
ashen notch
#

Yep, I know

slate swan
#

thats mostly what i would do.

stuck oyster
#

uh so

lofty pecan
#

okay so this is now the problematic code :

with open(os.getcwd() + f'\{database}.json') as file:
        content = json.load(file)  

    content[name] = {'age': age,
                     'gender': gender,
                     'picture': picture,
                     'hex': Hex,
                     'desc': desc,
                     'universe': universe
                    } 
    
with open(os.getcwd() + f'\{database}.json', 'w+') as file:
  json.dump(content, file)```
after asking the user for information I want to take the database file (`json file` with inside just `{}`) and add a key with the corresponding dictionnary inside but I feel like this won't work at all
#

and it's also not working, otherwise I would be here complaining haha

cloud dawn
unkempt canyonBOT
#

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

Creates a template for the guild.

You must have the [`manage_guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_guild "discord.Permissions.manage_guild") permission to do this.

New in version 1.7.
cloud dawn
#

!d discord.Template

unkempt canyonBOT
#

class discord.Template```
Represents a Discord template.

New in version 1.4.
lofty pecan
cloud dawn
#

Templates can easily create mock guilds without making for loops for channels etc.

lofty pecan
ashen notch
#

That's where most of the work is

lofty pecan
cloud dawn
ashen notch
#

And I'll likely be trying to send it as a single large post request when I create it.

The IDs for the generated channels and roles

cloud dawn
#

A template sends in everything at once and using discord.Guild.channels and discord.Guild.roles should give you every id.

ashen notch
#

Sure but I'm not planning on using dpy for this, just direct API calls.

cloud dawn
#

Oh yeah def.

lofty pecan
#

nice

#

Object of type Message is not JSON serializable that's nice

#

how is this not working:

with open(os.getcwd() + f'\{database}.json', 'r') as file:
  Content = json.load(file)  

                    
Content[f'{name}'] ={'age': age,
                        'gender': gender,
                        'picture': picture,
                        'hex': Hex,
                        'desc': desc,
                        'universe': universe
                        }             
with open(os.getcwd() + f'\{database}.json', 'w') as file:
  json.dump(Content, file)                

await ctx.send('Character successfuly added to the database!')
    ```
#

How

cloud dawn
#

You are putting a message object inside the dict

#

That's not allowed.

lofty pecan
#

:(

#

so

cloud dawn
#

Put in the id

lofty pecan
#
await ctx.send('Enter the value of the character (format is 0xFFFFFF): ')
value= await bot.wait_for('message', check=check, timeout=30)
``` I have to convert those to `str`?
cloud dawn
#

Fetch it if you need it.

dull terrace
#
if (time_stamp - self.date).days >= 1:
AttributeError: 'float' object has no attribute 'days'```

both made with
```python
datetime.now().timestamp()```
lofty pecan
#

haaaaa

dull terrace
vale wing
#

!d datetime.datetime.fromtimestamp

unkempt canyonBOT
#

classmethod datetime.fromtimestamp(timestamp, tz=None)```
Return the local date and time corresponding to the POSIX timestamp, such as is returned by [`time.time()`](https://docs.python.org/3/library/time.html#time.time "time.time"). If optional argument *tz* is `None` or not specified, the timestamp is converted to the platform’s local date and time, and the returned [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") object is naive.

If *tz* is not `None`, it must be an instance of a [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.tzinfo "datetime.tzinfo") subclass, and the timestamp is converted to *tz*’s time zone.
dull terrace
#

ahh okay thanks

lofty pecan
#

lemme test

cloud dawn
pliant gulch
#

Yea don't ^

#

You already have the object

dull terrace
cloud dawn
lofty pecan
#

haha another error

cloud dawn
#

Datetime objects are the only object you can store in a database.

dull terrace
cloud dawn
#

Then use timestamp lol

dull terrace
#

hmm can just do the conversion once when i take it out i suppose

vale wing
#

The best way to store datetime in sqlite is int timestamp cuz it takes the least memory

dull terrace
#

and put it in

cloud dawn
#

!d datetime.datetime.fromtimestamp

unkempt canyonBOT
#

classmethod datetime.fromtimestamp(timestamp, tz=None)```
Return the local date and time corresponding to the POSIX timestamp, such as is returned by [`time.time()`](https://docs.python.org/3/library/time.html#time.time "time.time"). If optional argument *tz* is `None` or not specified, the timestamp is converted to the platform’s local date and time, and the returned [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") object is naive.

If *tz* is not `None`, it must be an instance of a [`tzinfo`](https://docs.python.org/3/library/datetime.html#datetime.tzinfo "datetime.tzinfo") subclass, and the timestamp is converted to *tz*’s time zone.
vale wing
#

And the only better way is ||use another db that supports datetime||

cloud dawn
#

I mean nothing wrong with fromtimestamp

#

and timestamp - timestamp = amount of seconds

lofty pecan
#

and I just want to input

#

despite the .content

cloud dawn
lofty pecan
#

{"<Message id=the_id channel=<TextChannel id=the_id name='test' position=7 nsfw=False news=False category_id=the_id> type=<MessageType.default: 0> author=<Member id=the_id name='This is Chris' discriminator='1095' bot=False nick='ChrisZeThird' guild=<Guild id=the_id name='Chris & Bo' shard_id=None chunked=False member_count=39>> flags=<MessageFlags value=0>>": {"age": "19", "gender": "male", "picture": "url_pic", "hex": "0xffffff", "desc": "no desc lol", "universe": "life"}}

but I just want {"age": "19", "gender": "male", "picture": "url_pic", "hex": "0xffffff", "desc": "no desc lol", "universe": "life"} to be added

lofty pecan
#

how did I do that

cloud dawn
#

By force converting it to string

dull terrace
dull terrace
#

that's kind of wild. isn't it going to be way too long in 100 years froggy_chill

lofty pecan
#
with open(os.getcwd() + f'\{database}.json', 'r') as file:
        Content = json.load(file)  

                    
Content[f'{name}'] ={'age': age.content,
                        'gender': gender.content,
                        'picture': picture.content,
                        'hex': Hex.content,
                        'desc': desc.content,
                        'universe': universe.content
                        }             
with open(os.getcwd() + f'\{database}.json', 'w') as file:
        json.dump(Content, file)                

await ctx.send('Character successfuly added to the database!')```
cloud dawn
dull terrace
#

ablobsweats one day tho, one day

cloud dawn
#

I think after 2300 we will have a solution lol

lofty pecan
cloud dawn
# lofty pecan how so?

"<Message id=the_id channel=<TextChannel id=the_id name='test' position=7 nsfw=False news=False category_id=the_id> type=<MessageType.default: 0> author=<Member id=the_id name='This is Chris' discriminator='1095' bot=False nick='ChrisZeThird' guild=<Guild id=the_id name='Chris & Bo' shard_id=None chunked=False member_count=39>> flags=<MessageFlags value=0>>"

#

!d discord.Message

unkempt canyonBOT
#

class discord.Message```
Represents a message from Discord.

x == y Checks if two messages are equal.

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

hash(x) Returns the message’s hash.
dull terrace
#

year 2300 we will be using telekinesis instead of numbers froggy_chill

lofty pecan
#

huh

#

so the .content

#

is problematic

cloud dawn
cloud dawn
dull terrace
#

you gotta be doing something pretty wild to need atomic time

cloud dawn
boreal ravine
lofty pecan
dull terrace
cloud dawn
dull terrace
#

what old operating system is going to be running in 2038 though

narrow grail
#

anyone know how to use start? Everytime I want to use it, it says one positional argument is required: 'self'. Whenver I put it in (test.start(self)) it says 'self' is not definied

lofty pecan
boreal ravine
#

whats name;

lofty pecan
#

name is just a string

#
await ctx.send('Enter the name of the character: ')
name = await bot.wait_for('message', check=check, timeout=30)```
#

this

#

hold up

#

I'm an idiot

#

I forgot to add .content to name

#

idiot me

#

lol

boreal ravine
#

aren't we all sometimes

lofty pecan
#

sometimes yes

lofty pecan
#

see ya !

junior verge
#

Can you make the bot do something when someone adds it to their server

cloud dawn
#

!d discord.on_guild_join

unkempt canyonBOT
#

discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") joins a guild.

This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
narrow grail
#

anyone know how to use start? Everytime I want to use it, it says one positional argument is required: 'self'. Whenver I put it in test.start(self) it says 'self' is not definied

narrow grail
boreal ravine
narrow grail
# boreal ravine show me where your using test.start
async def test(ctx):
  if not minigame_queue:
    minigame_queue.append(ctx.author)
    return
  other_player = minigame_queue.pop(0)
  vs = Minigame(sbot, [ctx.author, other_player])
  geto = sbot.get_channel(other_player)
  await Minigame.start()```
boreal ravine
#

hm why do you need self?

narrow grail
boreal ravine
#

yea but why do you need self in the task

narrow grail
slate swan
narrow grail
#

or is there a other way @boreal ravine ?

torn sail
#

Remove self

#

From the task

flat solstice
#

so I have this function py async def guild_events(self, guild: Guild, event: str): embed = Embed( title="Guild {event.title}", timestamp=datetime.utcnow(), description=f"{guild.name} ({guild.id})", ) if event == "JOIN": embed.colour = Colour.green() if guild.id in self.bot.banned_guilds: await guild.leave() async with self.bot.pool.acquire() as conn: await conn.execute() elif event == "LEAVE": embed.colour = Colour.red() embed.set_footer(text=f"{len(self.bot.guilds)} servers") if self.bot.config.join_channel: await webhook_constructor(self.bot.config.join_channel, embed)which handles my guild events (such as on_guild_join and on_guild_remove), this func is outside of a class and yet I need to pull data from self.bot inside this func. Should I be passing the self of the actual event into the func like thispy @commands.Cog.listener() async def on_guild_join(self, guild: Guild): await guild_events(self, guild, "JOIN")or should I be importing my bot var from my main file and calling bot instead of self.bot?

sick birch
#

Just pass in bot if you need to

#

But honestly it's better to keep them seperate

flat solstice
sick birch
#

Yeah

#

Still don't really see why you have to mush them together

flat solstice
#

okay thanks for the help

flat solstice
#

So I've got big on type hinting (I think that's the right term) all my funcs including eventspy @commands.Cog.listener() async def on_message_delete(self, message: Message):and I want to type hint my on_bulk_message_delete event, would it just be py @commands.Cog.listener() async def on_bulk_message_delete(self, messages: list[Message]):

glacial echo
#

what do i need to do to host a bot on a raspberry pi

#

and is it feasible to have the bot send me a dm with any errors that happen rather than spitting them into console/printing to console?

#

what about making a command to actually relaunch the bot through dms

#

basically, what can i do to reach a functional product with ways remote control and tracking of issues

glacial echo
slate swan
#

annotations are all useless but are helpful

slate swan
#

!d discord.on_bulk_message_delete

unkempt canyonBOT
#

discord.on_bulk_message_delete(messages)```
Called when messages are bulk deleted. If none of the messages deleted are found in the internal message cache, then this event will not be called. If individual messages were not found in the internal message cache, this event will still be called, but the messages not found will not be included in the messages list. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.

If this occurs increase the [`max_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") parameter or use the [`on_raw_bulk_message_delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_bulk_message_delete "discord.on_raw_bulk_message_delete") event instead.

This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
slate swan
#

in docs its a list of message objects so yes youre correct, you should read docs or check src if you ever doubt types

slate swan
#

🤨 📸

flat solstice
slate swan
#

!pep 484 @flat solstice heres more info on typehints!

unkempt canyonBOT
#
**PEP 484 - Type Hints**
Status

Final

Python-Version

3.5

Created

29-Sep-2014

Type

Standards Track

flat solstice
#

thank you 👍

slate swan
#

❤️

#

How do i enable 2 fac auth in my account

#

Bot*

hushed galleon
torn sail
#

Is that a thing?

hushed galleon
#

yeah certain moderation permissions can be enforced by 2FA requirement in the server's moderation settings

#

if you check a permissions calculator like this https://discordapi.com/permissions.html you'll see them highlighted, but basically its kick/ban/administrator, and any most permissions starting with "Manage"

sick vale
#

How is it possible to make a DM group with discord.py?

#

I know how to send a DM to a single user but how is it possible to send to multiple users?

abstract kindle
#

Question: I currently sort through my mongo database to check for the top 5 users in the 'money' category

#

This is how I create my leaderboard for the top users in the server

#

How would I sort the top in 2 categories combined?

#

For example, in 'money' and 'bank'

#

I'm currently doing this

cursor = self.bot.db.find().sort("money", pymongo.DESCENDING).limit(6)
        top_users = await cursor.to_list(length=6)
slate swan
#

I am using:

def disable_all_buttons(self):
    for button in self.children:
      button.disabled = True

in my button class, though when I try to use self.disable_all_buttons() in my command class it doesn't work, but gives me no error. How can I disable a button from the command class?

hushed galleon
hushed galleon
slate swan
#

await interaction.message.edit dont work

#

and neither does await msg.edit("...", view=self)

hushed galleon
#

doesnt work as in NameError: name 'interaction' is not defined? or still no error

slate swan
#

one sec

#

doesn't give me an error

hushed galleon
#

does your view have an on_error?

slate swan
#

i have a command error handler

#

but not for the view

#

if x >= crashNum:
x = crashNum
viewOneInstance.x = round(x, 2)
self.disable_all_buttons()
await interaction.message.edit(view=self)
break
thats my code, I am making an econemy bot with a crash game

hushed galleon
#

hm i would suggest adding print statements across your view's code to see whats happening

hushed galleon
#

prints just before and after your if-statement might be a good place

slate swan
#

it seems to stop at self.disable_all_buttons()

#

i think

abstract kindle
#

Can anyone help me?

supple thorn
slate swan
#

how to unban user with dev id and username in discord py bot

hollow quarry
#

@supple thorn fyi, we don't allow that link because it's often dropped in a rude manner. if you need to express it, it's a lot more welcoming to say it yourself.

abstract kindle
#

scroll up maybe 1 scroll

#

see lol

#

this is why i ask, can anyone help me. I don't wanna spam my question, but when I ask, it goes silent lol

slate swan
stuck oyster
#

Is there a way to disable/enable buttons on discord

supple thorn
#

!d discord.ext.commands.Context.send

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

Sends a message to the destination with the content given.

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

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

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

the delete after kwarg

stuck oyster
slate swan
slate swan
abstract kindle
#

Question: I currently sort through my mongo database to check for the top 5 users in the 'money' category
This is how I create my leaderboard for the top users in the server
How would I sort the top in 2 categories combined?
For example, in 'money' and 'bank'
I'm currently doing this

cursor = self.bot.db.find().sort("money", pymongo.DESCENDING).limit(6)
        top_users = await cursor.to_list(length=6)
#

Here you go @supple thorn

stuck oyster
slate swan
#

bool for short

stuck oyster
#

ok so to enable would be disabled = False

slate swan
supple thorn
arctic gyro
#
@bot.command()
@commands.has_permissions(ban_members=True)
async def mute(ctx,member: discord.User,time: float = None ,*,reason=None):
  
  if reason == None: 
    reason = 'Spamming! '
  if time == None:
    time = 900
  
  await ctx.channel.purge(limit = 1)
  await member.timeout(duration=time,reason=reason)
  if time >= 60:
    timee = time/60
    rem = time % 60
    time2 = math.floor(timee)
    await ctx.channel.send(f"{member} has been silenced in the class for {time2} minutes and {rem} seconds because of {reason}")
    await member.send(f'You have been muted in ' + f'{ctx.guild.name}' + ' for ' + str(time2) + ' minutes ' + str(rem) + ' seconds because of ' + reason)
  else:
    await member.send(f'You have been muted in ' + f'{ctx.guild.name}' + ' for ' + str(time) + ' seconds' + ' because of ' + reason)
    await ctx.channel.send(f"{member} has been silenced in the class for {time} seconds because of {reason}")

Hi , can anyone tell if somethings wrong with this code cuz it aint workinng

slate swan
stuck oyster
#

is there a way to make a command that enables and disable it

abstract kindle
#

rip

slate swan
stuck oyster
slate swan
arctic gyro
stuck oyster
arctic gyro
slate swan
slate swan
arctic gyro
#

I heard from another guy that is should not be discord.User and should be disnake.User but discord-disnake isnt compatible

slate swan
#

nah

#

in this case it would be discord.Member if youre using dpy as the User class is a discord user and not a member of a guild which the Member class has the timeout method

arctic gyro
#

alright i'll try to change it to discord.Member
thx

stuck oyster
slate swan
#

bool should be a literal bool and children must be used as it returns a list of components in a view which then you index the list of components to disabled the button you want in this case.

stuck oyster
#

MyView.children[0].disabled = True

slate swan
#

if its your first component and you want to disable it that is so

#

but you would need to edit the view.

#

which probably is impossible

#

so the whole command is useless

stuck oyster
slate swan
#

afaik no

#

i think you could with a slash command im not sure

#

you could fetch the message and edit it with an interaction and send a new view with the current instance that has the button disabled idk

#

cant really try out sorry

abstract kindle
#

what is afaik

slate swan
#

as far as i know

abstract kindle
#

as far as you know what

#

just kidding 😛

supple thorn
#

was about to clown

sick birch
slate swan
slate swan
sick birch
#

no idea

slate swan
#

what does smh mean?

sick birch
#

¯_(ツ)_/¯

slate swan
#

😧

abstract kindle
#

Lol

heavy folio
#

is it wise to log command usages (logging.info) in on_command

sage otter
#

Why wouldn’t it be?

#

Especially since it’s for logging purposes

heavy folio
#

if i'd like to log it through a webhook to a discord channel, how would i do it (using the logging module)

hushed galleon
#

i think using the logging.handlers.QueueHandler with an asyncio.Queue and having a background task relay messages from it to your webhook would be a fair idea

#

assuming you dont log too much that is

heavy folio
#

im planning on sending it every 15 minutes
or when the length of list hits 30
then proceed to send it

heavy folio
hushed galleon
#

for batching your logs a MemoryHandler subclass would also be another option

heavy folio
#

hm is there a basic example?

#

!d logging.handlers.MemoryHandler

unkempt canyonBOT
#

class logging.handlers.MemoryHandler(capacity, flushLevel=ERROR, target=None, flushOnClose=True)```
Returns a new instance of the [`MemoryHandler`](https://docs.python.org/3/library/logging.handlers.html#logging.handlers.MemoryHandler "logging.handlers.MemoryHandler") class. The instance is initialized with a buffer size of *capacity* (number of records buffered). If *flushLevel* is not specified, `ERROR` is used. If no *target* is specified, the target will need to be set using [`setTarget()`](https://docs.python.org/3/library/logging.handlers.html#logging.handlers.MemoryHandler.setTarget "logging.handlers.MemoryHandler.setTarget") before this handler does anything useful. If *flushOnClose* is specified as `False`, then the buffer is *not* flushed when the handler is closed. If not specified or specified as `True`, the previous behaviour of flushing the buffer will occur when the handler is closed.

Changed in version 3.6: The *flushOnClose* parameter was added.
heavy folio
#

ty
also how do i add a handler if i used logging.basicConfig

hushed galleon
heavy folio
#

o

slate swan
#

The cog is loaded

slate swan
#

what?

supple thorn
slate swan
#

Its hastebin? lol

#

Maybe use this then

supple thorn
#

or all commands?

slate swan
supple thorn
slate swan
#

Well how do I make sure?

supple thorn
slate swan
#

I did

supple thorn
#

did it work

supple thorn
slate swan
#

No

supple thorn
slate swan
#

Actually wait, I do

supple thorn
#

okay

#

what does it say

slate swan
#

Well INFO: Loaded plugin: donators

#

Thats my cog name

supple thorn
slate swan
supple thorn
slate swan
#

fh_sigh Same here.. maybe ill try rebooting the bot again

supple thorn
slate swan
#

Yeah

#

Def loaded

supple thorn
slate swan
#

This is in the shell, used jishaku.. I actually use modmails core and build plugins on that so if it shows here that means its imported.. all my other cogs work

#

Rebooting didnt do anything either smh

#

For the first time when I think I write perfect code fh_smh

little ivy
#

How do I make sure the emoji the bot adds to a message, doesnt count? So i mean. If the bot ads the emoji, the action doesnt start. Only if a member ads it.

little ivy
#

check if what?

supple thorn
little ivy
#

euhh

#

yeah

boreal ravine
supple thorn
#

!d discord.on_reaction_add

unkempt canyonBOT
#

discord.on_reaction_add(reaction, user)```
Called when a message has a reaction added to it. Similar to [`on_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message_edit "discord.on_message_edit"), if the message is not found in the internal message cache, then this event will not be called. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") instead.

Note

To get the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") being reacted, access it via [`Reaction.message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Reaction.message "discord.Reaction.message").

This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.

Note

This doesn’t require [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") within a guild context, but due to Discord not providing updated user information in a direct message it’s required for direct messages to receive this event. Consider using [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") if you need this and do not otherwise want to enable the members intent.
supple thorn
#

!d discord.abc.User.bot

unkempt canyonBOT
supple thorn
alpine furnace
#

It’s literally hastebin, lol

#

There is no download, discord just thinks it is a download because of .py

manic wing
#

clicking links cant do much

cloud dawn
#

hmm so instead of cogs now we combine client and command groups

lofty pecan
#

Hi there. I just would like to know what method is the best when you want to check user permissions before running a command. Basically only admin can use a specific command so is it better to use try /except or a simple if/else condition

#

And then put everything the bot has to perform in the if

tacit storm
lofty pecan
#

So def check(m) :

tacit storm
#

no, there’s built in checks to check weather or not a user has a permission

lofty pecan
#

Ho

lofty pecan
#

Because I found this if ctx.message.author.server_permissions.administrator:

#

Hoooo

tacit storm
lofty pecan
#

I see! I put that after @commands.command

#

That's amazing!

slate swan
#

!d discord.ext.commands.has_permissions

unkempt canyonBOT
#

@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.

Note that this check operates on the current channel permissions, not the guild wide permissions.

The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions").

This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
lofty pecan
#

So @commands.has_any_role('Library Devs', 'Moderators', 492212595072434186) for example

#

And then for the roles I put the one that can use the command

lofty pecan
boreal ravine
#

no

lofty pecan
#

Or is it administrator=True?

boreal ravine
#

yes

tacit storm
#

it checks for a bool

lofty pecan
#

Oki

#

Well thank you that's really awesome!

oak warren
#

how do i edit the message which has the button ?
i tried edit_original_message but it edited the sent message

spring flax
#

Screenshot?

slate swan
cosmic agate
#

hello

#

my code doesnt work

#
@bot.command(aliases= ["nrules", "funnyrules"])
async def newrules(ctx):
  embed = nextcord.Embed(title = "**NEW RULES**")
  embed.set_image(url="https://cdn.discordapp.com/attachments/838867332641849404/943992738393751602/rules.mp4")
  await ctx.reply(embed = embed)

#

the output is

#

just that

#

someone help

tacit storm
#

this is a discord api limitation

cosmic agate
#

oh ok

tacit storm
#

^^

junior verge
#
async def on_guild_join(self):
``` Do you use any other parameters for this
unkempt canyonBOT
#

discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") joins a guild.

This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
supple thorn
#

Guild

quick gust
junior verge
supple thorn
#

I just assumed you were on 2.0 since your add_cog method was a courotine now

junior verge
#

How do you get the guild ID when someone added the bot with a on_guild_join

slate swan
unkempt canyonBOT
quick gust
#

use the guild parameter which is the Guild object

junior verge
quick gust
#

yes

junior verge
#

Alright ty

#

@quick gust another question, how do you get the membercount of that server that its added to?

cosmic agate
#

how to make bot send video without link showing up

quick gust
#

!d discord.Guild.member_count

unkempt canyonBOT
#

property member_count```
Returns the member count if available.

Warning

Due to a Discord limitation, in order for this attribute to remain up-to-date and accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be specified.

Changed in version 2.0: Now returns an `Optional[int]`.
cosmic agate
#

nono

#

video too big to make into gif

#

also has audio

boreal ravine
cosmic agate
#

uh

#

nvm

#

i found something that may/may not help

boreal ravine
#

Nice

placid skiff
#

it is better to have all cogs in a single folder, so you can import all of them at once

stuck oyster
#

how do I fetch a message

slate swan
unkempt canyonBOT
#

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

Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") from the destination.
slate swan
#

!d discord.Member.fetch_message if you need a specific member message

unkempt canyonBOT
#

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

Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") from the destination.
slate swan
#

!d discord.ext.commands.Context.fetch_message you could use this too

unkempt canyonBOT
#

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

Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") from the destination.
stuck oyster
#

await ctx.channel.fetch_message(961911342489567262)

#

How can I edit a view

#

I am trying to get the message id and edit the view

slate swan
#

while editing

#

use the view kwarg

stuck oyster
# slate swan use the `view` kwarg
    @commands.command()
    async def leaf_enable(self, ctx):
        channel = await ctx.channel.fetch_message(961911342489567262)
        view = MyView2()

        await channel.edit(view=view)```
#

Uh like this?

slate swan
#

I made a bot with a console but i tried to put a cpu state view on the console with while True: but commands not working ??

#
async def on_ready():
    bot.process_command
    while True:
        #my script
#

Like this

stuck oyster
slate swan
#

Its not a command

granite parcel
#
@client.command()
async def img(ctx):
    image = Image.new(mode="RGB" (255,255,0), size=(100,100),  color=0xffff00)
    image.save(format="PNG")  
    await ctx.send(file = discord.File(filename="image.png"))```
#

Command raised an exception: TypeError: 'str' object is not callable

#

?

slate swan
#

I mean when i put while True: in @bot.event its just will print CPU and GPU state %

#

(i hided the script to print CPU and GPU btw)

#

And when i start my bot, its working but all commands are not responding

#

Its just do while true: and don't process command of my bot

placid skiff
#

strange

slate swan
#
async def on_ready():
    bot.process_commands
    while True:
        #script

        #print  ``` if someone want to see how looks my bot.event
#

Ofc i just changed my script to #script and the print to #print

placid skiff
#

there is no need to use process_commands in on_ready event

heavy folio
#

and fyi it's a coro

placid skiff
#

btw if even without it the commands doesn't work try to use the listen decorator

slate swan
#

So i put my while true: to a bot.listen() ?

#

But idk its will print when i start the bot

stuck oyster
#

hm

slate swan
#

Still not working

hoary cargo
slate swan
#

I already removed on_ready

#

And just put async def background_task():

#

With aioconsole but still not work so maybe i give up

#

Should i put await asyncio.sleep() ?

#

:oooo its working

arctic gyro
#

Hi , can anybody tell me how to ping everyone in an embed

stuck oyster
arctic gyro
stuck oyster
#

oh you want it to ping

arctic gyro
#

yes

stuck oyster
slate swan
#

How can i make a window like this

arctic gyro
granite parcel
#

can i set pillow images in the embed thumbnail?

#

anyone help?

slate swan
#

!d discord.ui.Modal

unkempt canyonBOT
#

class discord.ui.Modal(*, title=..., timeout=None, custom_id=...)```
Represents a UI modal.

This object must be inherited to create a modal popup window within discord.

New in version 2.0.

Examples...
slate swan
unkempt canyonBOT
#

Thanks to discord.py, sending local files as embed images is simple. You have to create an instance of discord.File class:

# When you know the file exact path, you can pass it.
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")

# When you have the file-like object, then you can pass this instead path.
with open("/this/is/path/to/my/file.png", "rb") as f:
    file = discord.File(f)

When using the file-like object, you have to open it in rb mode. Also, in this case, passing filename to it is not necessary.
Please note that filename can't contain underscores. This is a Discord limitation.

discord.Embed instances have a set_image method which can be used to set an attachment as an image:

embed = discord.Embed()
# Set other fields
embed.set_image(url="attachment://file.png")  # Filename here must be exactly same as attachment filename.

After this, you can send an embed with an attachment to Discord:

await channel.send(file=file, embed=embed)

This example uses discord.TextChannel for sending, but any instance of discord.abc.Messageable can be used for sending.

slate swan
#

you can set a local file as the embed image/thumbnail this way

formal basin
#

Why isn’t my setup command not working

granite parcel
junior verge
#

Is wavelink music against tos?

supple thorn
formal basin
supple thorn
#

Open it using write mode

#

And dump the things you need

formal basin
#

Ok

formal basin
supple thorn
formal basin
#

Won’t dump anything

formal basin
supple thorn
formal basin
#

Nope

formal basin
#

Actually yes

#

What does that mean

supple thorn
supple thorn
formal basin
supple thorn
#

Because storing data in json will bite you in the ass

supple thorn
formal basin
#

Yes

supple thorn
formal basin
#

Ok

supple thorn
#

Because i can't see the line where dump is

#

Replit has a bug where it can sometimes doesn't save your changes

#

And what your looking at is ghost code

supple thorn
#

Inside the opening of the file

#

You have the with open indented in your first with open

formal basin
supple thorn
formal basin
supple thorn
#

Why are you sending unrelated images

formal basin
stuck oyster
#
    @discord.ui.button(label="Request Leaf", style=discord.ButtonStyle.green, emoji = "🍃", custom_id="persistent_view:leaf")
    async def button_callback(self, button, interaction):
        button.disabled = True```
supple thorn
stuck oyster
formal basin
stuck oyster
#

button doesn't get disabled, it shows interaction failed

supple thorn
stuck oyster
#

how can i disable it using the command

formal basin
#

Look at it

#

All the way at the bottom of main.py

#

Is my verify stuff

placid skiff
supple thorn
#

Your code is like this

with open("verify.json") as json_load:
    data = json.load(json_data)
    
    with open("verify.json", "w") as f:
        json.dump(data, f)
stuck oyster
supple thorn
#

Into the json file

formal basin
#

I am

supple thorn
#

You're dumping data which is the blank json into the same json

#

You're writing {}

#

Blvck help please

placid skiff
#

json, replit, if he is newbie at python this would be the best combo

supple thorn
#

😔

supple thorn
placid skiff
#

i don't even know what he wants to do lol D_D

nimble plume
#

help

supple thorn
nimble plume
#
await logs1.delete()
AttributeError: 'coroutine' object has no attribute 'delete'
#

delete a channel

supple thorn
#

He's actually writing {} though

nimble plume
#

pls help me?

formal basin
supple thorn
#

Okay look

supple thorn
#

When you opened the json file for the first time

#

You loaded it in data

placid skiff
supple thorn
#

Data is now {}

nimble plume
formal basin
supple thorn
#

Because verify.json is blank

formal basin
#

Ok

supple thorn
#

Now when what you're dumping into the hson file is {}

#

You're legit dumping the same old data from itself

placid skiff
#

Dunno, read the docs i use views for components D_D

supple thorn
#

You're not dumping anything new

formal basin
#

Then how do dump stuff

supple thorn
#

Dump your new_verify_role

supple thorn
formal basin
supple thorn
#

Yes

formal basin
#

Ok

#

Done that

supple thorn
#

I'm guessing that's what you dump

boreal ravine
supple thorn
#

Cause why would you have a variable that's a dictionary

formal basin
supple thorn
#

Then yes

#

Dump that

#

See if it works

#

If it doesn't fix your indentation

formal basin
#

Ok

#

Yeah my indentation is crazy

boreal ravine
#

Use black

#

it'll make your code look a bit better

supple thorn
#

I don't think there is black in replit

formal basin
boreal ravine
#
pip install black

black .
``` in the shell.
supple thorn
#

I don't usually mess with replit's configuration when testing

#

I'll try that next time i try shit i don't want on my laptop

junior verge
#
@commands.Cog.listener()
    async def on_guild_join(self, guild):
        channel = self.client.get_channel(961913538832658492)
        embed = Embed(title=f"Added to server", color=0x00ff00)
        embed.add_field(name=f"Server ID:", value=guild.id, inline=False)
        embed.add_field(name=f"Owner ID:", value=guild.owner_id, inline=False)
        embed.add_field(name=f"Membercount:", value=guild.member_count, inline=False)
        await channel.send(embed=embed)
``` why doesnt this give me a error or send a message when someone added it to their server
flat solstice
#

so I see that discord.Intent.messages and discord.Intent.message_content both apply toon_message() (both guilds and DMs) on_message_edit() (both guilds and DMs) on_message_delete() (both guilds and DMs) on_raw_message_delete() (both guilds and DMs) on_raw_message_edit() (both guilds and DMs)I presume I need discord.Intent.messages for events such as on_message_edit and on_messsage_delete to even fire and then I need discord.Intent.message_content to see the content of the msg that was deleted/edited? so if I only wanted to know that a message was deleted/edited but not what the msg actually was I'd just the discord.Intent.messages

junior verge
#

Nope

#

Nvm it works now my bad sorry

placid skiff
lyric apex
#

How to make preview like this any idea?

lyric apex
#

?

placid skiff
#

the image provides embed info

lyric apex
#

Not this

#

I was talking about the image preview color when we use randomcolor of dyno

slate swan
austere solstice
lyric apex
austere solstice
unkempt canyonBOT
#

class discord.Colour(value)```
Represents a Discord role colour. This class is similar to a (red, green, blue) [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.10)").

There is an alias for this called Color...
formal basin
#

Anyone know what this means

lyric apex
#

This one

slate swan
lyric apex
slate swan
slate swan
lyric apex
slate swan
lyric apex
slate swan
lyric apex
slate swan
#

I think this is going to help u

mental bison
#

Hi, Can someone help me out.

I am trying to send messages in Private thread using BOT

unkempt canyonBOT
#

class discord.Thread```
Represents a Discord thread.

x == y Checks if two threads are equal.

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

hash(x) Returns the thread’s hash.

str(x) Returns the thread’s name.

New in version 2.0.
slate swan
muted dagger
#

me

hoary cargo
slate swan
slate swan
hoary cargo
#

i'm talking about the formatting

#

why even use .format in such situation lol

slate swan
lyric apex
hoary cargo
# lyric apex This one

most probably dyno has some image manipulation code, otherwise, you can get a pic with the color and put it inside your embed

lyric apex
hoary cargo
#

something like this

hoary cargo
lyric apex
#

I Maked This already

#

I wanted something unique so

hoary cargo
#

well, so you want what exactly? put the hex color over a certain pic

stuck oyster
#
   @discord.ui.button(label="Request Leaf", style=discord.ButtonStyle.green, emoji = "🍃", custom_id="persistent_view:leaf")
    async def button_callback(self, button, interaction):
        button.disabled = True```
How can edit the view without waiting for an interaction
slate swan
#

i'm trying to add slash commands in a cog and dont know what do do with this error

slate swan
#

and, please, switch to dpy 2

#

dont use discord_components

hoary cargo
#

ciudat it's quite confusing what;s in there

slate swan
#

didnt know that

hoary cargo
slate swan
# slate swan ok

you can install it using - pip install git+https://github.com/Rapptz/discord.py

#

there are some breaking changes though

visual island
hushed galleon
#

or using your interaction's followup webhook with edit_original_message() might also be suitable, though i would save that for ephemeral views

slate swan
#

Isnt there a except for cogs? Like

try:
   load_extension("cog")
except ExtensionAlreadyLoaded:
  ...```
hushed galleon
#

nah you have to write that try/except yourself

#

tho if you use the jishaku extension their load command handles it for you

jovial plover
#

can discord bot upload emojis

hushed galleon
#

yes, using the Guild's create_custom_emoji() method

jovial plover
#

Thanks

slate swan
#

!d discord.Guild.create_custom_emoji

unkempt canyonBOT
#

await create_custom_emoji(*, name, image, roles=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

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

There is currently a limit of 50 static and animated emojis respectively per guild, unless the guild has the `MORE_EMOJI` feature which extends the limit to 200.

You must have the [`manage_emojis`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_emojis "discord.Permissions.manage_emojis") permission to do this.
slate swan
#

and the image should a bytes object

slate swan
#

im not quite sure

slate swan
slate swan
#

im to lazy to check docs on mobile since its so slow

#

inarguable

hasty lake
#

Readthedocs issue

slate swan
#

yeah

slate swan
#

it takes a solid sec for it to load

#

and its not my wifi😡

slate swan
hasty lake
#

I'm fairly certain it's because of readthedocs being slow

slate swan
#

it is im just joking

#

mine opens right away ngl

#

on mobile?

#

yeah

#

just tried

#

🧢

#

search's hyperlinks work fine enough

#

it takes a solid sec for it to load the endpoint compared to the desktop ver

#

and there we go, now it doesnt even redirect me to the docs

#

it died as usual

supple thorn
#

Even on laptop mine is slow

#

And searching is more slow

slate swan
#

your wifi is just bad at that point

supple thorn
#

That's how okimii beats me

slate swan
#

is discord's styling changed or is it just me?

slate swan
supple thorn
#

he always replies faster to the problem

#

😔

slate swan
#

lmfao

supple thorn
#

Forgot

#

It's because of your avatar

slate swan
#

lmao

supple thorn
#

Turning into ashley

slate swan
#

tf

#

im a she

#

jk

#

..