#discord-bots

1 messages · Page 780 of 1

maiden fable
#

Yea same

plush peak
#

So what messages were meant for me?

slate swan
#

because it did i sent a link of what happend

plush peak
#

I saw no reply at all

slate swan
#

first it started with a 1sec api response and then it started

final iron
#

These things happen

#

Its annoying though

slate swan
#

how would this happen smh

#

this shouldnt happen

final iron
#

I mean discord outages are pretty common

maiden fable
#

Yea

slate swan
#

they shouldnt

#

smh discord

final iron
#

I never said they should happen

#

I'm saying its not uncommon

#

I agree, Discord shouldn't be having outages at all

slate swan
#

i just said it shouldnt happen and it shouldnt be common

final iron
#

I totally agree but I'm saying it is common

#

Not that it should be this way

slate swan
#

btw did you saw the new 3050?

maiden fable
#

?

final iron
#

Might head out and buy it tmr

slate swan
#

i think its unnecessary

maiden fable
#

!ot exists

unkempt canyonBOT
final iron
slate swan
left crater
#

how can i make the bot send png files

delicate geyser
#

what happened to discord?

final iron
unkempt canyonBOT
#

class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/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/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
slate swan
#

@delicate geyserapi outage

delicate geyser
slate swan
#

yw

cold sonnet
#

discord on top

slate swan
#

LMAO

maiden fable
#

Gn everyone lemon_sleepy

cold sonnet
#

guild = bot.get_guild(id=918873871858425896)

cold sonnet
#

you don't need to pass it in as a kwarg

slate swan
#

its a positional argument

cold sonnet
slate swan
#

nothing

cold sonnet
#

yeah I just copied it out of his code

slate swan
#

!d discord.ext.commands.Bot.get_guild

unkempt canyonBOT
slate swan
#

/ means all arguments before it are positional arguments

cold sonnet
#

oh interesting

slate swan
#

ikr

#

just like *,

cold sonnet
#

and comments in some languages are made with * and /

#

what a coincidence

slate swan
#

yeah ik

cold sonnet
#

I feel like we're getting backstabbed

#

trolled

slate swan
#

wdym

cold sonnet
#

and quite possibly bamboozled

slate swan
#

?

cold sonnet
#

dk

slate swan
#

...

cold sonnet
#

......

final iron
#

@slate swan If I can find the 3050 at msrp I'm going to buy it

slate swan
final iron
#

I'll fight someone for it

plush peak
#

Finally figured out how to paste

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

Okay now that that's figured out, can someone help me out? I'm stuck like a idk what else is stuck but I'm stuck

I had a friend help me with a Discord bot that pulls a database of users via API and auto assigns a specific role as long as the user is found in that db.

Problem now, it also unassigns all roles before this happens and since we have CaptchaBot (which assigns a basic role after verification) it somehow can't assign the specific role to the user
User gets stuck in a loop of verifying since users without the basic role can't enter a channel except for #verify-here

How do I change the role assignment from unassign all roles -> assign "premium" role to just add the "premium" role.

slate swan
modern fiber
#

Guys, my code just broke I don't know why. When I press run the code, it doesn't starts my bot. There are no errors not the message "Bot is online":

#

Help?

slate swan
#

send the code

final iron
modern fiber
#

Its long

modern fiber
unkempt canyonBOT
#

Pasting large amounts of code

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

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

slate swan
slate swan
#

i see no reason why

modern fiber
#

There you go then.

slate swan
#

that hurts my eyes so much

slate swan
modern fiber
#

I did.

slate swan
#

and your bot constructor isnt right

modern fiber
#

client.run('myultrasecrettoken')

#

like that

#

Hm?

#

It worked fine til I tried adding flipcoin command

#

I just deleted it after, and it broke

slate swan
#

1.you have no intents
2.you can change status in the bot constructor
3.you can remove the help command in the bot constructor

#

theres so many kwargs jeez

modern fiber
#

And what is this?

slate swan
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

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

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

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

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

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

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

slate swan
#

see the intents kwargpithink

modern fiber
#

and what is this?

slate swan
#

cool youre still doing allot of things wrong

#

lol

modern fiber
#

.

#

You didn't helped me bro?

#

My question was why my code isn't running? Well, my bot.

#

Yes it is.

#

breh

slate swan
#

and dont do anything on ready

final iron
#

Hello chat

manic wing
velvet tinsel
pine verge
#

my bot isnt running as well

#

was it because of the outage ?

final iron
#

Perhaps

slim ibex
#

Well it was an api outage

#

So technically yes

pine crown
#

wheree slash commands go

#

oh, poop.

kindred drum
slim ibex
#

Error speaks for itself. Maybe something happened and you accidentally moved it somehow

