#discord-bots

1 messages · Page 702 of 1

dire folio
#

i have no clue why

#

btw i mean the fields

honest vessel
#

inline=false

dire folio
#

wdym

dire folio
honest vessel
#

🤷🏻‍♂️

#

do u have it on all fields?

dire folio
#

no should i?

honest vessel
#

if u want them all to be like second pic u should?

velvet tinsel
#

You should have inline=True

dire folio
#

i thought it was only for the discord.Embed part

honest vessel
#

nah every field

#

add_Field

velvet tinsel
honest vessel
#

add_field(*, name, value, inline=True)¶

velvet tinsel
#

If you want them all to line up

velvet tinsel
dire folio
honest vessel
#

np doood

sullen shoal
#

inline should be False if you want them to look like the second picture

#

show more of your code

#

!d time.time ?

unkempt canyonBOT
#

time.time() → float```
Return the time in seconds since the [epoch](https://docs.python.org/3/library/time.html#epoch) as a floating point number. The specific date of the epoch and the handling of [leap seconds](https://en.wikipedia.org/wiki/Leap_second) is platform dependent. On Windows and most Unix systems, the epoch is January 1, 1970, 00:00:00 (UTC) and leap seconds are not counted towards the time in seconds since the epoch. This is commonly referred to as [Unix time](https://en.wikipedia.org/wiki/Unix_time). To find out what the epoch is on a given platform, look at `gmtime(0)`.

Note that even though the time is always returned as a floating point number, not all systems provide time with a better precision than 1 second. While this function normally returns non-decreasing values, it can return a lower value than a previous call if the system clock has been set back between the two calls.
sullen shoal
#

!d datetime.datetime.now

unkempt canyonBOT
#

classmethod datetime.now(tz=None)```
Return the current local date and time.

