#discord-bots

1 messages · Page 840 of 1

unkempt canyonBOT
#

class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.

New in version 2.0.
nimble plume
#

Hec

slate swan
#

yes it was

nimble plume
nimble plume
slate swan
slim ibex
#

disabled disables it prolly

nimble plume
slate swan
hoary cargo
nimble plume
#

😑

hoary cargo
#

sure

nimble plume
#

Tell his name who tells js is hard

kindred drum
#
guild =  await bot.get_guild(915357451484790916)
TypeError: object NoneType can't be used in 'await' expression```
#

anyone got as solution

nimble plume
#

no idea

nimble plume
nimble plume
vale blaze
#

Because its never worked for me. It's just broke all the time when I tried to implement it there

nimble plume
#

It say nonetype

slim ibex
kindred drum
# nimble plume No
await guild.unban(member_real)
AttributeError: 'NoneType' object has no attribute 'unban'```
slate swan
pale turtle
slim ibex
#

!d discord.ext.commands.Bot.get_guild

unkempt canyonBOT
kindred drum
#
    @tasks.loop(seconds=5.0)
    async def tempbancheck(self):
        for i in range (0, len(Scammer_Items)):
            for x in Scammer_Items[i]:
                
                if Scammer_Items[i][x]['Expired'] == True:
                    pass
                else:   
                    unban_date = Scammer_Items[i][x]['Date Expiration']
                    formatted_time = datetime.datetime.fromisoformat(unban_date)
                    if formatted_time < datetime.datetime.now():
                   
                        member_real = await bot.fetch_user(x)
                        guild =  bot.get_guild(915357451484790916)
                        
                        await guild.unban(member_real)
                        print("unbanned")
                        
                        Scammer_Items[i][x]['Expired'] = True
                        json.dump(Scammer_Items, open("./Cosmic overground/punishments.json", "w"), indent=1)```
hoary cargo
#

WHYYYYYYYYYY the no profile people take over

slate swan
#

!code

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.

nimble plume
#

USE CTX ARG

slate swan
#

!course

tacit token
#

thanks but

slim ibex
slate swan
#

!course python

nimble plume
#

self , ctx

quick gust
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.

pale turtle
final iron
slim ibex
#

But try removing the await and see if it works I guess

slim ibex
slate swan
pale turtle
#

It'll probably return None if the guild wasn't found in cache

final iron
#

If you don't know how to help, don't

nimble plume
#

Alright.

slim ibex
final iron
#

get_channel also isn't a coro

hoary cargo
final iron
#

!d discord.Guild.get_channel

unkempt canyonBOT
#

get_channel(channel_id, /)```
Returns a channel with the given ID.

Note

This does *not* search for threads.
final iron
#

See

tacit token
#

guys i try add emoji to button and

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Object of type Emoji is not JSON serializable```
kindred drum
#

strange

#

its just the guild that returns as none

tacit token
#
await client.get_channel(int(channel_id)).send(embed=embed, components=[[Button(style=ButtonStyle.grey, emoji=pipa, label=f"Done {reportemoji}", custom_id="button_r_d")]])
        await member.send(embed=embed2)
kindred drum
#

oh

nimble plume
#

Lol

nimble plume
#

Lolll

slim ibex
#

that’s what I’m saying

kindred drum
#

I know what it is @final iron lmao, it doesn't wait for on_ready so the guild doesn't load before it checks the first time

hoary cargo
#

It's cursed

tacit token
slim ibex
kindred drum
#

actually such a annoying error

nimble plume
#

Ye

tacit token
final iron
slim ibex
#

^

nimble plume
slim ibex
#

looks like a fucking CST or something

nimble plume
final iron
#

It's unreadable

distant pendant
#

Is it possible to mention a user in an embed?

nimble plume
tacit token
#

if u dont use emoji in the code its this:

nimble plume
#

ok

slim ibex
unkempt canyonBOT
nimble plume
distant pendant
nimble plume
slate swan
#

@nimble plume i search video of code with harry but so many video coming of python which video this

meager chasm
distant pendant
nimble plume
#

Never tryed

meager chasm
honest vessel
#

await send(f"{member.mention}", embed=embed)

slate swan
nimble plume
left crater
nimble plume
distant pendant
honest vessel
#

then only in description i think u can use mention @nimble plume

slate swan
#

@nimble plume give me video in dm

nimble plume
#

Yes

honest vessel
#

99% of my embed they only use description xD

hoary cargo
#

^ anyway it's irrelevant because it won't ping them

nimble plume
nimble plume
#

in description it works

slate swan
kindred drum
#

whats the best way to deal with the problem of dming users with dms turned off?