#

Or maybe it got deleted somehow

pine crown
slim ibex
#

Wdym

pine crown
#

commands*

#

my bot slash command is dissapeared

#

im so angry rn

slim ibex
#

uhh maybe because of the api issue

#

just wait

cloud dawn
#
Monitoring - We have fully removed all rate limits and Discord is almost back to normal.

Over the next hour, some Discord servers may continue to see some issues interacting with bots using slash commands. As part of resolving the incident, we needed to reduce load on our databases and we turned down some parts of our slash command system.

We are going to complete our internal postmortem process to really dig in and understand exactly what happened here, but we really apologize for the inconvenience if you were unable to login today or had other issues.
Jan 26, 14:12 PST
devout iris
#

What is that?

#

it says my all infos lol

kindred drum
cloud dawn
#

Looks like you sended the context object

devout iris
slim ibex
#

🧐

devout iris
#

i want to take datas from an user

#

but idk what happened lel

manic wing
devout iris
#

first time of waiting for messages lol

#

widk how to use wait_for("message")

manic wing
slim ibex
#

!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.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

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

This function returns the **first event that meets the requirements**...
devout iris
#

but how can i take user inputs ?

final iron
unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

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

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

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

This function returns the **first event that meets the requirements**...
devout iris
#

like that:
bot: what is ur age?
user: 25

bot will save his age as a veriable

manic wing
#

what is a veriable

final iron
#

Check out the docs

slim ibex
#

!input

final iron
#

It will provide examples

slim ibex
#

!d input

unkempt canyonBOT
#

input([prompt])```
If the *prompt* argument is present, it is written to standard output without a trailing newline. The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that. When EOF is read, [`EOFError`](https://docs.python.org/3/library/exceptions.html#EOFError "EOFError") is raised. Example:

```py
>>> s = input('--> ')  
--> Monty Python's Flying Circus
>>> s  
"Monty Python's Flying Circus"
```  If the [`readline`](https://docs.python.org/3/library/readline.html#module-readline "readline: GNU readline support for Python. (Unix)") module was loaded, then [`input()`](https://docs.python.org/3/library/functions.html#input "input") will use it to provide elaborate line editing and history features.

Raises an [auditing event](https://docs.python.org/3/library/sys.html#auditing) `builtins.input` with argument `prompt` before reading input...
devout iris
#

variable*

#

lol my keyboard

devout iris
#

nvm i'm confused today i'll sleep

slim ibex
#

it’s simple

#

Look

cloud dawn
#

Can we please not suggest input in an async bot.

devout iris
#

i'm lookin

devout iris
slim ibex
#

Is there an async version of it lmao

cloud dawn
#

Most likely not, if there is it will be very sketchy with opening a second window.

slim ibex
#

💀

#

But @devout iris

#

actually it won’t rlly work

#

😢

slate swan
#

Hey I wanna make a Server Info command and it works but at the Owner field it shows None idk how to fix that

slate swan
#

How do I get the list of all channels in a specific category by using category.id ?

slate swan
cloud dawn
slate swan
cloud dawn
unkempt canyonBOT
#

property channels: List[GuildChannelType]```
Returns the channels that are under this category.

These are sorted by the official Discord UI, which places voice channels below the text channels.
cloud dawn
slate swan
slim ibex
cloud dawn
unkempt canyonBOT
cloud dawn
#

Could be None but maby because he/she isn't in the cache.

plush peak
#

Why does my Role Assign bot only assign roles after I restart the VM it's running on?

cedar stream
plush peak
pine sluice
#

How do you make it so that someone can only run a particular command once in their entire lifetime

cedar stream
pine sluice
#

also ive been trying to implement a system manually but it doesnt seem to work

cedar stream
pine sluice
cedar stream
#

Use a db

pine sluice
#

if someone have run the command once their user id will be put in the file

pine sluice
cedar stream
#

Database

pine sluice
#

Ah ok

cedar stream
rocky trench
#

What are you trying to do alexie?

#

Adding a cooldown to a command?

#

U don't need to store it in a data base.

rocky trench
#

Well eh

#

U could @commands.cooldown(1,1000000000000, commands.BucketType.user)

#

This would be the easiest

cedar stream
#

Lot of zeros

rocky trench
#

Or this

#

@commands.max_concurrency(number=1, per=commands.BucketType.user, wait=False)

#

1 command per buckettype.user

acoustic ermine
#

im curious what wait = False does

cedar stream
#

Probably error or something

#

🤷🏼‍♂️

acoustic ermine
#

anyone?

final iron
#

!d discord.ext.commands.max_concurrency

unkempt canyonBOT
#