If optional argument *tz* is `None` or not specified, this is like [`today()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.today "datetime.datetime.today"), but, if possible, supplies more precision than can be gotten from going through a [`time.time()`](https://docs.python.org/3/library/time.html#time.time "time.time") timestamp (for example, this may be possible on platforms supplying the C `gettimeofday()` function).

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 current date and time are converted to *tz*’s time zone.

This function is preferred over [`today()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.today "datetime.datetime.today") and [`utcnow()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow "datetime.datetime.utcnow").
velvet tinsel
#

Hi myxi

fringe harness
#

Yo

#

Myxi

#

Can we talk in dms

steel void
#

Hey guys, im having an issue posting a time to a channel

#

@tasks.loop(minutes=1)
async def my_background_task():
format = '%Y-%m-%d %I:%M %p'
now_utc = datetime.now(timezone('US/Eastern'))
channel = client.get_channel(919746368027918357)
await channel.send((now_utc.strftime(format)))

#

any idea why

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

steel void
#
@tasks.loop(minutes=1)
async def my_background_task():
    format = '%Y-%m-%d %I:%M %p'
    now_utc = datetime.now(timezone('US/Eastern'))
    channel = client.get_channel(919746368027918357)
    await channel.send((now_utc.strftime(format)))
echo heart
#

how to limit my discord bot commands to a moderator role ?

final iron
unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
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 invoking the command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role.

If the message is invoked in a private message context then the check will return `False`.

This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
final iron
#

Or you could do a check by permissions

untold token
#

!d discord.ext.commands.has_any_role

unkempt canyonBOT
#

@discord.ext.commands.has_any_role(*items)```
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 invoking the command has **any** of the roles specified. This means that if they have one out of the three roles specified, then this check will return True.

Similar to [`has_role()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.has_role "discord.ext.commands.has_role"), the names or IDs passed in must be exact.

This check raises one of two special exceptions, [`MissingAnyRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") if the user is missing all roles, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingAnyRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
untold token
#

You can use this, for multiple roles

vague sundial
#

When I try to kick someone it says MissingPermissions even though I have written @commands.has_permissions(kick_members=True)

quick gust
#

does the bot have permission to kick the members?

spring flax
#

@manic wing have you got it?

manic wing
#

no

wanton jacinth
#
        channel = message.channel
        number = 1
        await channel.send("Guess a number from 0 to 20")

        def check(m):
            return m.author == message.author and m.channel == channel

        wait = await client.wait_for("message", check=check)

        if wait == str(number):
            await message.channel.send("Right!")
        else:
            await message.channel.send("Wrong. Try again!")```
#

Does anybody hot to fix this

#

Even if the user's response is correct (1) the bot says what it's wrong

wanton jacinth
#

No, but i can try

cloud dawn
#

I suggest doing that.

wanton jacinth
#

Ok hold a sec

wanton jacinth
#

where do i have to call the print in the program?

cloud dawn
#

Well where did you put it?

wanton jacinth
#

after creating it

#

under wait = await client.wait_for("message", check=check)

real stag
#

yes

cloud dawn
#

Well it has to print atleast None then

wanton jacinth
#

Nope

cloud dawn
real stag
#

sorry wrong server

wanton jacinth
#

discord.Client()

cloud dawn
#

You got intents on?

wanton jacinth
#

I'm not that good at english what do you mean

wanton jacinth
cloud dawn
#

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

rotund nova
#
@bot.command(name='giveaway')
@commands.has_any_role("ᴀᴅᴍɪɴ 🛡️","ᴄᴏ ᴏᴡɴᴇʀ 🛡️","ᴏᴡɴᴇʀ 👑")
async def gstart(ctx, time=None , *, price=None):
    if time == None:
        return await ctx.send("Wpisz czas!")
    if price == None:
        return await ctx.send("Wpisz nagrode!")

    await ctx.message.delete()
    
    time_convert = {"s": 1, "m": 60, "h": 3600, "d": 86400}
    gtime = int(time[0]) * time_convert[time[-1]]
    rozdanie = discord.Embed(title=":giveaway: **Giveaway!** :giveaway:", description=f"⭐ __**Do wygrania**__ ⭐: **{price}**\n⏲️ Kończy się za ⏲️: **{time}**", color=0x42c2f5)
    gmsg = await ctx.send(embed=rozdanie)
    await ctx.send(ctx.message.guild.default_role)

    await gmsg.add_reaction("🎉")
    await asyncio.sleep(gtime)

    nowy_gmsg = await ctx.channel.fetch_message(gmsg.id)

    users = await nowy_gmsg.reactions[0].users().flatten()
    users.pop(users.index(bot.user))

    zwyciezca = random.choice(users)

    await ctx.send(f"🎊 Gratulacje {zwyciezca.mention}! Aby zgłosić się po nagrodę, skontaktuj się z administracją na ticket'cie! 🎊")
``` How can I add to this code to update the time every 30 minutes?
rotund nova
#

u have idea how?

outer violet
mortal thistle
#

how can I get message?

#

like get_message?

#

or something

boreal ravine
upbeat otter
#

oopsie

#

wrong one nvm

boreal ravine
#

@boreal ravine should look like this

boreal ravine
unkempt canyonBOT
#
Not likely.

No documentation found for the requested symbol.

boreal ravine
#

what the fuck

rotund nova
outer violet
boreal ravine
boreal ravine
outer violet
boreal ravine
#

no

#

only check for the mention

gray frigate
#

Is there a method in dpy to look for messages without reactions in certain channel

outer violet
cedar stream
#

Lmfao 😭

gray frigate
shadow wraith
#

how this clean syntax lookin

#

basically:

  • used impractical groups just for a command
  • used bot.wait_for for the reaction
gray frigate
#

if I do that in on message event won't it effect the performance?

shadow wraith
sage otter
#

What a great help this guy is.

gray frigate
#

Thanks 😊👍🏻

shadow wraith
#

bro don't use bot.wait_for to check messages oh fu-

#

bot.wait_for has to be awaited i think

sage otter
shadow wraith
#

!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.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**...
sage otter
#

If you're using commands.Bot atleast.

gray frigate
#

Technically yes

shadow wraith
#

i once got rate limited by the discord api, now i make changes to my bot but don't load them that fast

velvet tinsel
sage otter
#

wotpepe why

velvet tinsel
#

I’ll also give it 5 stars

mental viper
#

how to get a bot to detect a word

slate swan
velvet tinsel
#

Why tf is the bot offline

velvet tinsel
slate swan
mental viper
velvet tinsel
#

Bro I don’t love humans

velvet tinsel
slate swan
velvet tinsel
#

I love bots

slate swan
velvet tinsel
#

I love your bot. Does that mean I love you?

slate swan
#

Yes

#

Im its father what do you expect

velvet tinsel
#

I’m asexual

#

But I love robots

slate swan
#

!ot

unkempt canyonBOT
mental viper
#

im confused

velvet tinsel
#

What are you confused about

mental viper
slate swan
#

Or use in

velvet tinsel
#

I can’t display the code since I’m on a phone lmao 😂

boreal ravine
#

!d discord.Message.content

unkempt canyonBOT
cedar plank
#

hello how i make my bot do a command in custom channelbnx4_smile

boreal ravine
#

do a command? wym

cedar plank
#

yes

slate swan
velvet tinsel
#

I have a question

slate swan
#

Send it

velvet tinsel
#

Can you check for profanities even if someone uses spoiler?

#

Like this ||fuck||

velvet tinsel
#

Alr

slate swan
#

Because your checking if in msg content theirs a word

#

So it would be :profanity:

velvet tinsel
#

Mm hm

slate swan
#

Ofc its their so yes

velvet tinsel
#

Would it sense for profanities even if it’s a emoji?

slate swan
#

Since spoiler uses |

crude crater
boreal ravine
#

message.content returns the raw message content lol

velvet tinsel
#

Oh

slate swan
velvet tinsel
#

What

You know what I’ll find out myself

crude crater
#

Okay

slate swan
#

In a msg it probably looks like:

Msg || lol || :kek:
crude crater
#

No it wouldn’t look like that

slate swan
#

How would it look like then

crude crater
#

Not like that

velvet tinsel
#

Then what would it look like

boreal ravine
slate swan
#

Is that really your explanation

slate swan
boreal ravine
#

what do you mean by what it would look like lol

velvet tinsel
#

“It wouldn’t look like that”

“Then what would it look like”

not that”

“Then what”

slate swan
#

Since you said it takes raw msg content

velvet tinsel
#

*ahem* he was pointing to your explanation to me

slate swan
#

🚶

sage otter
slate swan
mental viper
sage otter
#

It escapes mark down.

crude crater
tawdry perch
slate swan
sage otter
#

So ||hi|| would look like ||hi|| to the bot

tawdry perch
#

ah ok 😅

boreal ravine
velvet tinsel
slate swan
tawdry perch
velvet tinsel
sage otter
#

Yeah I fixed it

velvet tinsel
tawdry perch
slate swan
#

So how would it look like tyler is saying what i said and kayle is saying it doesn't

velvet tinsel
slate swan
#

Im having a stroke

tawdry perch
velvet tinsel
sage otter
velvet tinsel
#

I asked it already lmao 😂😂

slate swan
velvet tinsel
#

Naw I sent the link

crude crater
#

But you asked, and I said no

sage otter
#

Then yes

#

What i said is right

boreal ravine
slate swan
#

Alr

tawdry perch
#

ah, decorator is best choice so far imo

velvet tinsel
boreal ravine
patent nexus
#

CodLab 🧪

sage otter
#

Bots don’t see markdown. They literally see what was typed in.

slate swan
#

But does it see the emoji like this:

msg :kek:
#

?

boreal ravine
#

no

#

they see the raw content

velvet tinsel
velvet tinsel
slate swan
sage otter
#

Either like that or !oogh shit

velvet tinsel
boreal ravine
patent nexus
#

Hi

velvet tinsel
#

sweet

slate swan
tawdry perch
slate swan
sage otter
#

Mentions are seen as @sage otter

tawdry perch
#

Breh I thought it was a question

slate swan
sage otter
#

Basically

slate swan
#

Thank you tyler and kayle

slate swan
#

?

velvet tinsel
mental viper
#

Can you give me the example of a bot's code that detects a certain word, like "dog" for instance

velvet tinsel
boreal ravine
crude crater
slate swan
boreal ravine
velvet tinsel
crude crater
slate swan
#

Wiser has said no to me like five times with no explanation i dont see if hes helping or not

velvet tinsel
#

Yeah me neither

slate swan
#

Seems like hes trolling

velvet tinsel
#

why “no” lmao

slate swan
#

Yeah

slate swan
#

Right there

manic wing
#

no is a good word but only if its justified

velvet tinsel
#

Caeden is the expert he’ll explain

crude crater
slate swan
#

Yeah but he never justifies it

velvet tinsel
#

But you never provided context

slate swan
slate swan
velvet tinsel
#

You’re just saying “no”

crude crater
velvet tinsel
#

Where

crude crater
velvet tinsel
#

I do not recall you explaining anything

sage otter
#

This guy has to be shitposting right now.

crude crater
slate swan
#

The sentence starts with "No"

slate swan
velvet tinsel
slate swan
velvet tinsel
crude crater
slate swan
#

No

velvet tinsel
#

No

slate swan
#

Ok ill stop

#

Lol

velvet tinsel
#

Anyways someone ask a goddamn question

slate swan
#

Yup

crude crater
velvet tinsel
#

Before I do something I’ll regret

slate swan
velvet tinsel
#

Stop spamming emojis

slate swan
#

!ot

crude crater
unkempt canyonBOT
velvet tinsel
#

!ot-names || they changed the name of the command

unkempt canyonBOT
slate swan
#

I should read docs on how to use regex and i should go learn sql because i havent

velvet tinsel
#

I should learn js

slate swan
velvet tinsel
#

I did not say that, however if you want me to ping the mods then ok

velvet tinsel
crude crater
#

!rule 7

unkempt canyonBOT
#

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

untold token
#

what even is going on here

slate swan
velvet tinsel
velvet tinsel
#

Ask a goddamn question before I do something I’ll regret

slate swan
slate swan
velvet tinsel
#

Right

#

That’s it

#

I’m eating dinner

slate swan
#

🕴️

#

Can i get some

crude crater
crude crater
crude crater
unkempt canyonBOT
#

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

slate swan
#

The shitpost in here

#

Im going to eat breakfast later guys🚶

crude crater
jade tartan
#

But i want my bot to kick them

untold token
jade tartan
#

Can it not do that?

slate swan
untold token
#

you should add the if statement that checks if the message user is the bot itself

untold token
crude crater
slate swan
#

But doesnt the bot framework not respond to itself?

#

Or it does

jade tartan
untold token
jade tartan
#

S

untold token
#

not commands

slate swan
tawdry perch
slate swan
velvet tinsel
untold token
#

np

slate swan
#

Never knew that lol

untold token
#

the docs say that though

#

!d discord.on_message

unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.

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

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
slate swan
#

Guess im blind

untold token
#

see, the bot can respond to its own message

slate swan
velvet tinsel
#

yeah

crude crater
velvet tinsel
slate swan
#

No

#

😭

#

Ok bye guys

crude crater
slate swan
#

Ok

velvet tinsel
velvet tinsel
slate swan
#

💀

velvet tinsel
#

Learn dpy

#

Actually

crude crater
slate swan
velvet tinsel
#

Learn common sense

slate swan
#

Or buttons

velvet tinsel
slate swan
#

I made buttons

velvet tinsel
slate swan
#

Because you dont know them

velvet tinsel
slate swan
velvet tinsel
#

Oh true

#

Bro you don’t use career karma

slate swan
#

Learn buttons its not that hard

velvet tinsel
#

😳

velvet tinsel
slate swan
#

Just check the examples in disnakes git

velvet tinsel
#

Ok mr smartypants

slate swan
velvet tinsel
#

I didn’t see the use in buttons

crude crater
slate swan
#

Buttons > reactionsyert

velvet tinsel
#

Why should we let the user decide what to do, when we can do things for them

slate swan
#

🕴️

velvet tinsel
#

It’s called communism

slate swan
#

Your excuses not to learn buttons are huge

velvet tinsel
#

We serve the people, not ourselves (well, occasionally)

velvet tinsel
slate swan
boreal ravine
velvet tinsel
#

I have a question

slate swan
velvet tinsel
slate swan
velvet tinsel
#

Naw I was joking

#

I love pressing buttons, but not making it

boreal ravine
#

!ot

unkempt canyonBOT
spark wigeon
#

is discussion of selbotting allowed

boreal ravine
#

no

velvet tinsel
boreal ravine
velvet tinsel
#

How was discord.py created? Did he use a web scraper or something

manic wing
#

discord has an api and all discord.py does is interact with said api

velvet tinsel
#

Ok

boreal ravine
manic wing
#

you should look at the source code

velvet tinsel
#

Will do

boreal ravine
#

all it does is use aiohttp/websockets

slate swan
#

Dekriel did you thought dpy was an api💀

velvet tinsel
#

Does that mean I can create my own discord py

velvet tinsel
slate swan
#

Andy is actually making an api wrapper for the discord api

velvet tinsel
slate swan
velvet tinsel
#

Built for Okimii

#

Because he loves anime

slate swan
#

Good

#

I was thinking of making a reddit api wrapper but idk how to start

jade tartan
boreal ravine
manic wing
velvet tinsel
velvet tinsel
#

I love it when he goes god mode

slate swan
#

Hes always making huge paragraphs like andy for a reason

#

They would give you a whole page of info if you wanted

boreal ravine
manic wing
slate swan
manic wing
#

it does

#

!pypi asyncpraw || also this

unkempt canyonBOT
#

Async PRAW, an abbreviation for `Asynchronous Python Reddit API Wrapper`, is a python package that allows for simple access to reddit's API.

slate swan
#

I have to read some documentation on what are exactly endpoints web sockets and others

velvet tinsel
#

Kayle

#

Why

slate swan
velvet tinsel
#

Also if I made an API for self bots what would happen

boreal ravine
slate swan
velvet tinsel
#

Ok

boreal ravine
velvet tinsel
#

I’m only learning JS because of a grudge

#

Against a website

slate swan
velvet tinsel
#

It isnt that serious

manic wing
#

im learning c++ for one reason and one reason only; you can compile it to an exe without windows pissing itself

velvet tinsel
#

All it does is break their terms

velvet tinsel
#

Nothing else

boreal ravine
slate swan
#

I wanna learn js but im going to learn sql first and master it and then ill go to js

manic wing
#

learning sql 🤸‍♀️

slate swan
#

How do I fix this error?

embed = discord.Embed(colour=0xd7832b,timestamp=ctx.message.created_at)

AttributeError: 'NoneType' object has no attribute 'created_at'

boreal ravine
#

python objects can change at any time but in static languages you must explicitly define the type lol

velvet tinsel
#

However instead of using JS I can just access their API, but that doesn’t react with anything really

slate swan
manic wing
boreal ravine
#

use discord.utils lol

slate swan
#

Utild💀

boreal ravine
#

!d discord.utils.utcnow

unkempt canyonBOT
#

discord.utils.utcnow()```
A helper function to return an aware UTC datetime representing the current time.

This should be preferred to [`datetime.datetime.utcnow()`](https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow "(in Python v3.9)") since it is an aware datetime, compared to the naive datetime in the standard library.

New in version 2.0.
boreal ravine
#

or use datetime.datetime's version if you aren't using 2.0

manic wing
#

im making the worlds best help command, wish me luck

dull stirrup
#

I need some help with how my bot pulls and sends info from a json file in help-pineapple

slate swan
boreal ravine
slate swan
#

wdym

boreal ravine
#

you call it using a parenthesis

velvet tinsel
#

<@&831776746206265384>

boreal ravine
#

<@&831776746206265384>

wintry panther
slate swan
#

where has auto mode gone wtf

fast warren
#

!ban 909842478293733377 racism

unkempt canyonBOT
#

:x: User is already permanently banned (#57593).

wintry panther
#

wait a space at end?

boreal ravine
wintry panther
#

oh

slate swan
#

I installed a discord.py fork, how do I uninstall it

#

This is the cmd to install it

pip install -U git+<link>
boreal ravine
#

pip uninstall module

slate swan
#

But it's a link

#

a github link

final iron
#

Just pip uninstall the package

slate swan
slate swan
final iron
#

Whats the issue?

slate swan
#
ERROR: You must give at least one requirement to uninstall (see "pip help uninstall")
#

I wrote pip uninstall <github_link_here>

manic wing
#
@commands.command(
        aliases=['h', 'commands', 'cmd', 'command', '?', 'helpme', 'helpcommand', 'cmds']
        )
    async def help(self, ctx:Context, command=None) -> None:
        if not command:
            embed = await self.main_help(ctx)
            return await ctx.send(embed=embed)
     
        cmd = self.bot.get_command(command)
        if cmd:
            embed = await self.specific_command(cmd)
            return await ctx.send(embed=embed)

        cog = self.bot.get_cog(command.capitalize())
        if cog:
            embed = await self.specific_cog(cog, ctx)
            return await ctx.send(embed=embed)

        embed = await self.no_command(ctx)
        return await ctx.send(embed=embed)
manic wing
#
async def no_command(self, ctx:commands.Context) -> disnake.Embed:
        message = ctx.message.content.replace(f"{ctx.prefix}{ctx.invoked_with} ", "").strip()
        commands = [f"- `{k.name}`" for k in self.bot.commands if k.name.startswith(message[0]) and not k.hidden]
        
        embed = disnake.Embed(
            description="**Did you mean:**\n" + '\n'.join(commands)
        ).set_author(
            name=f"{message} is not a command!",
            icon_url=ctx.author.avatar.url,
        )
        return embed
#

sexy code

final iron
#

What is it

boreal ravine
#

its in message class @final iron

lost wolf
#

is it possible to create custom commands in dpy?

manic wing
#

?

lost wolf
#

where you can make your own commands for each server?

manic wing
#

well there was a great link for it

#

but i lost it

boreal ravine
#

lost

manic wing
#

easy to do

lost wolf
#

well im new to dpy

slate swan
boreal ravine
manic wing
#

?

manic wing
lost wolf
#

is it possible to create custom commands in dpy?

boreal ravine
manic wing
#

i dont want that

boreal ravine
#

why did i click it

#

ok

boreal ravine
lost wolf
#

is slash commands possible in dpy?

boreal ravine
thorn osprey
#

why give me this error?

boreal ravine
#

but in dpy forks

boreal ravine
thorn osprey
boreal ravine
#

wrong token then

thorn osprey
boreal ravine
#

are you sure you copied the right thing

#

(token)

thorn osprey
#

yes

#

do want a source

#

؟

boreal ravine
#

uh

slate swan
#

Ignoring exception in command join:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 77, in join
channel = ctx.message.author.voice.voice_channel
AttributeError: 'VoiceState' object has no attribute 'voice_channel'

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

Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'VoiceState' object has no attribute 'voice_channel'

potent spear
slate swan
#

the same problem

potent spear
#

not true mate

slate swan
#

wait

#

old screenshot

potent spear
#

read what I type

slate swan
#

ok

thorn osprey
#
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001FB92A04EE0>
Traceback (most recent call last):
  File "C:\Users\DR_Nitrogen\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\DR_Nitrogen\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\DR_Nitrogen\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon
    self._check_closed()
  File "C:\Users\DR_Nitrogen\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed        
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed```
#

whyyyyyyyyy

potent spear
thorn osprey
#

yess

#

@potent spear

mental viper
#

how to define bot in bot.listen

potent spear
sick birch
#

And I don't really think that's possible as to have a bot.listen() you need a bot instance in the first place

velvet tinsel
#

You don’t need to

#

if you already have a commands.Bot

mental viper
#

this girl said to put this

velvet tinsel
#

*boy

#

And also yeah you do that

mental viper
#

but how do I define bot
in @bot.listen()

velvet tinsel
#

If you already have a bot = commands.Bot()

#

!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.
sick birch
#

Didn't you want a commands.Bot() inside your @bot.listen()?

velvet tinsel
#

I don’t think they have a commands.Bot

#

They’re probably using Client

sick birch
#

Yeah that's the older way to do things

#

If you're going to make commands I strongly recommend you use commands.Bot

velvet tinsel
#

Yeah

velvet tinsel
sick birch
#

commands.Bot subclasses discord.Client so it does everything discord.Client can and more

mental viper
velvet tinsel
#

Eh

velvet tinsel
#

yeah, commands.Bot is amazing

mental viper
#

so I add bot = commands.Bot()?

velvet tinsel
#

Don’t forget all the kwargs and stuff

#

bot = commands.Bot(command_prefix=..., help_command=... Intents=...)

sick birch
#

command_prefix and intents are the most important

#

bot won't really function without those

mental viper
#

im a beginner so l dont understand much of what you are trying to say

velvet tinsel
#

bot = commands.Bot(command_prefix="whatever you want it to be")

#

command_prefix is a kwarg

#

pass in your command prefix there

sick birch
velvet tinsel
#

put it before your @bot.event

sick birch
#

Heck you shouldn't do anything except printing in on_ready

wispy plover
#

I am confused about discord.py should I use that library to create discord bot or not ?

sick birch
#

It's personal preference

#

If you want to sure, if you don't then sure as well

velvet tinsel
wispy plover
#

But I heard it's shutting down so I am concerned about using it

sick birch
#

I would say discord.py is the best for python as it's had the most time to mature and get as good as it can get, if you want to make it in different languages there are most likely libraries there as well

sick birch
#

If you need to implement slash commands, you can easily do so yourself with the base discord.py library without any forks

#

Personally I prefer this over the forks as I don't really trust them as they're not as mature as the discord.py library, but if you want to use the forks you are more than welcome to do so

mellow gulch
#

if i have a variable called player1 which has a discord name like TawdryDragon#2484 how would I add a role to someone with just that variable

sick birch
#

It would be preferable the variable had an ID

#

but if there's absolutely no possible way to store the ID, then you can use utils.get()

mellow gulch
#

well can u gib me an example?

sick birch
#

Of using an ID or with the name?

mellow gulch
#

would it be like player1 = utils.get(id)

sick birch
#

If you had the ID it would be

player1 = guild.get_member(id)
mellow gulch
#

ok and then how do i get the id of player1 with player1 being TawdryDragon#2484

sick birch
#

Well how did you get the name in the first place

#

I mean how did you set player1 to TawdryDragon#2484

#

Through a command?

mellow gulch
#

it is what i got from someone pressing a button

#

with nextcord

sick birch
#

interaction.user is a discord.User object, not a name

#

you most likely did something like so:

player1 = interaction.user.name
mellow gulch
#
@nextcord.ui.button(label='Join', style=nextcord.ButtonStyle.primary)
    async def who_plays_game_button1(self, button: nextcord.ui.Button, interaction: nextcord.Interaction):
        userid.append(interaction.user)
        for index in userid:
            print (index)
        self.value = 1
        self.stop()```
sick birch
#

I see

#

you should probably append interaction.user.id instead

#

considering the name of the variable is userid

velvet tinsel
#

oh nextcord

sick birch
#

Also it's probably printing TawdryDragon#2484 instead of the object itself because discord.User has a __repr__ dunder

#

Your userid is actually a list of user objects

mellow gulch
#

as far as i know

velvet tinsel
#

I prefer disnake

manic wing
#

^

#

fuck nextcord

coarse island
#

can anyone help me create a bot?

manic wing
#

no.

sick birch
unkempt canyonBOT
#

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

It prints whatever I return here instead of the actual object
sick birch
#

!e

class MyClass:
  pass
print(MyClass())
unkempt canyonBOT
#

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

<__main__.MyClass object at 0x7fc44fe31120>
sick birch
#

It just prints the memory location of the object

mellow gulch
sick birch
mellow gulch
#

how do i get guild

pliant gulch
#

add_roles

#

And it's a coroutine

slate swan
velvet tinsel
#

uhh..

slate swan
velvet tinsel
#

yeah....

#

it's cool though

slate swan
#

Ikryert

velvet tinsel
#

pretty cool

mellow gulch
#

how do i get the guid from a user id

crude crater
unkempt canyonBOT
manic wing
#

-_

mellow gulch
manic wing
#

best help comman

slate swan
#
import disnake, json, asyncio, traceback
mellow gulch
sick birch
#

You can also get a guild by ID using bot.get_guild(...)

manic wing
mellow gulch
slate swan
sick birch
sick birch
manic wing
#

nah man pep-8 is horny for me

slate swan
slate swan
sick birch
#

😂

mellow gulch
sick birch
#

The ID of the guild

slate swan
mellow gulch
manic wing
#

import disnake,

pliant gulch
#

The typehints too

manic wing
#

import disnake, json

pliant gulch
#

They should be foo: type

#

Not foo:type

slate swan
#

It hurts

manic wing
#

ok fine ill change that

slate swan
sick birch
manic wing
#

and ill make an __init__.py to import * from emojis

pliant gulch
#

Why are all your add_fields like that to

pliant gulch
#

Def does not look good code wise kek

sick birch
#

looks more like javascript than anything

mellow gulch
manic wing
sick birch
#

subjective

slate swan
#

I think hes delusional

sick birch
#

nah he just likes his help command

slate swan
#

!pep8 here caeden

unkempt canyonBOT
#

PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.

More information:
PEP 8 document
Our PEP 8 song! :notes:

pliant gulch
# manic wing *creaming

Typehinting for the second photo is wrong command should be command: Optional[str] and the return statement is disnake.Message as you are returning send

sick birch
#

a nice looking embed can make anyone happy

slate swan
#

It does look good tho

sick birch
#

The embed? yeah

#

Code? not so much

pliant gulch
slate swan
sick birch
#

lmaoo

sick birch
#

The code is just as important as the end result

pliant gulch
slate swan
sick birch
# mellow gulch

Can mean a few things:

  • Bot is not in the guild
  • Guild is not in the cache
  • You gave the ID as a string (must be an integer)
pliant gulch
#

Pyright

slate swan
pliant gulch
#

I already told you about it as well

#

Kek

slate swan
#

My fault

slate swan
#

Its just my vsc screams when i downloaded it

sick birch
#

Are you sure the bot is in the guild?

slate swan
#

It just says to turn off pylance and it screams in pain

slate swan
pliant gulch
#

Doesn't pylance already have pyright

#

🤔

sick birch
#

i've been getting tired of dynamically typed languages these days lmao

#

main reason i've been using typescript

slate swan
#

Idek what you mean by a type checker

sage otter
#

Is PyLance some type of linter or something?

slate swan
manic wing
#

andy

#

find a way to dis my main.py

#
"""
The MIT License (MIT)

Copyright (c) 2020-present CaedenPH

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMxITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
"""

from core import JesterBot  

if __name__ == "__main__":
    JesterBot().run()


pliant gulch
slate swan
#

Yeah pylance does it lol

sick birch
pliant gulch
mellow gulch
sick birch
#

bot.fetch_guild(...)

pliant gulch
#

Its just a waste of lines

slate swan
#

Andy always finds something to dis

manic wing
#

imagine having so little storage each line matters

sick birch
#

me with 9 gigs left of my drive

pliant gulch
#

Each line should matter when you code lol

manic wing
slate swan
sage otter
#

Rich people

pliant gulch
#

My current code does so much but uses 120 gbs!!! But my friend has made code that does the same thing but is 10 gbs

#

Can you see how that would matter lol

slate swan
sage otter
#

With their 20,000 tb hdds

sick birch
mellow gulch
sick birch
#

though i'm planning on getting a tb ssd for christmas lmao

pliant gulch
#

dual boot 😬

sick birch
#

mans gotta play his games

pliant gulch
slate swan
#

My code only reaches 4kb😭

pliant gulch
#

Just check proton db

manic wing
#

awk

pliant gulch
#

Most steam games are supported now

#

They also getting support for easy anti cheat

sick birch
#

yeah windows just runs them better tbh, just a lot of little tiny annoyances

slate swan
#

I still havent broken 500lines in a project 😔

pliant gulch
#

To stubborn to use windows

#

Thank god

slender perch
#

bro im lucky to reach over 30 mb

sick birch
#

i really wish i didn't have to use their bloatware trashy os but i'm left with no choice haha

slender perch
#

i usually have under 1gb left, unless i go through my whole ass drive

slate swan
#

I havent even reached a mb💀

slender perch
#

clear your temp files or smth

#

you could also delete/move the biggest files on your desktop

#

and move your downloads

#

that works for me

slate swan
#

Ik lol

pliant gulch
#

My whole wrapper is only 6.55mb

slender perch
sick birch
#

9.4 for me

slender perch
#

all of my codes are small asf

#

im too lazy to make over 100 lines of code

#

50*

slate swan
#

I need a sata cable to add 3tbs to my desktop and ill have 4.5tb finally 🕴️ 🚶

slender perch
#

50-100 actually

pliant gulch
mellow gulch
sick birch
#

you need an ID and await it

slender perch
#

i have like, 3.5 tb, all of my shit goes to my c drive tho

sick birch
slate swan
#

Most of my projects are 400lines still havent broken 500lines

slender perch
#

the rest are filled with other shit

slate swan
sick birch
#

ahh yes

sage otter
slate swan
#

Im jk idk i just like having allot of space

sick birch
#

sure buddy

pliant gulch
#

Claustrophobic

slate swan
slate swan
mellow gulch
#

@sick birch so this?

slender perch
#

my most complex program was like 50 lines and it was a bot info checker

manic wing
#

global makes me cry

slender perch
#

probably less

slate swan
#

What is global for never used it

slender perch
#

like 30-40

sage otter
slate swan
slender perch
#

im still a stinky programmer ngl, i dont know most of this shit
i mainly just use stacks or github and ctrl c/v

sage otter
#

👌

sick birch
slate swan
sick birch
#

that should add it to your cache

slate swan
sick birch
#

if that doesn't work then the bot isn't in the guild

#

you might wanna store it in a variable though

slender perch
#

i was thinking about making a discord bot that sets someones nick to a stupid name if it starts with a !

pliant gulch
unkempt canyonBOT
#

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

001 | 0
002 | 1
sick birch
#

globals

pliant gulch
#

You also have keywords like nonlocal

sick birch
#

why must you hurt me in this way

pliant gulch
#

Useful some times

sick birch
#

i was told globals are bad and you should stay away from them

pliant gulch
#

!e ```py
def wrapper(func: callable) -> None:
def inner():
nonlocal func
func = lambda: True

inner()
return func

func = wrapper(print)
print(func)

#

Idk this was really a bad example but I use nonlocal sometimes

hot cobalt
unkempt canyonBOT
#

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

<function wrapper.<locals>.inner.<locals>.<lambda> at 0x7fb200218ca0>
slate swan
#

And what the heck is

nonlocal
hot cobalt
#

They tangle everything up into an absolute mess. Values are being changed and accessed from god knows where, making it very hard to follow the code and try debug it

pliant gulch
#

Yes globals are bad mostly, python is a multi paradigm language, so you have OOP and stuff, much better to create a class instance variable and mutate that from within methods

mellow gulch
pliant gulch
#

Easier to track which is one of the problems of global as well

lament mesa
#

You could use mutable data types as an alternative to globals, like dictionary

pliant gulch
#

Classes are basically just dictionaries

sick birch
pliant gulch
#

Real pimped out dictionaries

lament mesa
#

yeah

mellow gulch
#

does anyone know why this does not work in giving me a role

pliant gulch
#

Your inside of an if statement that checks if index == open then you add the roles in a nested if statement that checks if the same index is somehow 0 now

#

🤔

mellow gulch
#

@pliant gulch so i fixed index==open to multiplayer_spots==open and now there is this error:
TypeError: list indices must be integers or slices, not str

#

What do i fix

#

Anyone know what i then do

#

anyone know what is wrong with the line i am on

#

this is the creation of the list

slate tartan
#

index would be each element in the list (which is a string)
That's why you are getting a TypeError

#

@mellow gulch

mellow gulch
#

Oki

slate tartan
outer violet
#

Is it possible to get the cooldown of a command? Like this?

outer violet
velvet tinsel
#

error handler

ripe jackal
#

or asyncio.sleep 🙂

#

@outer violet

velvet tinsel
velvet tinsel
ripe jackal
#

why not?

outer violet
velvet tinsel
#

because there's a command for cooldowns

velvet tinsel
#

shit

outer violet
velvet tinsel
#

sorry

#
@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        await ctx.send('This command is on a %.2fs cooldown' % error.retry_after)

something like this

outer violet
#

Still not that

slate swan
#

Hi

velvet tinsel
#

just add it into your embed lmao

velvet tinsel
velvet tinsel
brittle harness
#

How do I set the bot's Icon status so like Idle and DND and all that.

vivid pilot
#

I have a feeling this question gets asked a lot so sorry, but is there any clear front-runner for the successor to discord.py yet?

ripe jackal
#

@outer violet explain a lil idk what to recommend while you're not explaining lmao

velvet tinsel
#

and use it in your embed

velvet tinsel
ripe jackal
#

yes but for what

outer violet
#

Like so I’m making a help command and for the on_command_help and I want to display the number of the cooldown in the embed like this

ripe jackal
#

oh

slate swan
#

Not sure

ripe jackal
#

you should make variable with the time amount to wait and add it into a new embed field ig

velvet tinsel
ripe jackal
#

idk

velvet tinsel
#
@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        await ctx.send('This command is on a %.2fs cooldown' % error.retry_after)
ripe jackal
#

das what im thinking lmao

velvet tinsel
#

just make it an embed lmao

#

what's so hard

supple thorn
#

Shes subclassing help command

velvet tinsel
supple thorn
#

@outer violet

#

Your a she right

outer violet
#

Yes 💀

ripe jackal
#

lmao

supple thorn
velvet tinsel
#

:yea:

supple thorn
#

Guessed correctly

velvet tinsel
#

they're making a custom help cmd or what

ripe jackal
#

hahaha

velvet tinsel
#

she

#

anyways im actually gonna go sleep bye 😳

outer violet
#

Eh?

heavy folio
#

brb

mellow gulch
shrewd inlet
#

how do i make a command that will have text and an embed as well

#

like i know how to make a command with an embed but i want to also add normal text along with the embed

slate swan
#

Is there a way to code an event that gives the first 50 members a specific role?

slate swan
worldly bane
#

how to convert minutes to unix timestamp (for timestamp)

shrewd inlet
#

what is the variable for tag for example : ernest#0001 no mention just the username and the tag ?

slate swan
#
await ctx.send(ctx.author.name)
#

this?

heavy folio
#

!d discord.utils.format_dt if you wanna use unix timestamp use this

unkempt canyonBOT
#

discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.9)") for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
ripe jackal
shrewd inlet
worldly bane
ripe jackal
#

it is in python 🙂

heavy folio
unkempt canyonBOT
#

class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").

x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.

x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.

hash(x) Returns the member’s hash.

str(x) Returns the member’s name with the discriminator.
slate swan
#

scroll up @shrewd inlet

shrewd inlet
slate swan
shrewd inlet
#

ernest#0001

#

the name + the discriminator

ripe jackal
slate swan
#

i think it will send it

heavy folio
shrewd inlet
#

wouldn’t it be

heavy folio
#

that'll return hello, not hello#1234

shrewd inlet
heavy folio
#

ctx.author does it

shrewd inlet
#

alr

ripe jackal
#

yh

visual island
heavy folio
#

oh yes yes

#

@shrewd inlet string it

shrewd inlet
#

how do you string something

visual island
#

str()

shrewd inlet
#
@bot.command()
async def on_member_join(member):
  guild = bot.get_guild(917821802351308910)
  channel = guild.get_channel(917826956295303219)
  embed = discord.Embed(title="**{member.name}{member.discriminator}** has joined the server.",color=0x2f3136)
  await channel.send("{member.mention} <@&917950907445039154>",embed=embed)
#

does that work?

visual island
shrewd inlet
#

i want it to be like ernest#0001

visual island
#

str(member)

#

or just member is fine as you're using f string

heavy folio
shrewd inlet
#
@bot.command()
async def on_member_join(member):
  guild = bot.get_guild(917821802351308910)
  channel = guild.get_channel(917826956295303219)
  embed = discord.Embed(title="**str(member)** has joined the server.",color=0x2f3136)
  await channel.send("{member.mention} <@&917950907445039154>",embed=embed)
shrewd inlet
#

so that?

shrewd inlet
heavy folio
#

{str(member)}

#

have to use it in a bracket

shrewd inlet
#
@bot.command()
async def on_member_join(member):
  guild = bot.get_guild(917821802351308910)
  channel = guild.get_channel(917826956295303219)
  embed = discord.Embed(title="**{str(member)}** has joined the server.",color=0x2f3136)
  await channel.send("f{member.mention} <@&917950907445039154>",embed=embed)
#

so that

visual island
#

!f-string

#

!f-strings

unkempt canyonBOT
#

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

visual island
#

use the f

shrewd inlet
#
@bot.command()
async def on_member_join(member):
  guild = bot.get_guild(917821802351308910)
  channel = guild.get_channel(917826956295303219)
  embed = discord.Embed(title=f"**{str(member)}** has joined the server.",color=0x2f3136)
  await channel.send(f"{member.mention} <@&917950907445039154>",embed=embed)
slate swan
#

you forgot a f string in the title kwarg

shrewd inlet
#

edited

#

is that right ?

slate swan
#

there

#

nope