honest vessel
#
description = f""
description += f"more data text {var}"
em = Embed(description=description, colour=dh.color["blurple"])
await ctx.send(embed=em, delete_after=20)
``` 99% of my embeds looks like this
nimble plume
#

Claim a help channel

nimble plume
#

🟦 + 🟪 = 💥

honest vessel
final iron
nimble plume
final iron
#

You can't do anything about it

hoary cargo
kindred drum
#

yeah but how do I bypass the error in the best way so it just runs the other code

#

oh god

final iron
#

try except block

kindred drum
#

is there no like global way I can deal with it? cause I really dont wanna go edit every command

#

😭

honest vessel
#

and i have this in a file that i import

# Colors for embeds
color = {"blurple" : 0x7289DA, "green" : 0x33ff57, "yellow" : 0xFFD300, "red" : 0xB22222}


def embed(title="", description="", url="", colour=None):
    em = disnake.Embed(title=title, description=description, url=url, colour=colour)
    return em
meager chasm
unkempt canyonBOT
#

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

The default command error handler provided by the bot.

By default this prints to [`sys.stderr`](https://docs.python.org/3/library/sys.html#sys.stderr "(in Python v3.9)") however it could be overridden to have a different implementation.

This only fires if you do not specify any listeners for command error.
hoary cargo
hoary cargo
nimble plume
#

Huh

frank tartan
#
  channel = client.fetch_channel(944270496659279882)
  msg = await channel.fetch_message(944461110717841448)

thats my code, and this is the error messsage

Unhandled exception in internal background task 'updateMessage'.
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 168, in _loop
    await self.coro(*args, **kwargs)
  File "main.py", line 33, in updateMessage
    msg = await channel.fetch_message(944461110717841448)
AttributeError: 'coroutine' object has no attribute 'fetch_message'
kindred drum
#

like it wont run the part after

meager chasm
slate swan
#

@nimble plume which i watch 1 year or 6 months

frank tartan
nimble plume
#

1

honest vessel
#

@frank tartanwhen u get AttributeError: 'coroutine' its you forgot use await

meager chasm
#

what

slate swan
nimble plume
#

Ya

slate swan
final iron
#

!ot @slate swan @nimble plume

unkempt canyonBOT
final iron
#

You're just clogging up the channel

nimble plume
#

Im not he is pinging me

slate swan
final iron
slate swan
final iron
#

You're clogging up the channel

honest vessel
#

cause you talking about videos and hindi

#

its irrelevant for everyone else

nimble plume
#

Ok ill ignore him

slate swan
#

ok

drowsy condor
#

how to make on_member_join only work on one server.

meager chasm
#

what?

honest vessel
#

check if ctx.guild is that guild

#

you only want

quick gust
honest vessel
#

yeah i just figured

quick gust
#

check if member.guild = your guild variable

final iron
hoary cargo
honest vessel
#

yeah

#

exactly

quick gust
#

or that, yeah

drowsy condor
#

What is 1234?

hoary cargo
#

the guild id uncanny

drowsy condor
#

Oh

#

Sorry im stupid

#

🦧

honest vessel
#

1234 aint a guild id, its just an integer

hoary cargo
honest vessel
hoary cargo
#

mike bro

nimble plume
#

def function(self,arg1,arg2,arg3,arg4,arg5,arg6) --> None:

tacit token
#
@client.command()
async def hallo(ctx):
    await ctx.send("hello", components = [Button(label="Hi", style="3", emoji="✅", custom_id="button1")])
    interaction = await client.wait_for("button_click", check=lambda i:i.custom_id=="button1")
    await interaction.send(content = "Button clicked", ephemeral=True)```

Emoji ERROR:

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0.emoji: Only dictionaries may be used in a ModelType```

boreal ravine
drowsy condor
nimble plume
#

!function hi i a m n o t h i n g

boreal ravine
#

@nimble plume #bot-commands

nimble plume
#

Yes ik lol

hoary cargo
boreal ravine
#

yeah

nimble plume
#

@honest vessel i know 😑

honest vessel
#

In components.0.components.0.emoji: Only dictionaries may be used in a ModelType

#

pass a dict?

dim oriole
#

when i get the reactions of a message with ```py
msg.reactions.users

radiant rampart
#

any chance that someone could help me with a bot I'm creating? I want it to change people's nicknames if they are connected to the voice channel if that is possible. I already have a way of getting the user IDs of everyone connected, just can't figure out how to mass change the nicknames

honest vessel
#

for loop them

#

or edit their nicks when they join vc

#

@radiant rampartthis how u change a nick tho,

await user.edit(nick="new nick")```
#

this how i do for my afk function

await user.edit(nick=str(user.display_name)+str(" (afk)"))
            
radiant rampart
#

users is channel.members

quick gust
#

yeah, py for member in users: await member.edit()

honest vessel
#

if you want to change them all sametime sure, but if you want it to automaticly change their name when join a vc, or leave it n change it back you will need use an event that runs when a user joins a vc

#

await member.ban()

hoary cargo
brave flint
honest vessel
#

but you gonna get api blocked probally if many users

#

but put a sleep on it 😉

hoary cargo
#

if it's my server

brave flint
brave flint
honest vessel
#

its gonna be api-blocked

hoary cargo
honest vessel
#

well put a sleep n it will work

radiant rampart
#

how long are the api bans

quick gust
#

iirc 15-20 mins, might be wrong

radiant rampart
#

I doubt more than 30 people will be in my voice chats anyway

quick gust
#

u can asyncio.sleep()

honest vessel
#

why u wanna change their names tho?

hoary cargo
#

artistic_hmm fun

honest vessel
#

i mean for his vc stuff

radiant rampart
honest vessel
#

i change their nicks adds (afk) to it and removes it when they use afk command again, only reason i see change name is usefull

scarlet rune
#

why doesn't case_insenstive=True, work in prefixes?

honest vessel
#

cause u spell wrong

hoary cargo
honest vessel
radiant rampart
#

super odd, bot is saying that it’s missing permissions but it has manage nicknames

scarlet rune
radiant rampart
#

lol

honest vessel
honest vessel
#

why i made bot owner of server so afk command works on me 😄

scarlet rune
# honest vessel case_insensitive=True

it still doesn't work oof

bot = Bot(command_prefix="e!",
          case_insensitive=True,
          intents=Intents.all(),
          test_guilds=[821619777419739147],
          help_command=None)```
#

you're right( i haven't made a use for it yet) but still can't get case insensitive to work duh

honest vessel
#

thats weird

#

try remove test_guilds

#

wait

#

should't it be commands.Bot()

scarlet rune
slim ibex
#

You can explicitly import it

honest vessel
#

ah