@discord.ext.commands.max_concurrency(number, per=discord.ext.commands.BucketType.default, *, wait=False)```
A decorator that adds a maximum concurrency to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or its subclasses.

This enables you to only allow a certain number of command invocations at the same time, for example if a command takes too long or if only one user can use it at a time. This differs from a cooldown in that there is no set waiting period or token bucket – only a set number of people can run the command.

New in version 1.3.
final iron
final coral
#

didnt this get discontinued

final iron
final coral
#

@final iron

final iron
#

Well development has ceased

final coral
#

so how long until it will stop working

final iron
#

¯_(ツ)_/¯

final coral
#

i saw some alternatives that were being made a while back

#

any of those good now?

final iron
#

!pypi disnake

unkempt canyonBOT
final iron
#

Use this

final coral
#

same syntax?

final iron
#

Yeah

#

Its a fork

final coral
#

is it backed by good developers

final iron
#

Yes

final coral
#

is pycord any good i saw something about that

slate swan
#

pycord is the something I'll never recommend to use.

final coral
#

why

slate swan
#

It's not too well done , and event the og discord.py developer says it

#

Disnake/nextcord are decent maintained and fast developing forks

torn sail
final iron
#

I wouldn't recommend it

#

Use disnake

sick birch
quaint epoch
#

!d disnake.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://docs.disnake.dev/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**...
final coral
#

ok thanks guys

#

ive just never disnake thats why

quaint epoch
#

how do i do a Bot.wait_for() in my on_message function, so that i can check if a certain user sends a message?

quaint epoch
final coral
slim ibex
#

its been gone since august

sick birch
#

only for verified bots

#

implementing slash commands yourself is actually relatively easy

slim ibex
#

its more work with dpy. all the other libs have slash commands built in

pliant gulch
#

discord.py wasn't really built for you to extend it a lot though

#

From my experiences at least it was very much designed to stop you from doing so

slim ibex
#

mhmm

pliant gulch
#

You could manually make routes and do the requests like that though for a minimally invasive implementation

#

But you'd also need a mapping of the commands' and their callbacks

kindred epoch
#

how do i add "diff" codeblock in my embed description?

final iron
kindred epoch
slate swan
#

Hello

kindred epoch
#

it does this

final iron
#

It should work

slate swan
#
pic_ext = ['.jpg', '.png', '.jpeg']
@client.event
async def on_message(message):
    for ext in pic_ext:
        if message.content.endswith(ext):
            print("testing")

I'm trying to get my bot to detect if an image is sent in a specific channel.

final iron
#

Is there an error?

slate swan
final iron
#

!d discord.Message.attachments

unkempt canyonBOT
final iron
#

You can check with this

slate swan
#

message.attachments[0].url

quaint epoch
#

does bot.wait_for() raise a asyncio.timeout_error if the the check is true, before the timeout is finished?

slim ibex
#

!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.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

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

This function returns the **first event that meets the requirements**...
quaint epoch
#

!d disnake.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://docs.disnake.dev/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**...
quaint epoch
#

but, idk if when it raises asyncio.TimeoutError

slate swan
#

@final iron

cloud dawn
slate swan
cloud dawn
slate swan
stone talon
cloud dawn
slate swan
#

yeah lmao

#
pic_ext = ['.jpg','.png','.jpeg']
@client.event
async def on_message(message):
    if len(message.attachments) > 0:
        for file in message.attachments:
            for ext in pic_ext:
                if file.filename.endswith(ext):
                    print("test")
cloud dawn
# slate swan yeah lmao
@client.listen()
async def on_message(message):
    if message.author.bot:
        # If the user is a bot -> ignore
        return

    for attch in message.attachments:
        # Loops over the attachments, skips if list is empty
        if attch.filename[-4:] in ['.jpg', '.png', '.jpeg']:
            print("test")
#

if you for loop an empty list it skips the for loop

#

!e ```py

for x in []:
print("test")

unkempt canyonBOT
#

@cloud dawn :warning: Your eval job has completed with return code 0.

[No output]
cloud dawn
slate swan
pliant gulch
#

You could also check the MIME type of the attachment with strings, E.g image/png

#

Significantly more work but an alternative as well

cloud dawn
slate swan
#

ok now the tricky part

cloud dawn
#

You would need to download the image aswell andy i think.

slate swan
#

so, I want it to grab the image sent and post it to twitter..

pliant gulch
unkempt canyonBOT
cloud dawn
#

That's handy :3

slate swan
pliant gulch
#

You should look into the twitter API, out-of-scope in this channel

slate swan
cloud dawn
#

Do use aiohttp please :3

slate swan
kindred epoch
#

im fetching a message using a message id, and when i try to get the embeds in it, it returns None even tho it does have an embed, any idea why?

slate swan
cloud dawn
#

@slate swantweepy seems to have an asyncstream

green bluff
#

i cant see

#

the slash command

final iron
green bluff
#

disnake

final iron
#

Have you read this?

green bluff
#

yes

final iron
#

So did you add your guild in your bot constructor?

green bluff
#

u have to do that?

final iron
#

Go back and actually read it

#

Skimming over docs is a bad idea

green bluff
#

sorry

slate swan
green bluff
#

an hour for it to register the command?

slate swan
#

iirc yes

pliant gulch
#

An hour to register global commands

#

Guild specific commands are added pretty quickly

#

Keep in mind you also need ‘application.commands’ scope to have permissions to make slash commands

#

There should also be a permission you can set instead

green bluff
#

my bot

#

has admin perms

slate swan
#

doesnt matter , a scope is different from role permissions

green bluff
#

oh

#

i c oops

#

shouldnt administrator allow slash comamnds

slate swan
#

hello

#

I wanna learmn how to code

slate swan
unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

slate swan
#

thanks

slate swan
slate swan
#

how long is it gonna take for me to master it

#

like the average

#

i took 2 yrs

dreamy sluice
#

Anyone know how to get the user object in nextcord buttons?

slate swan
#

why would it be a package

#

its an internal module

slate swan
dreamy sluice
pliant gulch
slate swan
#

Interaction.author must be the thing

if not , its interaction.user

dreamy sluice
#

Okeh

#

lemme try that

plain glacier
#

Thread(target=Kraken.CreateChannel, args=(guild.id,)).start()
AttributeError: type object 'Kraken' has no attribute 'CreateChannel'

dreamy sluice
#

Hmmm, it's not working

plain glacier
#

i dont get this error.

slate swan
#

read the edit.

dreamy sluice
obsidian ledge
#

how do i make my bot create a channel after someone presses a button

dreamy sluice
#

oh

#

lemme try that

slate swan
plain glacier
#

its the bots name

unkempt canyonBOT
#

await create_text_channel(name, *, reason=None, category=None, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

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

Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.

The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.

Note

Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
slate swan
#

or the channel type you want...

#

use this in the button's callback

slate swan
#

/method

plain glacier
#

ohhh i got it thanks

obsidian ledge
slate swan
#

you dont copy paste what i sent....
use your own discord.Guild instance.

#

and it was discord.Guild , not discord.guild

slate swan
#

its a builtin module

slate swan
pliant gulch
#

I doubt you ever really "master" python

#

You get better at it but mastering it is a whole different thing

slate swan
#

theirs so much to it

slim ibex
#

You don’t program to master it

slate swan
#

you never would, there's always something you dont know about!

slim ibex
#

You physically can’t remember everything

slim ibex
#

or every little nuance about the lang

slate swan
slim ibex
#

im saying that as in its impossible to remember everything from the top of your head

#

idk if that was supposed to be a question or a comment tbh lmao

slate swan
#

cause i remember stuff mentally pithink

slim ibex
#

true

slate swan
#

you dont use checks on events

#

sarthak's godly vision

#

hawk eyes

royal oar
#

Can someone pls help me get this working? Its a Welcome message for multiple servers.
https://paste.pythondiscord.com/exonezijuk.py
Its suppose to save the guild and top channel to a Json file.
this is where its suppose to send the message.
The set command changes that.
It wont save when it joins the server
Set command works
but then when i try to use the on_member_join()
i get this error:
line 38, in on_member_join
channel = guildInfo[guild.id]
KeyError: 927416344431956048

slate swan
#

dont use json as a db lol

slim ibex
#

^

#

a few things too, you don’t need a use .format, use f strings

slate swan
slim ibex
#

You don’t need the whole path starting from C:

royal oar
slate swan
#

not gona work, you need to use the send message for the channel id

royal oar
#

ahh ok

royal oar
slate swan
#

you shouldn't

#

and you cant send nothing

#

channel isnt a channel obj

slate swan
#

you need to get the channel where it sends the message the fuck 😄

royal oar
slate swan
#

at least it should be the channelid without that it cannot send the message? tf u talkn abt

#

and also await channel.send(embed=embed)

#

who are you talking to lmao

#

Jamie

#

as you can see this wwwwwwtf

slate swan
#

idk chief seems like she or he isnt here

#

he wants to send embed to guild but not channelID this is so funny where does the Bot even get the Channel? he just declares the guildid to the channel and then trys to send a integer

slate swan
unkempt canyonBOT
slate swan
#

bro you make no sense

#

read what it says.

#

send a int?

slate swan
#

they are getting the channel , and sending the message there

#

u prolly cannot even read?

#

anyone interesting in being friends :D

#

ah , they didnt get it

#

ok bai no one cares smh

slate swan
slate swan
slate swan
#

damn

#

i want some programming friends lol

#

hipithink

slate swan
slate swan
#

sarthak is fun to talk to so have funpithink

#

you want friends but we cannot send Friend Req funny mate

slate swan
#

i see no point in saying stuff like this is useless and not funny

#

tf u talkn about @slate swan just because im new to this admin bot permissions?

#

on client.event

#

nice var naming

#

ty

#

and use listeners smh

#

you new to this game

#

Kid you need to learn more

#

!d discord.ext.commands.Bot.listen

unkempt canyonBOT
#

@listen(name=None)```
A decorator that registers another function as an external event listener. Basically this allows you to listen to multiple events from different places e.g. such as [`on_ready()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_ready "discord.on_ready")