#

i didnt see that part so 🙂

scarlet rune
#

it worked some days ago... couldn't figure out why it doesnt work now

honest vessel
#

it should work tho

scarlet rune
#

ima ask in disnake server

honest vessel
#

you sure your bot disconnects when u closes it

#

so you dont run an old instance of it in background

#

cause you can run multiply bots

radiant rampart
#

@honest vessel odd, I just tried testing it on my alt account and it just does nothing now? not even an error

#

I made sure the bot’s role was higher than the ones on my alt account

honest vessel
#

can u post ur code of whole command?

radiant rampart
#

sure I’ll dm it to yoy

honest vessel
#

ok

kindred epoch
#

@scarlet rune how are you typing out the command?

kindred epoch
#

are you typing E! command_name or E!command_name?

slate swan
kindred epoch
quick gust
#

!pypi disnake | fork of dpy

unkempt canyonBOT
scarlet rune
kindred epoch
scarlet rune
kindred epoch
#

🙂 yes

scarlet rune
#

aight then oof

kindred epoch
#

you can add e! and E! in a tuple and set that as ur command prefix

dull terrace
#

wtf font does discord use

#

i tried whitney and one other to try and get character widths

#

using pillow and measuring size

#

did not work

manic wing
#

what are you tryna do

dull terrace
#

jwK'FIp@x'
'NvWh^s=-e
RNs@V=j||Q
C]S^'%:Q%!

#

these strings should all be equal length for example

#

i'm trying to add dashes to some strings so they're equal i.e.

text here - - - - - - - - - - - - - something here
something here dif size - - - another thing here

#

i may just go through and do everything manually this is dumb

fallow mauve
#

with my rpg bot im making i got this error and i have no idea what it means. i added this command and it all stopped working, but it's fine without it:

full lily
#

how strange

fallow mauve
#

me?

full lily
#

oh

#

i know why

fallow mauve
#

me?

full lily
#

yes

fallow mauve
#

kk

dull terrace
#

can you use text alignment in an embed? that would save a lot of hastle

full lily
#

you overwrote the built in function open with your open command

fallow mauve
#
@bot.remove_function("open")

?

final iron
#

What

fallow mauve
#

or just change the name

full lily
#

change the name

fallow mauve
#

kk

full lily
#

_open if you want to keep it named that

#

here

#

paste me the first few lines of that command including the decorators

final iron
#

Use the name kwarg in the decorator

full lily
#

^^!

fallow mauve
full lily
#

you can keep it as name if you want

tacit token
#

Guys how can i make this command send a normal not in "only u see this"?

@client.command()
async def hallo(ctx):
    await ctx.send("hello", components = [Button(label="Hi", style="3", custom_id="button1")])
    interaction = await client.wait_for("button_click", check=lambda i:i.custom_id=="button1")
    await interaction.send(content = "Button clicked", ephemeral=True)```
full lily
#

but the func name can't be that

tacit token
#

ty so much

slate swan
#

!d discord.Activity

unkempt canyonBOT
#

class discord.Activity(**kwargs)```
Represents an activity in Discord.

This could be an activity such as streaming, playing, listening or watching.

For memory optimisation purposes, some activities are offered in slimmed down versions:

• [`Game`](https://discordpy.readthedocs.io/en/master/api.html#discord.Game "discord.Game")

• [`Streaming`](https://discordpy.readthedocs.io/en/master/api.html#discord.Streaming "discord.Streaming")
fallow mauve
#

@full lily thx so much that thing was rly breaking everything

bold surge
#

ah 👍

tacit token
broken cave
slate swan
fallow mauve
#

ok, im using keep_alive and uptime robot, but im getting this error:

#

it works on my other bot but not this one

#

any idea why this is?

fallow mauve
#

as a package?

boreal ravine
#

yes

fallow mauve
#

ok

boreal ravine
#

package manager > install

honest vessel
#

^^

#

imagine if all python packages(modules) was already installed

#

pl0x dont fill my HDD

fallow mauve
#

EPIC

#

that should be a thing: import all

honest vessel
#

it stil wont import flask tho cause u havnt installed it 😄

fallow mauve
#

i did

honest vessel
#

python downloading pip modules if module not found 😎

potent spear
#

is this the full traceback?

#

str(role.mention)
the mention is already a string...

#

I'll shorten it for you

roles = []
for role in member.roles:
    roles.append(str(role.mention))```
to
```py
role_mentions = [role.mention for role in member.roles]```
pliant gulch
#

That is irrelevant to the error

#

The error is from passing an invalid formatter to strftime

potent spear
#

true and not shown in the given error

pliant gulch
#

What do you mean it's not shown

potent spear
#

the traceback doesn't contain the line

pliant gulch
#

Their f-strings are fine, that rules them out. What is left is the stftime

#

The error specifically mentions invalid format string

potent spear
#

I'd suggest the discord built-in timestamp

slate swan
#

My discord bot is sending a huge message by getting info from end point how do I sent as txt file without creating txt file

#

So it sends the txt file straight to channel without saving to pc to save storage

potent spear
slate swan
#

See it’s getting all info from an api but message is too big

potent spear
#

doesn't have to be saved locally

slate swan
#

O

#

Any docs?

potent spear
#
from io import BytesIO

# if you have an image or anything that saves to a stream
buffer = BytesIO()
im.save(buffer, "png")  # 'save' function for PIL, adapt as necessary
buffer.seek(0)

# if you have some bytes
buffer = BytesIO(my_bytes)

# if you have some text
my_text = "Don't do drugs kids"
buffer = BytesIO(my_text.encode("utf8"))  # change encoding as necessary

await ctx.send(file=discord.File(fp=buffer, filename="whatever.png"))```
example with image ^^
scarlet rune
#

can tell me why this code make other commands be executed twice?

@commands.Cog.listener()
    async def on_message(self, message):
        if message.author == bot.user:
            return
        if message.author.id == owner_id:
            emiliasalute = ["Hey Emilia, you there?", "Hey emilia, you there?", "You there emilia?"]
            answers = ["Hey, I'm here!", "I'm here!",
                       f"I'm here {message.author.name}!",
                       f"{message.author.name}, I'm here!",
                       f"Hey {message.author.name}, I'm here!"]
            if message.content in emiliasalute:
                emiliasalute = "https://cdn.discordapp.com/attachments/944600993788731432/944601384500723762/emilia_salute.gif"
                ownerreact1 = disnake.Embed(color=ecolor)
                ownerreact1.set_image(url=emiliasalute)
                await message.reply(random.choice(answers), embed=ownerreact1)
            elif message.content == 'ping':
                await message.reply(f':ping_pong: pong! ({round(bot.latency * 1000)} ms)')
                print("bot pinged;")
            elif message.content == 'peng':
                await message.reply(f':ping_pong: pang! ({round(bot.latency * 1000)} ms)')
                print("bot pinged;")
        await bot.process_commands(message)```
manic wing
#

cogs handle that for you

#

its not making an event, just a listener

scarlet rune
#

ah i see, i thought it's the same as event

manic wing
#

no

#

you can only have one event, but multiple listeners

#

event = bad | listener = good

scarlet rune
potent spear
#

I highly suggest you to start using discord timestamps

hoary cargo
#

StareW bru

#

that's not how you use strftime

potent spear
#

He shouldn’t be using that

#

Example:
<t:1420070609>

#

Isn’t that a bit nicer?

#

<t:your_timestamp>

#

So your_timestamp should be the created_at timestamp

hoary cargo
slate swan
potent spear
#

He just ‘skips’ the error by implementing timestamp I’d say

slate swan
final iron
slate swan
hoary cargo
#

i have this when someone joins my server and it looks fine to me artistic_hmm, though i need to rewrite the code because the second bot still runs on dpy 1.6.0 lmao so probably i will also switch to timestamp instead of strf

hoary cargo
# slate swan

yeah, that's the only advantage, looks more clean which is fair

slate swan
#

@hoary cargo well I need to use it bc TikTok api uses it

#

They use unix

hoary cargo
#

understandable

final iron
#

<t:1645119398>

slate swan
#

I’m using: from discord.commands import option but I’m not sure on module

final iron
slate swan
final iron
#

Exactly

#

Timestamps are superior

slate swan
#

Fr

#

Even the white outline looks clean

final iron
#

All the formatting options are really nice too

#

<t:1645119398:R>

slate swan
hoary cargo
final iron
#

There are a ton

#

Well not a ton

slate swan
#

@final iron yk from discord.commands import option

#

Do you know module

#

I can’t find it

hoary cargo
#

option?

final iron
#

What's discord.commands

slate swan
final iron
#

Just use disnake

fallow mauve
#
Traceback (most recent call last):
  File "main.py", line 216, in <module>
    bot.run(os.getenv("token"))
  File "/home/runner/GDBot/venv/lib/python3.8/site-packages/discord/client.py", line 723, in run
    return future.result()
  File "/home/runner/GDBot/venv/lib/python3.8/site-packages/discord/client.py", line 702, in runner
    await self.start(*args, **kwargs)
  File "/home/runner/GDBot/venv/lib/python3.8/site-packages/discord/client.py", line 665, in start
    await self.login(*args, bot=bot)
  File "/home/runner/GDBot/venv/lib/python3.8/site-packages/discord/client.py", line 511, in login
    await self.http.static_login(token.strip(), bot=bot)
  File "/home/runner/GDBot/venv/lib/python3.8/site-packages/discord/http.py", line 300, in static_login
    data = await self.request(Route('GET', '/users/@me'))
  File "/home/runner/GDBot/venv/lib/python3.8/site-packages/discord/http.py", line 216, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: 429 Too Many Requests (error code: 0): You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently. Please read our docs at https://discord.com/developers/docs/topics/rate-limits to prevent this moving forward.
 172.18.0.1 - - [19/Feb/2022 18:36:24] "GET / HTTP/1.1" 200 -

im getting this what does this mean?

hoary cargo
#

YEPW you spammed the API and now u blocked

fallow mauve
#

i spammed what API?

final iron
#

Discord api

fallow mauve
#

whats that?

hoary cargo
#

That's requests for you

slate swan
fallow mauve
#

ok

#

so i have too much code or...

slate swan
#

You sent too many requests (messages ect)

fallow mauve
#

ok

slate swan
#

You spammed the command or something ?

fallow mauve
#

ok

#

so how fix? just wait?

final iron
#

Yes

#

And don't spam the api again

slate swan
fallow mauve
#

ok

slate swan
#

@fallow mauve what are you hosting on ?

fallow mauve
slate swan
#

O

hoary cargo
#

Understandable

slate swan
#

You didn’t spam api

fallow mauve
#

?

slate swan
fallow mauve
#

someone else has access to my bot?

hoary cargo
#

It's irrelevant anyway since y'all suffer

slate swan
fallow mauve
hoary cargo
#

Imagine you go on replit just to troll and get everyone rate limited

fallow mauve
#

😐

fallow mauve
#

i hate them even though i dont know their name

hoary cargo
fallow mauve
slate swan
#

replit shares ips so the whole ip got ratelimited lol

fallow mauve
#

ok

#

thx

slate swan
#

just make a new replit

#

most people make a new one and it fixes the issue

#

maybe it changes the ip im not quite sure

#

@fallow mauve

#

That should change ip

fallow mauve
#

?

#

in the shell?

slate swan
#

Yes

fallow mauve
#

i just type kill 1?

slate swan
#

theres a command to change your ip in replit?

slate swan
#

or are you just trolling

#

Works for me

slate swan
fallow mauve
#

thx that worked

slate swan
#

🙂

#

ive never gotten ratelimited by the discord api lol

#

I have a lot

#

only the praw api

#

I use repl a lot

#

Sometimes I use vs code

#

why tho

#

Idk it’s just easy to use ide

#

Access from anywhere

#

bro what

#

vsc isnt quite hard

#

It’s not

#

I just prefer Replit layout

#

you have to be joking

#
  • sometimes I like to code on phone
#

nah youre just trolling at this point

#

I’m not lmao

#

dont belive you at all

jade bay
#

Hey, I was wondering if I could get the members banned by someone specific (from audit logs) and unban them

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.
jade bay
slate swan
#

returns a list so iterate through it

#

I’m on a roll today for guessing shit

jade bay
#

I don't want to unban everyone so I was wondering if I could somehow get only the people which got banned from nuking

slate swan
#

@jade bay await bans()

jade bay
slate swan
jade bay
#

I'm not entirely sure what a snowflake is

slate swan
#

the id of the user is unique so its called a snowflake

#

hence a snowflake always being unique

jade bay
#

oh, but how would I get the IDS of the people which got banned by the nuker?

slate swan
#

no just iterate through the list and check the ids and if the id is correct as the nukers just use the pass statement

kindred drum
#
member = guild.get_member(member_real)```
anyone know why that returns none type?
slim ibex
#

member_real is prolly none

kindred drum
#

member_real = await bot.fetch_user(x)

jade bay
#

There is a propriety which returns the user which banned the other user?

kindred drum
#

which prints as mictony#9857

slim ibex
unkempt canyonBOT
slate swan
#

and not a user obj

jade bay
slate swan
#

it probably has that attr

slim ibex
slate swan
kindred drum
#

but as soon as i sent that message I realised it gotta be a member_real.id

slim ibex
#

!d discord.abc.Snowflake

unkempt canyonBOT
#

class discord.abc.Snowflake```
An ABC that details the common operations on a Discord model.

Almost all [Discord models](https://discordpy.readthedocs.io/en/master/api.html#discord-api-models) meet this abstract base class.

If you want to create a snowflake on your own, consider using [`Object`](https://discordpy.readthedocs.io/en/master/api.html#discord.Object "discord.Object").
kindred drum
#

needs to be an id 😭

slate swan
slate swan
kindred drum
#

ah

slate swan
#

it accepts an int lol

kindred drum
#

snowflake = unique

slate swan
#

yes

#

in this case the id is a snowflake

#

everyone has a snowflake

#

youll never see a user with the same ids

#

but @everyone has the same id as the guild

honest vessel
#

snowflake

#

thats political terms those days

final iron
#

😔

honest vessel
#

maybe like

#

ID=hash(email, ip)

#

something that way

#

maybe just email hashed

#

at first

slate swan
pliant gulch
#

Well, discord directly says they use twitters snowflake package

honest vessel
#

i dont know what better channel to ask in this server, its relevant to discord. so if u del account u can make new one on that email or need new email no matter?

pliant gulch
#

That's how they generate unique IDs

slate swan
honest vessel
#

if u use delete acc?

#

once used email its done

#

thats wrong

slate swan
#

if the account is deleted yes you can iirc

honest vessel
#

thinking

#

if i poress delete acc i can make new acc with same email

#

?

slate swan
#

yes

honest vessel
#

good

slate swan
#

i see no reason why you cant

honest vessel
#

redirect emails

slate swan
#

im not sure if you can

honest vessel
#

i think so

pliant gulch
#

You can just setup a gmail account and use dots

honest vessel
#

so they only allow certain email domains?

pliant gulch
#

E.g one@gmail.com -> on.e@gmail.com all point to the same email

honest vessel
#

gmail hotmail etcyahooo

#

no no no u missing it

#

thats ur gmail

#

but u buy a domain n put up a mailserv er that directs ur emails

#

as email

#

they cant check that up

slate swan
#

so you want a domain that redirects to another so spoof it?

honest vessel
#

so u can have 100000 emails on 1 domain

pliant gulch
honest vessel
#

but all ur discord accounts has 1 email

pliant gulch
#

These are counted as two different emails, but they point to the same email

honest vessel
#

forgot password sent to 1

#

acc

#

no

#

yea

#

technical 2 but its 1 for all

pliant gulch
#

Yea, which is what you just explained

honest vessel
#

or technical 1 and 1000

pliant gulch
#

A redirection

honest vessel
#

out

#

i figured this out cause my idea was how u share email

#

witth one if u dont trust em

#

do a temp email

#

but u cant send em

#

but u can recive

#

if u send u gonna show its layers

slate swan
#

so you want several accounts tied to one email but make allor of emails that get redirected to a domain and one password?

dull terrace
#

better to return and keep things flatter but add an extra line or no 🤔

#

trying to make a lil more readable

slim ibex
#

holy shot lmao

#

i would say first one

final iron
dull terrace
final iron
#

Doesn't matter

#

Nobody should ever be using json as a database

dull terrace
#

oh i can't be using a database for the player saves

hoary cargo
dull terrace
#

i experimented with that and it wouldn't work.

#

i could seperate the player save into a db and a dict but

#

half and half

slate swan
final iron
#

That's why I said to not use it

slate swan
#

So they are json too

#

Use json files instead to target what youre saying

final iron
#

Wat

dull terrace
#

umm lemme give you an example of the saves for map objects in the player dict

#

so if you can put that in a db good luck

slate swan
#

Don't see why it would be a issue, just use something like mongo

hoary cargo
dull terrace
#

yeah but why would you do it

slate swan
slate swan
#

Don't relate anything to json pls 💀

slate swan
slate swan
pliant gulch
# dull terrace

This is easy, you just create an array of types ```sql
CREATE TYPE foo AS (
bar varchar,
baz INT,
qux NUMBER(1),
)

CREATE TABLE foos (
data foo[]
)

#

If you were to use postgres you could also just add a JSON codec

#

And store it as JSON

dull terrace
#

isn't that just adding extra unnecessary steps

pliant gulch
#

Which part

dull terrace
#

just, why would i move everything to a db, makes no sense with my data structure

pliant gulch
#

Because there are some perks you get from using an actual DBMS than just a .json file

slim ibex
#

but I haven’t used all of them so idk

#

I’ve gone through docs of some and haven’t seen list types listed in the data typed

pliant gulch
#

I can say it does for postgres at the very least

dull terrace
#

i doubt it would be faster. I currently using a caching for 5 minutes whenever someone interacts so only the most recent are in the player dictionary.

slim ibex
#

yeah Postgres has them

pliant gulch
#

You can also cache your queries

slim ibex
#

redis 😩

dull terrace
#

it wouldnt be though. if i have 10 players loaded into my dict vs searching through 1 million in a db

pliant gulch
#

You must be under some kind of misconception clearly

slim ibex
#

^

slate swan
#

imagine saying 1 million and having only 7 users

dull terrace
#

😆

pliant gulch
slate swan
# dull terrace 😆

Nothing funny, json files are generally resource wasting too, it first of all reads all of the file, then writes all of it back when you dump stuff

pliant gulch
#

That's constant time for getitem

dull terrace
pliant gulch
slate swan
#

Isnt that single person outvoted to 5 rn

hollow blaze
#

I got a question, so i am developing a discord bot with discord.py, and now i wanna know in how many servers my bot is? Any suggestions

slim ibex
#

as many servers as it’s invited or added to

dull terrace
#

i think it's len(client.guilds) if i remember correctly

slate swan
slim ibex
#

I don’t think he meant how to get it with code

#

unless he did

#

🗿

slate swan
slim ibex
#

idfk

#

I prolly lose more brain cells here than playing basketball at school

dull terrace
slate swan
slim ibex
#

🗿

final iron
#

What the sus happened

#

🤨

candid pilot
#

how could i make a command like 'search' so that whatever i search the bot will search in google and send the top result? im pretty new so yeah

slate swan
#

!pypi google

unkempt canyonBOT
slate swan
#

i forgot the invisible unicode, it looks like u+200b

#

nvm i got it

hoary cargo
honest vessel
#

not serverside

#

the username

#

maybe cant?

pliant gulch
#

You'd give a new username to await Bot.user.edit(...)

#

!d discord.ClientUser.edit

unkempt canyonBOT
#

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

Edits the current profile of the client.

Note

To upload an avatar, a [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object "(in Python v3.9)") must be passed in that represents the image being uploaded. If this is done through a file then the file must be opened via `open('some_filename', 'rb')` and the [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object "(in Python v3.9)") is given through the use of `fp.read()`.

The only image formats supported for uploading is JPEG and PNG.

Changed in version 2.0: The edit is no longer in-place, instead the newly edited client user is returned.
dull terrace
#

trying to educate myself on databases 😤 if anyone knows any good videos/resources lemme know

candid pilot
slate swan
slate swan
#

@bot.command()
@commands.has_any_role(692760082085183519, 940008547993927691, 863878825376743475)
async def очистить(ctx, amount : int):
    if amount == None:
        emb=discord.Embed(title="❌ Error", description="Введите число!", color=discord.Color.from_rgb(0, 255, 0))
        await ctx.reply(embed=emb)
    else:
        await ctx.channel.purge(limit=amount)
        await ctx.reply(f"{ctx.author.name} удалил {amount} сообщений")
#

if not working, why?

#

you can use is or not and amount will never be None and if you are gonna set a defualt value make it 1 and you cant purge allot because youll get ratelimited

#

A okay

rare saddle
#

How can I deduce that the bot does not have enough rights when pressing the button?
More precisely, how to make a condition

slate swan
slim ibex
#

💀

manic wing
#

mine command

#

anyone got any improvements?

pliant gulch
#

It would be a lot better with buttons

#

You can have a 25 button area field

#

As 5 action rows, 5 buttons per row

manic wing
pliant gulch
#

Then you wouldn't have to do all this coord specifying stuff

manic wing
#

and how would you flag

pliant gulch
#

Press the button, ask in an ephemeral message if you want to flag or dig

manic wing
#

but then thats 2 steps

#

click button; flag or dig

#

rn its only coords

#

and im not sure how this would scale with 10x10

pliant gulch
#

I feel like that sacrifice is a lot better then specifying the coordinates

#

Press & click, not read type and send

#

If you want to do 10x10 just make that the regular one, keep the others in buttons?

#

Not sure

hoary cargo
#

remember, easier for users means harder to code for the programmer, harder for user to use, easier to code MR_canny_6

pliant gulch
#

Except when your users are coders

#

The easier an implementation it is, the easier it is to hack it

#

That's why all my homies like low-level functions

slate swan
manic wing
slate swan
manic wing
#

oh i see what you mean

#

cursor with buttons would be horrific

#

imagine you're at 0, 0 and you want to get to 10, 10

#

the ratelimits would be psycho

slate swan
#

sounds like a you problem

#

or just do a plus 5 movement or sm lol

#

better than specifying cords

manic wing
#

-_-

pliant gulch
#

do interactions even have ratelimits, I'll have to test that rq

manic wing
#

yes?

final iron
#

Probably

manic wing
#

it says slow down, you're clicking too fas

slate swan
#

who clicks a button so quickly you get ratelimited

manic wing
#

you dont have to click it quickly

slate swan
#

ik

manic wing
#

even if you click it pretty slow, after 5 times you get ratelimited

slate swan
#

dynamic ratelimits lol

pliant gulch
#

I'll look at the headers of the request anyhow

slate swan
#

just check the headers lol

pliant gulch
#

That's what I Just said

manic wing
slate swan
native wedge
#

is there any like discord phising link list? so i can put that on a filter

slate swan
#

discorde is one

#

discode is one as well theres many domains

slate swan
# manic wing

kinda triggers me how it says it on the row where the button is and not on bottom

pliant gulch
slate swan
#

guess youre slow

pliant gulch
#

spamming

slate swan
#

lolll

manic wing
#

i can assure you i didnt hack discord 😳

slate swan
#

;|

pliant gulch
#

Let me restart my client

#

Ok now I am getting them

#

I am so confused lmao

slate swan
#

discord is confusing

manic wing
#

did you just find a way to bypass the ratelimits? o.O

slate swan
#

just check the id of the guild

final iron
#

If the member is not in the server it will throw an error iirc

slate swan
#
if ctx.guild.id == 1234567890:
    ...

and you can use or so no need for that if statement when you can just do

member = member or ctx.author
tacit token
#

guys, how can i make a command the command enable & disable command (perserver)

cold sonnet
#

yeah that can't happen

#

member objects are all attached to a guild

slate swan
slate swan
#

a bot token is 52 chars

#

so make your name 52chars or else

manic wing
cold sonnet
manic wing
#

no

#

whats the other reason

cold sonnet
#

I can't fit a whole ass code in the about me

slate swan
cold sonnet
#

bro

slate swan
#

im joking lol

cold sonnet
#

nobody uses pycord

manic wing
#

^

cold sonnet
manic wing
slate swan
#

thats the punchline

final iron
#

@cold sonnet make your about me follow pep8

slate swan
cold sonnet
#

can't

final iron
#

Why

cold sonnet
#

I have to fit it in just a few lines

manic wing
final iron
#

You're missing spaces around the equal sign when you're defining the bot variable

manic wing
#

you wont figure it out

slate swan
#

he probably doesnt even follow pep8 LOL

final iron
#

Can you not add those in?

slate swan
cold sonnet
#

yeah probably but I don't care that much

#

y'all are just weirdos looking at that

slate swan
#

ok

final iron
#

ok

cold sonnet
#

nice

slate swan
cold sonnet
slate swan
#

they look off but i think its my font lol

manic wing
#

@pliant gulch tell them the error with his about me

#

i better not be wrong about this error

cold sonnet
#

why ping andy

slate swan
#

theres nothing in it?

#

or the useless class instance?

manic wing
#

zilo mate you're off the mark

slate swan
#

...

cold sonnet
#

mean you when_mentioned()?

manic wing
cold sonnet
#

seems right to me

manic wing
#

in the command_prefix you dont call the function

manic wing
#

command_prefix=commands.when_mentioned

#

not command_prefix=commands.when_mentioned()

slate swan
#

only on the or one iirc

cold sonnet
#

do you call when_mentioned_or?

manic wing
slate swan
#

bro

manic wing
#

just like you dont call get_prefix

cold sonnet
#

you do tho

manic wing
#

you dont

slate swan
#

doesnt get prefix call it?

pliant gulch
slate swan
#

im so confused

cold sonnet
#

when_mentioned_or("!")

slate swan
#

how so?

manic wing
#

!d discord.ext.commands.when_mentioned_or | take a look

unkempt canyonBOT
#

discord.ext.commands.when_mentioned_or(*prefixes)```
A callable that implements when mentioned or other prefixes provided.

These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.

Example

```py
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'))
```...
manic wing
#

actually thats right

pliant gulch
#

Kek

manic wing
#

😳

#

but the other one is wrong

slate swan
#

😖

manic wing
#

!d discord.ext.commands.when_mentioned

cold sonnet
#

no

unkempt canyonBOT
#

discord.ext.commands.when_mentioned(bot, msg)```
A callable that implements a command prefix equivalent to being mentioned.

These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.
manic wing
#

you dont call it in the command_prefix

cold sonnet
#

proof

slate swan
#

yeah get_prefix does iirc

native wedge
#

how would I do example !mute @native wedge 1d

#

or like 1m or 1s

slate swan
#

you can split the arg

#

1:d and split it on the colon and if the unit is a day just use math

pliant gulch
# cold sonnet proof

If you called when_mentioned inside of command_prefix= you'd get an error anyways

cold sonnet
pliant gulch
#

You need the message and the bot

cold sonnet
#

why don't the docs explicitly mention anything

slate swan
#

the edittt

pliant gulch
slate swan
#

🙃

pliant gulch
#

Plus it quite literally says so what to do! "These are meant to be passed into the Bot.command_prefix attribute."

#

!d discord.ext.commands.when_mentioned

unkempt canyonBOT
#

discord.ext.commands.when_mentioned(bot, msg)```
A callable that implements a command prefix equivalent to being mentioned.

These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.
cold sonnet
#

but that returns itself when called so

#

meh

pliant gulch
#

But when_mentioned doesn't return itself

#

It returns strings

cold sonnet
#

couldn't the string it returns be the prefix

pliant gulch
#

Yes...

#

That's what it is

cold sonnet
#

so you could call it if it were made like that

pliant gulch
cold sonnet
#

why you need that

pliant gulch
#

The function takes it

cold sonnet
#

yeah cuz it's not made like that

#

I meant

slate swan
pliant gulch
#

when_mentioned doesn't even need the message

#

It only returns a list of the mentions the bot can have

cold sonnet
#

if when_mentioned just returned "<@numbers>"

#

though

#

where would it get the id from

#

your bot gets its own id on startup

next breach
#

i don't understand what i've done wrong. Could someone explain pls?

manic wing
#

bot.event

#

you dont call the event part

next breach
unkempt yacht
#

How would you make a command to show all the guilds the bot is in? Additionally, how would you make the bot leave a guild it is in without the person who ran the command being in the guild.

next breach
umbral night
#

how would I go about making a 'createrole' command, and making sure it clears all permissions so its just a blank role with a name?

unkempt yacht
#

ty

umbral night
slim ibex
umbral night
#
@commands.has_permissions(manage_roles=True)
async def createrole(ctx, member:discord.Member, *, role:discord.Role = None):```
cerulean olive
#

discord.errors.ClientException: Callback for serverinfo command is missing "ctx" parameter.

slim ibex
#

you would do something like

guild = ctx.guild

perms = discord.Permissions(permissions=0)
await guild.create_role(name=role, permissions=perms)
cerulean olive
slim ibex
native wedge
#

how do i make an on_ready where it says
Bot_Name#0000 is now online

cerulean olive
manic wing
cerulean olive
slim ibex
cerulean olive
#

2 sec i will do it again

native wedge
slim ibex
#

that works ye

native wedge
#

ok ty

slim ibex
#

ii forgot the "

umbral night
#
@client.command(aliases=['cr'])
@commands.has_permissions(manage_roles=True)
async def createrole(ctx, member:discord.Member, *, role:discord.Role = None):
  guild = ctx.guild
  
  perms = discord.Permissions(permissions=0)
  
  await guild.create_role(name=role, permissions=perms)
  await ctx.send(f'`{role}` was created')```
I think I've done it all wrong @slim ibex
#

wait i dont need member

cerulean olive
#
Traceback (most recent call last):
  File "C:\Users\jackr\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "taken.py", line 83, in on_command_error
    await ctx.reply(embed=ErrorEmbed)
  File "C:\Users\jackr\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\context.py", line 340, in reply
    return await self.message.reply(content, **kwargs)
  File "C:\Users\jackr\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\message.py", line 1358, in reply    return await self.channel.send(content, reference=self, **kwargs)
  File "C:\Users\jackr\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\abc.py", line 1065, in send
    data = await state.http.send_message(channel.id, content, tts=tts, embed=embed,
  File "C:\Users\jackr\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 254, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In message_reference: Unknown message

cerulean olive
slim ibex
umbral night
#

im just trying to create a role

slim ibex
#

errors?

manic wing
umbral night
slim ibex
#

its because of the discord.Role typehint i believe

#

just make it str

unkempt canyonBOT
#

Hey @cerulean olive!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

slim ibex
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

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

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

cerulean olive
#

bru was py

umbral night
slim ibex
#

ye

umbral night
#

k

cerulean olive
cerulean olive
umbral night
manic wing
#

you deleted the message and are trying to do things to it after you deleted it

slim ibex
manic wing
#

delete it add the end

slate swan
#

Best way to make Embed python for help command

feral ridge
#

Is it possible to host a web server and a discord bot @ the same time ?
I have a discord bot that uses coinbase commerce's api and I have a webhook that receives events.

umbral night
#

how would I edit all of these at once?

#

isn't there some kind of shortcut

slate swan
unkempt canyonBOT
#
No way, José.

No documentation found for the requested symbol.

umbral night
#

.

slate swan
#

Idk

cedar stream
final iron
slate swan
slim ibex
cedar stream
final iron
#

Or is it written like serverInfoEmbed

cedar stream
final iron
#

mmm

#

So it's not even proper camel case

cedar stream
#

It’ s a mixture

slate swan
#

How to create private channel on command?

final iron
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
slim ibex
#

overwrites param

slate swan
slate swan
slim ibex
slate swan
#

@bot.command()
async def start(ctx):
guild = 944633510013075497
await guild.create_text_channel('test')

slim ibex
#

ctx.guild not the id pls

#

because its just a random int that has no meaning

cedar stream
slim ibex
#

^

cedar stream
#

You need discord.Guild instance

slim ibex
#

hence ctx.guild

slate swan
cedar stream
#

!d discord.Guild

unkempt canyonBOT
#

class discord.Guild```
Represents a Discord guild.

This is referred to as a “server” in the official Discord UI.

x == y Checks if two guilds are equal.

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

hash(x) Returns the guild’s hash.

str(x) Returns the guild’s name.
slim ibex
#

^

slate swan
#

Man I like using ids

#

So if someone’s invited bot

#

They can’t use

slim ibex
#

but an id can't do shit

slate swan
#

Ok

#

Ok sorry

vocal shuttle
#

hi

slate swan
#

hi!!!

#

wut? variables can start w/ number?

#

they cant right?

slim ibex
#

but 524 doesn't have send attribute\

slate swan
#

ohhh

#

you mean that

arctic tiger
#

hi

vocal shuttle
#

hi

slim ibex
#

and no variables can't start with numbers in python

slate swan
#

duh, that's an error

vocal shuttle
slate swan
#

Mb

#

!d discord.Member

vocal shuttle
#

how can i create a discord.Member with an id?

vocal shuttle
#

whats interaction