The functions being listened to must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine "(in Python v3.9)").

Example...
slate swan
#

funny guy arent youpithink

slate swan
#

smortpithink

#

"Python Skid"

#

Too much

#

What the fook he calls himself Software De

slate swan
slate swan
unkempt canyonBOT
slate swan
#

Dev höööööööööööö

#

i am one?

#

i couldnt careless if a 12 year old says im not

#

what are you gonna do

print("hello world")
#

I make Millions dog

#

sure you dopithink

slate swan
#

Okay cool, what the fuck mate then i need to add TRY:CATCH but that sucks, because its not how to code

#

wut

#

you make 0 sense

#

This isnt related to discord bots anyhow

#

catch is not a thing in python , its try except

#

and finally

#

and please keep the language civil remSmile

#

if you want to use it ofc

slate swan
#

👁️ 👁️

#

ash dontpithink

#

Lol

slate swan
#

thx

#

Oh man kids when they try to steal my Time

#

xD

slate swan
#

😂

slate swan
#

nice about me btw

#

javascipt

#

whats that👁️ 👁️

slate swan
#

scratch is best <3

#

cof cof

#

cry_juice we cannot use hex colors directly for embeds in hikari

#

use a fork like disnake or nextcord

#

!pypi disnake

unkempt canyonBOT
slate swan
#

epic fail

#

Wrong cmd smh

pliant gulch
#

Assuming some kind of builder class?

slate swan
#

hikari.Color(hex)

#

Wao

#

the heck

#

that looks cursed

#

you can do that in dpy too :)

#

the internals do the same.

#

lol

pliant gulch
#

💦 Writing these stupid classes got so easy thanks to that good Idea I had when making a Base class

slate swan
#

nice

#

!d disnake.Member.timeout

unkempt canyonBOT
#

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

Times out the member from the guild; until then, the member will not be able to interact with the guild.

Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.

You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.

New in version 2.3.
slate swan
#

or Member.edit(timeout=)

#

no

#

wait yes sorry

#

read that to quick

shadow wraith
#

cant wait for modals to be a thing when it releases

#

h

slate swan
slate swan
#

earlier it was required for it to be a hikari.Colourish object

shadow wraith
#

modals not models 💀

slate swan
#

i dont read discord news lol

#

lolll

shadow wraith
#

modals are like support input like a mini form

slate swan
#

oh modals those things

shadow wraith
#

yeah

slate swan
#

yeah there cool

shadow wraith
#

kind of like google forms integrated into discord 😎

slate swan
#

yes sir

shadow wraith
#

i wonder if they even exist

pliant gulch
#

Don't get why some people refer it to modals imo

#

Modals are too broad, just say text input field

slate swan
#

boi wut

shadow wraith
#

that's misleadin.

#

istg which text input would you mean

#

you mean input("this") or bot.wait_for(...) or modals.

slate swan
#

why call it discord call it super inteligente connective social apppithink

pliant gulch
#

Modals can be anything UI

#

Not sure how that makes it any better

shadow wraith
#

why call it discord.py call it super inteligente connective social app.python

slate swan
#

yes

#

can take floats or ints

shadow wraith
#

im pretty sure, but if u hate that then you can use until= which you can pass a datetime.datetime object with i think

grim oar
#

modals? pixels_snek_2

slate swan
#

yes a float or datetime with until

slate swan
shadow wraith
#

uhm i dont have a picture of discord modal lemme google an image up for it

#

fuck i still dont have an image

slate swan
grim oar
#

Did you mean "model" yert

slate swan
#

thats what i said?????

slate swan
#

but its referred as "modal"

grim oar
#

Modal

shadow wraith
pliant gulch
#

This was some other thing I saw

#

I thought I remembered seeing an inline text field input

#

But I guess I just remembered wrong

shadow wraith
#

do you use replit to code your bot or

slate swan
#

rip

shadow wraith
#

if you did, please don't it uses a shared ip which could get you rate limited often. just have it on your machine why do it in a browser lol

slate swan
shadow wraith
#

true but replit kind of just rate limits you often

slate swan
#

replit doesnt ratelimit you

shadow wraith
#

i need to learn english

slate swan
#

discord does its there api?

shadow wraith
#

replit gets discord to rate limit you like all the time lol for some reason

slate swan
#

yes

shadow wraith
#

ive never got rate limited except for the times i used replit

slate swan
#

discords

#

and just run your bot in a new replit and youll be fine

#

seen it yes

shadow wraith
#

weird solution

oblique adder
#

One quick question. I never use replit before but I know it is very bad for hosting bots.
My client paid me to make a bot and wanted it to be hosted on replit. Is it possible for the token to get leak since I cannot make the repo ?

slate swan
#

just add the token in a env file

maiden fable
#

Lmao

#

The typo tho

slate swan
#

that typo was so bad

#

i apologize 😭

oblique adder
#

so If i keep it in the env file other people who view the repo wont see the token am I right ?

maiden fable
#

Gud boy

slate swan
maiden fable
slate swan
maiden fable
slate swan
#

user isnt a kwarg and youre trying to timeout context

final iron
#

ctx.user.timeout

stray adder
#

Pls anyone help me

#

Plsss anyone help me

slate swan
#

no should be

await user.timeout(duration=10)
stray adder
#

@slate swan bro pls help me

slate swan
#

with

stray adder
#

@slate swan i made a nuker bot

slate swan
#

sorry cant help

stray adder
#

@slate swan y

slate swan
#

against discord tos

#

yw

stray adder
#

@slate swan no it's not like that

#

One cmmd not working

slate swan
#

yes its like that

slate swan
#

abusing the api is against tos

#

so please take the conversation else werepithink

slate swan
#

clarifying the situation pithink

keen talon
stray adder
keen talon
stray adder
#

@keen talon I'm noob at python

slate swan
#

we dont help with that herepithink

stray adder
#

@slate swan kk sorry

keen talon
stray adder
#

@keen talon 😁

slate swan
#

its all outdated and bad code lol but cant help with anything pithink

stray adder
#

@slate swan ys it's old

stray adder
#

@slate swan can you help me with any other bots

slate swan
#

nice

keen talon
stray adder
#

No I want to make a security bot

maiden fable
#

oki got a supporter (wow)

keen talon
slate swan
stray adder
#

That bans raiders and nukers

maiden fable
slate swan
slate swan
unkempt canyonBOT
slate swan
maiden fable
unkempt canyonBOT
keen talon
slate swan
#

does discord just flag you

maiden fable
maiden fable
slate swan
#

lmao

slate swan
#

not even related to what i said and i even know itpithink

maiden fable
#

Best feature in the lib 😂

slate swan
maiden fable
keen talon
stray adder
#

Can anyone teach me python language pls

slate swan
maiden fable
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.

maiden fable
slate swan
#

i use optional for return types

#

Union and Optional are almost same

#

Optional has None added by default , thats the only difference

keen talon
slate swan
#

!d typing.Union

unkempt canyonBOT
#

typing.Union```
Union type; `Union[X, Y]` is equivalent to `X | Y` and means either X or Y.

To define a union, use e.g. `Union[int, str]` or the shorthand `int | str`. Using that shorthand is recommended. Details...
slate swan
#

!d typing.Optional

unkempt canyonBOT
#

typing.Optional```
Optional type.

`Optional[X]` is equivalent to `X | None` (or `Union[X, None]`).

Note that this is not the same concept as an optional argument, which is one that has a default. An optional argument with a default does not require the `Optional` qualifier on its type annotation just because it is optional. For example:

```py
def foo(arg: int = 0) -> None:
    ...
```  On the other hand, if an explicit value of `None` is allowed, the use of `Optional` is appropriate, whether the argument is optional or not. For example...
maiden fable
slate swan
maiden fable
slate swan
#

oh wait lemme see

#

i.e

def function(a: str = None) -> typing.Optional[str]:
    return print(a)

or import the class which is better like i do

maiden fable
keen talon
slate swan
#

The parser will then continue on to the next parameters and converters, if any.

#

jeez , this is cool , and i never knew about it

maiden fable
#

The behavior is just like that of commands.Greedy

stray adder
#

Anyone pls teach me to code

slate swan
#

!resources

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.

stray adder
slate swan
#

you ment how?

#

if not, that wasn't funny thonk

#

anytime❤️

stray adder
#

Anyone help mee I want to learn python

#

@slate swan

#

Will. U help me

slate swan
#

no

stray adder
#

I think u know python well

slate swan
#

i dont

stray adder
#

@slate swan pls

slate swan
#

mhmmmmmmm

stray adder
#

Do i need a pc to learn

slate swan
#

mhmmmmmmm ||no sorry i learned by myself and so can you||

sweet ether
#

Hiii anyone need help?

sweet ether
stray adder
#

@slate swan then suggest me any website or something

timber sigil
slate swan
stray adder
#

@slate swan it's not working

stray adder
#

@sweet ether can u help me

slate swan
#

why the pings im right here

maiden fable
#

Look, @stray adder... No one help u by themselves in learning Python. Everyone will instead run the resources command to tell u the websites from where u can learn.

#

!resources click on the blue link

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.

timber sigil
sweet ether
slate swan
#

use disnake lol

slate swan
#

or any other fork

stray adder
#

@maiden fable i clicked it 5times

maiden fable
#

there is py-cord, nextcord and edpy too

maiden fable
slate swan
#

!pypi disnake

unkempt canyonBOT
slate swan
#

it will be easierr for you to get help

#

since people here use it too

timber sigil
#

m

slate swan
#

me making slash commads be like ```py
@implements(SlashCommand, PrefixCommand)

maiden fable
#

BTW I shifted to py-cord :DDD

slate swan
#

you did what

maiden fable
sweet ether
maiden fable
#

fcc isn't that good

maiden fable
sweet ether
slate swan
sweet ether
slate swan
slate swan
maiden fable
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.

maiden fable
slate swan
sweet ether
#

But fcc is more assignment based, so you’re not just reading but also practicing simultaneously

slate swan
#

no

maiden fable
slate swan
#

fcc shows more syntax then what the solution does

#

ignore forks , join the hikari gang

timber sigil
slate swan
slate swan
meager chasm
#

snek cord is the best fork imo

maiden fable
maiden fable
#

Actually I also had a talk with its owner. Great person he is

slate swan
#

nah hikari is the best discord api wrapper

#

hikari, pincer all good

maiden fable
#

Wait nvm I am mistaken

slate swan
#

👁️ 👁️

stray adder
#

Me noob😞

maiden fable
#

Ah I had the talk with the owner of dis-snek

slate swan
timber sigil
#

idk what lol

slate swan
slate swan
maiden fable
# final iron Lmao

He was in the disnake server when they were talking about how dis-snek gonna give disnake free advertisement (it was actually an awkward meet lol)

timber sigil
slate swan
#

you should subclass view tbh

#

components is meant for actionrows , use view or actionrow

maiden fable
meager chasm
#

danny hates anything that isn't dpy

slate swan
keen talon
slate swan
keen talon
#

Sleep 😴

slate swan
timber sigil
slate swan
#

goodnight , try stuff tomorrow

#

gn

slate swan
#

anytime

#

anytime

#

🤔

maiden fable
#

@slate swan

#

And the links above were disnake commits

slate swan
#

i can see that , but isnt it like a year old when the forks wasnt even too preferred

maiden fable
#

and the message by doge was actually a real comment in the source code lol

slate swan
#

what does danny expect all devs to stop making bots in python? it must be done

timber sigil
slate swan
#

10-2-2021

slate swan
maiden fable
#

It means October 2 iirc

slate swan
#

nvmmmmmm

#

different format

#

its mm-dd-yyyy 💀

maiden fable
#

LMAO

#

At last u understand

boreal ravine
#

?

timber sigil
meager chasm
#

string literals need quotes

timber sigil
#

koi :/ bta do vai

meager chasm
timber sigil
meager chasm
#

no wtf

#

you should know how to use string

timber sigil
#

🥲 me total new

meager chasm
#

you should know basic python first

stray adder
#

@meager chasm bro can u help me

meager chasm
#

ya

stray adder
#

@meager chasm pls check dm

timber sigil
meager chasm
#
"cat"
#

add quotes

timber sigil
#

^^?

meager chasm
#

ye

timber sigil
#

@meager chasm

meager chasm
#

bruh

#

but the url there

oblique adder
#

can we have more than 1 SelectMenu in 1 message ?

meager chasm
#

5, 1 per row i think

timber sigil
#

@meager chasmhttps://i.imgur.com/yGSVRo5.png

grim oar
#

Show your project dir structure

stray adder
#

@grim oar bro can u help me with one error

#

Look one error

grim oar
#

Show your code

stray adder
#

Ok

oblique adder
grim oar
#

You are apparently using commands.bot which is a module, you need to create an instance of commands.Bot

stray adder
#

@grim oar pls check your dm

grim oar
#
from discord.ext import commands

bot = commands.Bot(...)

@bot.command()
...
stray adder
#

What should we fill in between that bracket

grim oar
#

The command prefix, intents and other args

#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

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

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
spice folio
#

whats a good platform to run a discord bot off of thats programmed in python?

grim oar
#

A platform?

stray adder
#

@grim oar

grim oar
#

Capital B

spice folio
# grim oar A platform?

i guess what i mean to ask is, can you run a discord bot off IDLE? and if not what should it run off of?

stray adder
#

@grim oar where

spice folio
#

if that makes sence

quick gust
stray adder
grim oar
#

^

#

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

quick gust
# stray adder
  1. commands.Bot not commands.bot
  2. your bot variable is named Bot and you are doing @bot.command...
  3. supply it a prefix aswell
stray adder
#

@grim oar @quick gust

quick gust
#

...

stray adder
#

Plsh help

#

I'm noon at coding😅

quick gust
#

you now interchanged the bot variable and your decorator

#

why

#

just keep your bot instance bot

pliant gulch
grim oar
#

Wait what

#

Ohh

#

Bruh

stray adder
#

I made it

#

But only one problem

#

That's the thing

grim oar
#

I am never getting helper 😩

keen talon
stray adder
#

But I'm not using it for nuke any server

keen talon
quick gust
keen talon
stray adder
#

@keen talon if want to nuke then I can do it bcoz already the cmmds are working

#

I want to learn bit development and the most simple bot is a nuker that's why doing

quick gust
#

Who tf told you that

keen talon
#

We are not allowed to help you with that

keen talon
stray adder
#

No admins would invite nuker bot to their server then how can I nuke

grim oar
#

is that why you wanted me to help in dm 😕

quick gust
#

i can't comprehend what you're saying bruh

stray adder
#

@grim oar yeah all people are just saying I'm spammer

keen talon
grim oar
keen talon
quick gust
stray adder
#

@grim oar it's not public and only my cmmds work for that bot and I had written in it's about section that this is a nuker bot

keen talon
#

We can't believe random words from a stranger pithink pithink

stray adder
#

I can show code

grim oar
#

Why not instead of making it sound better, just make something different at this point, no one will help you with that here as inf said

stray adder
quick gust
unkempt canyonBOT
#

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

keen talon
stray adder
#

@keen talon kk

#

Will not say

echo wasp
#

How would this be possible "in the bot when user will use $start cmd he can use alll other commands but when user didnt used $start cmd he cant use any other command and he will get a error" I don't understand how that happened I didn't put one in at all to do that

grim oar
#

Store the ids of all the users and make a global check

kind hill
#

!warn 832836236342984724 Don't ask about nuker bots or other malicious bots in our community.

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied warning to @stray adder.

stray adder
#

@kind hill kk srry

novel bolt
#

hey i just wanted to send multiple embeds , so i made the code from my lap and ran it , it worked . But the same code i copy pasted to the site where i host bot , it shows this error

#

anyone know why tis happens?

pliant gulch
#

The place where your bot is hosted runs on a different version of discord.py

novel bolt
#

so is there any fix for it?

keen talon
#

Pls share your code pithink

novel bolt
pliant gulch
#

embeds kwarg was added to send in version 2.0

#

You need to install 2.0 to use it

novel bolt
#

oh

light violet
#

how to check the number of admins in a discord server with discord py?

steel void
#

how do i print everything from discord.py console to a discord server chat

visual island
light violet
#

ok

light violet
#

numbers

visual island
#

!d discord.Guild.bans

unkempt canyonBOT
#

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

Retrieves all the users that are banned from the guild as a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`BanEntry`](https://discordpy.readthedocs.io/en/master/api.html#discord.BanEntry "discord.BanEntry").

You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to get this information.
visual island
#

so like [e.user for e in await guild.bans()]

tender estuary
tender estuary
#

many don't give admin perms to admins itself

light violet
#

thanks

tender estuary
#

So if you have an admin role without admin perm it won't show

tender estuary
light violet
tender estuary
#

wdym

#

like a !serverinfo?

visual island
visual island
tender estuary
light violet
#

how to put that

tender estuary
#

Try this

#

ok wait nvm

#

try this

light violet
#

ok

tender estuary
#

Ok I found a mistake, i is a member can't iterate I

#

let me work a way around this

light violet
#

a = [m for m in guild.members if m.guild_permissions.administrator]
await ctx.send(f'{len(a)}')

#

it worked

tender estuary
#

this will too

#
guild = ctx.author.guild
    await ctx.send(len([m for m in guild.members if m.guild_permissions.administrator]))

no need of the variable

light violet
#

oo thanks

light violet
tender estuary
light violet
#

how to do that

tender estuary
#

if any error give here

light violet
#

ok

slate swan
#

isnt it ctx.guild?

#

Or both work?

tender estuary
#

both works

slate swan
#

uhuh

tender estuary
#

but ctx.author.guild narrows it down so I used it

slate swan
#

Hmm