#discord-bots

1 messages Β· Page 435 of 1

stark python
#

!e print ("hehhe")

unkempt canyonBOT
#

@stark python :white_check_mark: Your eval job has completed with return code 0.

hehhe
stark python
#

see, works wonders ahshaha

slate swan
#

lol

#

python's like the USA lmao

#

you can do everything

#

I just started to learn C# and I'm feeling pretty closed in

#

c# claustrophobia

stark python
#

im starting university next month and im trying to learn some things and get used to this enviroment

slate swan
stark python
slate swan
#

I'm gonna start calling people grandpa

stark python
#

sounds about right

stoic whale
#

delete_after work in ephemeral messages?

slate swan
#

it's a kwarg in Messageable.send()... I don't think the message matters

#

why want

#

their

#

bot to ping and reply

#

them

#

dm me i ll give

sly cliff
#

What does the client function do in discord bots

slate swan
#

it's not a function...

#

where are you writing that code im just wondering bc i want to make a bot

thick basin
#

visual studio

slate swan
#

oh

#

thanks

south kayak
#

i need help

#

I try to execute client.get_user(id) with my ID and i got None

thick basin
#

i am not exactly sure but it is because of members intent being disabled

south kayak
#

members intent?

south kayak
slate swan
#

!d discord.ext.commands.Bot.get_user

unkempt canyonBOT
slate swan
#

doesn't say if it needs intents or not

#

eh

south kayak
slate swan
#

is it in a command?

south kayak
#

yes

slate swan
#

then why use client

thick basin
#

i think he is using AutoShardedBot

south kayak
#

because I use async def handle(self, params, message, client):

thick basin
#

Β―_(ツ)_/Β―

slate swan
#

it doesn't matter, consider enabling intents and using ctx.guild.get_member()

south kayak
slate swan
#

and why don't you have ctx there

thick basin
#

you should consider enabling intents

south kayak
#

is there a way to use it without client?

slate swan
#

the client param?

thick basin
#

can you show the part of code

south kayak
#
async def handle(self, params, message, client):
        #getting parameters from params
        owner_id = *censored*
        owner = client.get_user(owner_id)
        msg = "a message"
        msg_o = "some message to me"
        await owner.send(msg_o)
slate swan
#

so client is a parameter

#

taken from the command

#

so you wanna do str.get_user

south kayak
#

yea

south kayak
#

user id is got from dev mode

slate swan
#

what is client

south kayak
#

discord.Client object

slate swan
#

why is it in the parameters of the command

stark python
#

How do i obtain the member count of my server? I've tried client.get_guild(id)
and then guild.member_count

fair rose
#

how to make ban everyone command

slate swan
unkempt canyonBOT
#

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

fair rose
#

!rule 10

unkempt canyonBOT
#

:x: Invalid rule indices: 10

fair rose
#

!rule 9

unkempt canyonBOT
#

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

south kayak
slate swan
#

and why are you using self?

#

are you using cogs?

south kayak
#

what are cogs?

slate swan
#

understood

#

you can replace self with ctx

#

delete the client parameter

#

and place a @client.command() decorator above your function

south kayak
#

gives me error

#

in fact, actually i'm not working at one file, but one file each command

full lily
slate swan
#

huh

thick basin
slate swan
#

this is how a command's built in cogs

#decorator that says this is a command
@commands.command()
async def test(self, ctx, **kwargs):
    #here's your code
    #you use self.client or self.bot, most likely bot, since it's made for commands
south kayak
#

ok...

slate swan
#

wait da heq

south kayak
#

this template separates main code from commands and events

#

so coding commands is very different but handy to code

slate swan
south kayak
#

😩

south kayak
#

but uses a predefined base

dapper cobalt
slate swan
#

exactly

south kayak
#

OMG

#

😫

#

any alternative?

slate swan
#

use normal dpy...

south kayak
#

what's dpy?

slate swan
south kayak
#

ok...

#

but for separate commands from main file?

slate swan
#

cogs

#

and I don't think it's a big deal

#

to have it in one file

#

they have docs on everything,
tutorials everywhere,
discord.gg/dpy has help channels

#

and this channel mainly supports discord.py-
and some discord-components stuff I think

stark python
#

Do you guys suggest the use of cogs? its just different files to categorize everything right?

slate swan
#

they have benefits

stark python
#

a cog for moderation, a cog for embeds, a cog for role assignment?

slate swan
#

you can reload them, for example

stark python
#

what does that do

slate swan
#

don't gotta restart the whole bot

#

just a part of it

#

make an autodeploy on github

#

whenever you update it, the host deploys it

#

!reload commands

#

πŸ’₯

#

I don't have to go to my Raspberry PI and restart the whole bot since I can just use a command

#

so in my experience, they're pretty useful
if you don't need them, don't have to

stark python
#

ohh okok i see

#

mines pretty basic so yeah no need

slate swan
#

Β―\_(ツ)_/Β―

stark python
#

You host your bot in the RPI?

#

so it runs 24/7

slate swan
#

yeah

#

I'm on vacation running 5 bots at home

stark python
#

the RBI is only able to host a thing or does it host alot of stuff?

stark python
slate swan
#

1GB of RAM

#

it doesn't have much, tbh

#

can anyone help me with cogs

stark python
#

just buy a desktop lemon_s_winter

slate swan
#

plzzzzz

#

bigger bots on multiple servers cache a lot of stuff

pale turtle
slate swan
#

wouldn't be enough

stark python
slate swan
#

no i dont have cogs i nned the code plus ow it works

slate swan
stark python
slate swan
stoic whale
#

i get Interaction Failed but the button works Pbs_Hmnm

slate swan
#
guild_id[id] = {"id" :id , "channel":channel}
  file = json.dumps(guild_id)
  with open ("id.json","w") as f:
    f.write(file)
#

the code is correct right? but i got an error :l

#

nvm i got it

#

Someone? Please?

#

does anybody know the solution to this problem?

for word in f:
ValueError: I/O operation on closed file.

slate swan
#

someone knows the script who change every 10s the bot status?

#
@client.command()
async def test(ctx):
 msg = await ctx.send("[                    ] 0% ")
 await sleep(3) 
 await msg.edit("[=====               ] 25%")
 await sleep(3) 
 await msg.edit("[==========          ] 50%")
 await sleep(3) 
 await msg.edit("[===============     ] 75%")
 await sleep(3) 
 await msg.edit("[====================] 100%")
 await sleep(3) 
 await msg.edit("testing....")
 await msg.edit("Done.",components = [Button(style=ButtonStyle.red , label="Delete")])
 test = await client.wait_for("button_click",check= lambda i: i.component.label.startswith("Delete"))
 await msg.delete()
 await test.respond(content="deleted.")``` i want the only ctx.message.author who can use the button :-( idk how any help?
flat solstice
#

So i've been meaning to format my bots timestamp info like this for a while but i'm not sure how to do it. I had a look at a few guides but i'm still not exactly sure how it' done. I want to make it look like that for my member joined aaand account created timestamps

slate swan
#

<t:24:f>

#

idk tbh but u need to put num in <t::f>

#

like <t:num:f>

flat solstice
#

okay thanks

slate swan
flat solstice
slate swan
#

does anybody know the solution to this problem?

for word in f:
ValueError: I/O operation on closed file.

slate swan
#

Ive been trying my best to make my bot online 24 7 but i cantttttt

#

Its sofukin hard

slate swan
# forest vortex u didnt open the file

The code:
with open("path/file", "r+") as f:
if message.content.startswith(message):
message.channel.send(f)

for word in t:
pyautogui.typewriter(word)
Pyautogui.press("enter")

Error:
for word in f:
ValueError: I/O operation on closed file.

forest vortex
serene frigate
#

I'm getting global check failure in a command in a cog when testing on an alt, but I don't think I've implemented a global check anywhere. The cog doesn't have a check override. I have the on_command_error and on_message event outside of cogs though. Is there a function that might have accidentally added a global check?

blazing beacon
serene frigate
#

I do have a def bot_check in a different cog though

slate swan
blazing beacon
#

oh

pliant gulch
serene frigate
#

oh wait

#

oops, yeah, i meant to do cog_check there, ty

forest vortex
#

ctx.guild.owner_id

forest vortex
slate swan
# forest vortex what u tryna do?

I'm trying to open a file on command with a variable because when I put the open command the file I want to open opens no matter what and I want it to only open with a variable

pliant gulch
#

Meaning the for-loop will have to be inside of the context manager as well

lament mesa
#

You have to enable the members intents

forest vortex
#

@pliant gulch is it neccesary to close the file after opening it?

pliant gulch
#

Could slow down your bot, sometimes changes don't go into effect until file is closed, etc

#

Many reason to not want to leave open the file

#

I mean, just think about it? Why would you keep the file open if you aren't using it afterwards

forest vortex
#

true alright got it thanks

lament mesa
#

the opened file will take up memory

cunning fiber
#

how do i set a default value to the member who called the command?

blazing beacon
#

how do i get account connections( i didnt know the name of them i just googled it )

pliant gulch
#

A bot does not have access to those

blazing beacon
#

cri

#

bbbut they magiked it thank you anyways andy

prisma wedge
#

how do i make this

#

look like this

blazing beacon
#

it's markdown

prisma wedge
#

wdym

blazing beacon
#

it's mark down syntax highlighting

prisma wedge
#

so how do i do it

blazing beacon
prisma wedge
#

but thats?

#
- [] = optional requirement
blazing beacon
prisma wedge
#

i wrote it in py syntax

#

i did

blazing beacon
#

no put diff there

prisma wedge
#

ok

#

thanks!

blazing beacon
#

np

prisma wedge
polar dirge
#

how do i remove a reaction for an on_raw_reaction_add

blazing beacon
prisma wedge
#

ok

#

it doesnt do it

blazing beacon
#

show

prisma wedge
#

in code

#

diff\n - [] = optional argument

#

i had that in my code

blazing beacon
#

and it didnt highlight it?

prisma wedge
#

nope

blazing beacon
#

lemme try one sec

prisma wedge
#
- hi```
#

its doing it in chat

blazing beacon
#

yeah so move the \n to the diff

#

so it'd look like this

diff\n -hi
prisma wedge
#

um

blazing beacon
#

it worked?

prisma wedge
#

it didnt

#

oh wait mb

#

i didnt put the 3 backticks at the end

#

still no

#

diff\n - [] = optional argument

#

i have that

blazing beacon
#

lemme see

prisma wedge
#

there

blazing beacon
#

diff\n- [] = optional argument

prisma wedge
#

why does that matter

#

ok got it now

blazing beacon
#

yep

prisma wedge
#

thank youuu

blazing beacon
#

np

prisma wedge
#

Also one more question

#

so i have a snipe command that can do as many snipes as you want right?

blazing beacon
#

mhm

prisma wedge
#

how do i make it automatically delete the stored messages like every hour

#

so the bot doesnt lag

#

for each individual server

blazing beacon
#

i have nothing in mind sorry

#

you can ask someone who's much more qualifed than me

#

@lusty swallow wrong ping sorry

polar dirge
#

how do i remove a reaction for on_raw_reaction_add

royal zenith
#
@bot.event
async def on_command_error(ctx, error):
    embed=discord.Embed(title="Uh oh... :sweat_smile: ")
    embed.add_field(name="It seems I've ran into a problem", value=error, inline=True)
    await ctx.channel.send(embed=embed)

i want to make it so when they say like xjrf4jhgbjgjrn my bot doesnt respond but if they say a actaul command with a error, my bot tells them the error, how in the fuck do i-

wheat ember
#

How can I make the variable have different values on different servers?

slate swan
sand sun
#

I was wondering if I can use client events and commands in the same code?

#

nevermind

velvet yarrow
#

#help-carrot any one its about regex to get 4y or time in the for of year

kindred epoch
#

and what are you trying to do?

#

which user?

#

does it have manage roles perms?

#

send the error

#

show the code

#

the full code blobpain

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @cedar smelt until <t:1630375259:f> (9 minutes and 59 seconds) (reason: newlines rule: sent 117 newlines in 10s).

bitter perch
#

lol

kindred epoch
#

uh

#

dam

#

sad

bitter perch
#

if i had to guess you're getting hierarchied

kindred epoch
#

and why use that

#

when discord.Member exists

potent fox
#

!paste use our paste site please @cedar smelt

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

potent fox
#

!unmute 760501716662878240

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: pardoned infraction mute for @cedar smelt.

bitter perch
#

to avoid spam

kindred epoch
#

anti raid ig

potent fox
#

We check for spam. Some people will send a lot of newlines to troll and we check for it to prevent it

final iron
#

Im making a whois command and i'm having an issue where instead of just naming the roles it gives the role id's and puts in a bunch of other charcters

#

the code is

    @commands.command()
    async def whois(self, ctx, member: discord.Member=None):
        member = member or ctx.message.author
        current_time = datetime.today().strftime("%I:%M %p")
        embed=discord.Embed(title="Whois Command | Epic Bot",
                            description=f"Returns with the information of a user or yourself.\n\n**Username**\n`{member.name}`\n\n**Roles**{member.roles}",
                            color=0xff0000)
        embed.set_author(name=f'{member}', icon_url=f'{member.avatar_url}')
        embed.set_footer(text=f"Epic Bot | Discord bot | Today at {current_time}", icon_url='https://cdn.discordapp.com/embed/avatars/1.png')
        embed.set_thumbnail(url=f'{member.avatar_url}')
        await ctx.send(embed = embed)
#

I'm just trying to make it so it lists the roles instead of this result

slate swan
lone flume
#

How make the bot to add roles for a specific command?

final iron
#

I need to learn how to use stuff like that cause it's pretty useful in removing unwanted characters

bitter anchor
#

Hey.
Any discord.py users out there?
feel free to check my status
we're always looking for contributors and pull requests are more than welcome.
our goal is to keep a maintainable future for discord bot development in python now that discord.py is out of the picture

final iron
feral cargo
#

From a performance stand point... would it make sense to have a single 'main' on message received' and then split out into Cogs or have a different on message in each Cog. I feel like it would be the former so you aren't repeatably checking the message over and over

wheat ember
#
g=random.randint(1000,16777215)
@bot.command()
async def c(ctx):
    role=discord.utils.get(ctx.guild.roles, name='colour')
    user=ctx.message.author
    await user.add_roles(role)
    while True:
      print('change colour...')
      await role.edit(name='colour', colour=discord.Colour(g))
      print('changed')
      time.sleep(0.5)

why sometime work sometime it not work ???

pliant gulch
# feral cargo From a performance stand point... would it make sense to have a single 'main' on...

Not sure 100% But from how I see it, the former (main) on_message would have a bunch of if/elifs statements I'm assuming which would take a while depending on the number to traverse. On the other hand commands.Cog.listener makes a listener which is ran on a message create event in this case. Meaning instead of traversing through all the if/elif statements in the main on_message it fires directly to whatever you wanted (that being said you would need an if statement to make sure its the case you want)

pliant gulch
feral cargo
#

so mostly... the former may be better performance wise but at the cost of added latency?

pliant gulch
#

Idk if I said was very clear so heres an example

#

I hope you can see what I am trying to say

feral cargo
#

thanks πŸ™‚

pliant gulch
#

You could probably timeit to really see which ones is faster as I said earlier my thought isn't 100%

balmy tree
#

i need help

feral cargo
balmy tree
#

i installed python

feral cargo
#

what IDE are you using?

balmy tree
#

visual studio code

feral cargo
#

okay

#

open your command terminal and type pip --version what does it return?

balmy tree
#

pyhton 3.9.7 @feral cargo

slate swan
#

what do you guys think will happen to discord.py because danny retired?

prisma wedge
#

what category would snipe command come under?
fun, mod, info, bot, misc
which one

slate swan
#

fun

prisma wedge
#

fun?

#

rlly

feral cargo
feral cargo
balmy tree
#

jack helped me fix it

feral cargo
#

Current watching a few forks and a new wrapper and seeing where it's going

balmy tree
#

since i dont have a env file what line should i use to run my token?

stark bobcat
balmy tree
stark bobcat
#

Oh

#

Mb

balmy tree
#

client.run("") correct?

stark bobcat
#

Yes

balmy tree
#

good

#

i learned pythopn in 1 day ez

#

kinda

stark bobcat
#

Ok

balmy tree
final iron
#

Is there a function to get a users discriminator like there is to get a name?

pale turtle
#

!d discord.User.discriminator

unkempt canyonBOT
final iron
#

ty

pale turtle
#

Np

pale turtle
# balmy tree

The error speaks for itself, you have two commands with the name or alias avatar.

balmy tree
#

i fixed it

#

it was 2 avatar command lol

maiden fable
#

Hey @visual island, can u share the code where u trigger the typing but it types indefinitely in my DM?

Thanks

maiden fable
#

U were using typing() and not trigger_typing()?

visual island
#

the function it ran has a wait_for function which stops the context manager, so i create it as a taskcreate_task(func(*args, **kwargs))

visual island
#

async with args[0].typing():

unkempt canyonBOT
#

discord/abc.py lines 1455 to 1468

"""Returns a context manager that allows you to type for an indefinite period of time.

This is useful for denoting long computations in your bot.

.. note::

    This is both a regular context manager and an async context manager.
    This means that both `​`​with`​`​ and `​`​async with`​`​ work with this.

Example Usage: ::

    async with channel.typing():
        # simulate something heavy
        await asyncio.sleep(10)```
maiden fable
#

So this is what u were doing

#

See the example

#

That wait for was sort of something heavy

visual island
#

wait_for is not heavy actually, it is waiting for an event to be dispatched, if it not dispatched then the context manager wont exit

maiden fable
#

Yea, that makes it sort of heavy, just like asyncio.sleep(10)

visual island
#

PIL is very heavy

maiden fable
#

If the event never dispatches, then it won't run the code after it

maiden fable
visual island
#

that's why i used asyncio.loop.create_task

maiden fable
#

Haha cool

visual island
#

wait, im having exam

maiden fable
#

Sure

balmy tree
#

hi hnter

#

hi hunter

visual island
maiden fable
maiden fable
visual island
maiden fable
maiden fable
glacial mesa
#

ctx

visual island
maiden fable
#

Indeed

#

But we haven't tested those much tbh

#

The version which will be released would be the beta version for now

visual island
maiden fable
#

But I don't really know if they are released

#

Since EQ is developing those himself

visual island
#

EQ's skill is equivalent with Danny ic

maiden fable
#

He has been deving since 2018

#

He also says that, Danny changed his life too

#

BTW

#

If u want to start moving to disnake, the basic commands system is usable

glacial mesa
#

did anyone create a server setup bot?

maiden fable
#

As long as u don't use the newer features like context, slash commands and the Buttons, u r fine

#

The easiest way to transfer would be

import disnake as discord

Ezz

visual island
#

as i think v2 is quite stable already

maiden fable
visual island
#

but idk what should i add/change tbh

maiden fable
# visual island can i open a PR of something?

Sure. We are open to PRs. But if it is related to the Discord API, then u will have to talk to EQ, cz he's the one who codes the API side of the wrapper. Others filter out bugs and adds custom features

If you want, I can provide u an invite to the support server and u can talk with EQ there

crystal kestrel
#

disnake?

#

isn't that my lib?

maiden fable
#

???

#

Wym?

crystal kestrel
#

!pypi disnake

unkempt canyonBOT
crystal kestrel
#

h u h

maiden fable
#

......

crystal kestrel
#

I made a lib called disnake

#

like

#

yesterday

maiden fable
#

Uhhh idrk

#

This lib has been in development since a few days now

crystal kestrel
#

w t f

#

wait

unkempt canyonBOT
crystal kestrel
#

thats

#

mine

maiden fable
#

Oh

crystal kestrel
#

w h a t

maiden fable
#

πŸ˜‚

crystal kestrel
#

I think he made it after mine lmao what

#

mine was last updated about 6 hours before his, not sure tho

maiden fable
#

Also

#

Dude, please don't use camelCase. This isn't JS

crystal kestrel
#

?

#

i

#

do that all the time

maiden fable
#

RIP

#

!case

#

Nvm

crystal kestrel
#

did he rename it to disnake? I think it used to be dsc

desert heart
#

Frankly, unless your library is profoundly good or way far ahead of all other efforts, I think it won't get adopted just on grounds of it using camel case.

crystal kestrel
#

ig ima rename it

#

:(

desert heart
#

I think camel case enthusiasts suffer in Python cause even if their code uses it, the majority of the ecosystem and the standard library don't, so they just end up with inconsistent styles which is arguably worse

slate swan
#

Forks already started killing Library Internals notlikeblob
Pycord released third "Bot" class which can be used for slash commands. Basically proved the older and newer system are totally incompatible

#

word in message.content, message is the discord.Message object which is not iterable

slate swan
#

Yes

#

can anyone explain me why we save bot tokens in .env file and not in .txt?

slate swan
slate swan
slate swan
#

currently, i have directly put my token in the main boy file (bot is only in 1 server)

slate swan
# slate swan i did not understand

What you didn't understand? message is the instance of discord.Message class which can't be iterated. message.content returns the content string which is iterable, so use that.

slate swan
#

in simple words

slate swan
slate swan
slate swan
slate swan
#

oo kk

slate swan
#

thnx

slate swan
slate swan
maiden fable
maiden fable
slate swan
maiden fable
slate swan
#

:3

crystal kestrel
vale pendant
#

sure

#

with?

#

wdym

#

like a command where you can have spaces for the guild name?

#

ctx,*,arg

#

lol

slate swan
#

?

#

off topic???

maiden fable
crystal kestrel
#

okay ig

#

ima just leave python

#

this has happened to me like 5 times already

#

I made my own wrapper cause my friends needed one and they begged me to use python cause they need help

maiden fable
#

Aw, that's sad. Well, u can always choose a new name!

crystal kestrel
#

and theres ppl "criticizing" (quotes) the way i code

#

ima head out :/

maiden fable
#

@crystal kestrel I have just suggested that cz people don't use camel case in Python.. They use snake case. So people won't be comfortable with using your wrapper...

hoary gust
#

@maiden fable if i give my bot a emoji unicode that is not present in server, so will it react with that emoji

await re.add_reaction(":z_wrong:")
maiden fable
#

No

hoary gust
#

how can i do that

maiden fable
#

Also u need to use the full emoji name

hoary gust
maiden fable
#

No

hoary gust
maiden fable
#

Add a ``` before the emoji and it will send the whole emoji with ID

hoary gust
#

:z_wrong:

slate swan
maiden fable
#

\![7408_shrekstare](https://cdn.discordapp.com/emojis/847545516388909107.webp?size=128 "7408_shrekstare")

#

Just add a \

hoary gust
maiden fable
#

Weird

hoary gust
#

??

maiden fable
#

To get the emoji I'd, yea

#

Wrong channel

slate swan
final holly
#

how do i make my bot send a message without me using prefix like suppose i send hello i want it to reply hi

slate swan
#

!e

unkempt canyonBOT
#
Command Help

!eval [code]
Can also use: e

*Run Python code and get the results.

This command supports multiple lines of code, including code wrapped inside a formatted code
block. Code can be re-evaluated by editing the original message within 10 seconds and
clicking the reaction that subsequently appears.

We've done our best to make this sandboxed, but do let us know if you manage to find an
issue with it!*

#

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

001 |   File "<string>", line 1
002 |     async def test
003 |                   ^
004 | SyntaxError: invalid syntax
#

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

001 |   File "<string>", line 1
002 |     async def test: 
003 |                   ^
004 | SyntaxError: invalid syntax
#

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

001 |   File "<string>", line 2
002 |     ctx.send(
003 |     ^
004 | IndentationError: expected an indented block
unkempt canyonBOT
#

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

This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/stable/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/stable/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
maiden fable
slate swan
#

sorry

hoary gust
#

@maiden fable how to get emoji from other server

#

?

#

the method i used before didnt work

maiden fable
unkempt canyonBOT
#

class discord.PartialEmoji```
Represents a β€œpartial” emoji.

This model will be given in two scenarios:

β€’ β€œRaw” data events such as [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add")

β€’ Custom emoji that the bot cannot see from e.g. [`Message.reactions`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Message.reactions "discord.Message.reactions")...
maiden fable
#

Read the docs, from where u can get those

hoary gust
#

wth is this

maiden fable
#

Emoji but Partial

hoary gust
#

ok

maiden fable
#

From a guild the bot can't see

hoary gust
maiden fable
#

From the guild the bot isn't the member of

hoary gust
cloud dawn
#

Good morning guys

glacial mesa
#

403 Forbidden (error code: 50013): Missing Permissions how?

#

like for kick

#

PLS HELP

#

:(

cloud dawn
#

If the user is not in the guild or you are trying to kick the owner.

glacial mesa
#

@client.command()
async def kick(ctx, member : discord.Member, *, reason=None):
await member.kick(reason=reason)

lucid stream
#
#sets value in json to guild id upon the bot joining the guild
@client.event
async def on_guild_join(guild):
    #loads json file to dictionary
    with open("result.json", "r") as f:
        guildInfo = json.load(f)

    guildInfo[guild.id] = guild.text_channels[0] #sets key to guilds id and value to top textchannel
    
    #writes dictionary to json file
    with open("result.json", "w") as f:
        json.dump(guildInfo, f)

#allows server members to set channel for welcome messages to send to    
@client.command()
async def welcomeMessage(ctx):
    with open("result.json", "r") as f:
        guildInfo = json.load(f)

    guildInfo[ctx.message.guild.id] = ctx.message.channel.id #sets channel to send message to as the channel the command was sent to

    with open("result.json", "w") as f:
        json.dump(guildInfo, f)

``` this is my code i want the server name to be stored as well what do i do?
cloud dawn
glacial mesa
lucid stream
#

so i need a way to store server names as well

cloud dawn
lucid stream
#

panda yelp

cloud dawn
lucid stream
#

yea but as the discord client login has been closed down i need to know the server names as well or is it against TOS?

#

just to see which servers my bot is in thats all

lucid stream
cloud dawn
lucid stream
#

nice na ? before i used to go to the login then copy id

#

but now as it is banned

cloud dawn
#

That has always been against ToS

lucid stream
#

i have no way to get id so i had to use this code i just need a way for server names as well

cloud dawn
#

It was meant to automate small things but people abused it.

lucid stream
cloud dawn
#

But i'm not helping with self-botting.

lucid stream
#

or is it against TOS?

glacial mesa
#

wait

cloud dawn
#

Yes.

glacial mesa
#

@client.command()
async def changeprefix(ctx, prefix):
with open('prefixes.json', 'r') as f:
prefixes = json.load(f)

prefixes
prefixes[str(ctx.guild.id)] = prefix

with open('prefixes.json', 'w') as f:
    json.dump(prefixes, f, indent=4)

await ctx.send(f'Prefix changed to: {prefix}')
lucid stream
#

i just want to know the servers my bot is in and store it in a json like a database nvm leave

glacial mesa
#

i used this for storing id

#

u have to name the file prefixes.json

#

then useit

lucid stream
#

aha

glacial mesa
#

then it will be stored it the file with the prefix the server uses

glacial mesa
#

i m a beginner.

#

'''python
@client.command()
async def add(ctx, *nums):
operation = " + ".join(nums)
await ctx.send(f'{operation} = {eval(operation)}')

@client.command()
async def sub(ctx, *nums):
operation = " - ".join(nums)
await ctx.send(f'{operation} = {eval(operation)}')

@client.command()
async def multiply(ctx, *nums):
operation = " * ".join(nums)
await ctx.send(f'{operation} = {eval(operation)}')

@client.command()
async def divide(ctx, *nums):
operation = " / ".join(nums)
await ctx.send(f'{operation} = {eval(operation)}')

#

how do u format it?

#
async def add(ctx, *nums):
    operation = " + ".join(nums)
    await ctx.send(f'{operation} = {eval(operation)}')

@client.command()
async def sub(ctx, *nums):
    operation = " - ".join(nums)
    await ctx.send(f'{operation} = {eval(operation)}')

@client.command()
async def multiply(ctx, *nums):
    operation = " * ".join(nums)
    await ctx.send(f'{operation} = {eval(operation)}')

@client.command()
async def divide(ctx, *nums):
    operation = " / ".join(nums)
    await ctx.send(f'{operation} = {eval(operation)}')```
#

cool rite?

#
async def changeprefix(ctx, prefix):
    with open('prefixes.json', 'r') as f:
        prefixes = json.load(f)

    prefixes
    prefixes[str(ctx.guild.id)] = prefix

    with open('prefixes.json', 'w') as f:
        json.dump(prefixes, f, indent=4)

    await ctx.send(f'Prefix changed to: {prefix}')```
#

prefix changer

cloud dawn
#

This is mine ```py
@commands.command()
@commands.is_owner()
async def db_prefix_debug(self, ctx, prefix):
await self.bot.con.execute("UPDATE guilds SET guild_prefix = $1 WHERE guild_id = $2", prefix, ctx.guild.id)
await ctx.send('Updated!')

#

You can put as much decorators on there as you want, just for a command to succeed it will all need to be True. So if @commands.has_any_roles() is the moderator role and it also has is_owner() it would be the owner of the bot that has the moderator role.

#

Yes.

#

You can make your custom decorator for that!

lucid stream
#
async def on_ready():
    guilds = client.guilds
    data = {}
    for guild in guilds:
        data[guild.id] = []
        for name in guild.name:
            data[guild.id].append(guild.name)
    with open("new.json", "w") as file:
        json.dump(data, file)``` this is my code but on the json file im getting like some 20 outputs of the same server names help
pseudo nimbus
#

How do i make my bot detect role permission change? + the one who changed it

cloud dawn
unkempt canyonBOT
#

discord.on_guild_role_update(before, after)```
Called when a [`Role`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Role "discord.Role") is changed guild-wide.

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

The who can be found in the audit log

#

Never done that so can't really provide help with that but the docs do provide some info.

pseudo nimbus
#

thank you

tight obsidian
#

What's the difference between a news thread an a public text channel thread?

cloud dawn
#

Hope that covers your question a bit, i could look into it more but i'm guessing it's mainly this.

dense oasis
#
@bot.command(aliases=['Poll'])
async def poll(ctx,question : str):
   bot_msg = await ctx.send(f"**{ctx.author.name}#{ctx.author.discriminator}** asks: `{question}`")
   await bot_msg.add_reaction(":GreenTick:")
   await bot_msg.add_reaction(":RedCross:")

when i use the command it only detects the first word after the command but not the whole sentence. how do i make it detect the whole sentnce

glacial mesa
#

I want to do help='SOMETHING' but i am using aliases

cloud dawn
tight obsidian
dense oasis
slate swan
cloud dawn
tight obsidian
glacial mesa
#

@client.command(pass_content = True)
async def leave(ctx):
if (ctx.voice_client):
await ctx.guild.voice_client.disconnect()
await ctx.send('I left the voice channel')

cloud dawn
dense oasis
#

wait nvm i fixed it ty! @cloud dawn

cloud dawn
dense oasis
#

ty lol

cloud dawn
steep estuary
#

help it is showing this error

cloud dawn
#

Code?

steep estuary
#

k

#
@bot.command()
async def react(ctx, chat:discord.Message.id, emoji:discord.Emoji):
    if chat is not None:
        if emoji is not None:
            message = chat
            await message.add_reaction(emoji)
        else:
            await ctx.send(f":exclamation: {ctx.author.mention} Please Specify the Emoji which you want to React")  
    else:
        await ctx.send(f":exclamation: {ctx.author.mention} Please Specify the Message on which you Want to React")

this is code :/

lucid stream
#
async def on_guild_join(guild):
    #loads json file to dictionary
    with open("result.json", "r") as f:
        guildInfo = json.load(f)

    guildInfo[guild.id] = guild.text_channels[0] #sets key to guilds id and value to top textchannel
    
    #writes dictionary to json file
    with open("result.json", "w") as f:
        json.dump(guildInfo, f)``` error-raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type TextChannel is not JSON serializable
#

panda help

lucid stream
#

pandaaa

steep estuary
cloud dawn
steep estuary
#

i want to use the command like this

steep estuary
#

>react msgid emoji :/

cloud dawn
steep estuary
lucid stream
#
    #loads json file to dictionary
    with open("result.json", "r") as f:
        guildInfo = json.load(f)

    guildInfo str(guild.id) = guild.text_channels[0] #sets key to guilds id and value to top textchannel
    
    #writes dictionary to json file
    with open("result.json", "w") as f:
        json.dump(guildInfo, f)``` will this work?
cloud dawn
lucid stream
#

oh oki

glacial mesa
#

how to add reactions?

cloud dawn
lament mesa
#

Logging is handy in most of the applications

cloud dawn
#

typehint it as an int or str.

steep estuary
cloud dawn
#

I find that logging gives excessive information.

glacial mesa
#

how to add emoji as reactions?

lament mesa
cloud dawn
vale wing
#

How to add an exception handler for NotFound? I tried both isinstance(commands.NotFound, error) and isinstance(discord.NotFound, error), but none of them worked

lucid stream
#
async def on_guild_join(guild):
    #loads json file to dictionary
    with open("result.json", "r") as f:
        guildInfo = json.load(f)

    guildInfo str[guild.id] = guild.text_channels[0] #sets key to guilds id and value to top textchannel
    
    #writes dictionary to json file
    with open("result.json", "w") as f:
        json.dump(guildInfo, f)``` syntax error
vale wing
#

HTTP exception raised when message bot tries to operate with gets deleted

lament mesa
#

Look at @unkempt canyon bots repo, it uses logging

#

!src

unkempt canyonBOT
glacial mesa
#

HOW DO U ADD A EMOJI REACTION

vale wing
#

await msg.add_reaction()

cloud dawn
#

It is mostly used to easily find errors and runtime problems.

glacial mesa
vale wing
#

Message object

glacial mesa
lament mesa
#

Set your logging level to debug when you are running your bot and you'll see

vale wing
#

So who knows how to handle NotFound

slate swan
#

My PC starts lagging as I open the debug logs blobpain

vale wing
# glacial mesa ctx?

ctx is commands.Context and not discord.Message, however it has message attribute which is right format you need

slate swan
#

Dpy heavily uses logging, literally all the data it receive is logged

cloud dawn
#

Debug logs have so much info that you can't even find the error

vale wing
#

Eh lemme explain

lament mesa
#

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

glacial mesa
lucid stream
# lament mesa Code blocks on mobile is not readable

@client.event
async def on_guild_join(guild):
#loads json file to dictionary
with open("result.json", "r") as f:
guildInfo = json.load(f)

guildInfo str[guild.id] = guild.text_channels[0] #sets key to guilds id and value to top textchannel

#writes dictionary to json file
with open("result.json", "w") as f:
    json.dump(guildInfo, f)
cloud dawn
vale wing
#

I will try to raise it rq

lucid stream
vale wing
#

NotFound: 404 Not Found (error code: 10008): Unknown Message

slate swan
#

hey can anyone help me on wats wrong here ?

cloud dawn
#

I'm on my phone πŸ˜”

lucid stream
vale wing
cloud dawn
#

Choice isn't defined..?

cloud dawn
slate swan
#

Str?

glacial mesa
#

please tell how to get emoji id

slate swan
unkempt canyonBOT
vale wing
#

What the hell is guildInfo str[guild.id] = ...

lucid stream
vale wing
#

Maybe you meant guildInfo[str(guild.id)] = ...?

lucid stream
#

yea done

unkempt canyonBOT
#

Please provide a full traceback to your exception in order for us to identify your issue.

A full traceback could look like:

Traceback (most recent call last):
    File "tiny", line 3, in
        do_something()
    File "tiny", line 2, in do_something
        a = 6 / 0
ZeroDivisionError: integer division or modulo by zero

The best way to read your traceback is bottom to top.

β€’ Identify the exception raised (e.g. ZeroDivisionError)
β€’ Make note of the line number, and navigate there in your program.
β€’ Try to understand why the error occurred.

To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.

slate swan
vale wing
#

Define ch?

cloud dawn
#

Lol

lucid stream
#
async def on_guild_join(guild):
    #loads json file to dictionary
    with open("result.json", "r") as f:
        guildInfo = json.load(f)

    guildInfo [str(guild.id)] = guild.text_channels[0] #sets key to guilds id and value to top textchannel
    
    #writes dictionary to json file
    with open("result.json", "w") as f:
        json.dump(guildInfo, f)
                ```Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 172, in on_guild_join
    guildInfo = json.load(f)
  File "/usr/lib/python3.8/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 24 (char 23)
vale wing
#

Like what are you choosing from lol

slate swan
vale wing
lucid stream
slate swan
#

It's like you think you can drive truck without knowing what is sterring.
Learning with projects is efficient and fun, but first go with a simpler one.

vale wing
#

So does anyone know how to handle this
NotFound: 404 Not Found (error code: 10008): Unknown Message

slate swan
lucid stream
#

hmm yea like is there like a minor error that is fixable ? or just wholw code is bad @slate swan

vale wing
#

How to handle this in error handler I mean

cloud dawn
#

Can you dump a text_channel object inside an .json?

vale wing
#

Like isinstance(what, error)

vale wing
glacial mesa
#

guys

slate swan
lucid stream
glacial mesa
#

please tell the id of πŸ‘

slate swan
#

Default emojis don't have any id

vale wing
#

You don't need its id for any cases

lucid stream
cloud dawn
vale wing
#

If you want to add reaction of it, just do

.add_reaction('πŸ‘')```
slate swan
vale wing
#

If you want to compare, just do

emoji == 'πŸ‘'```
#

Easy see

cloud dawn
#

I just use postgre so my json experience is -5%

lucid stream
#

so i need somthing to figure it out

glacial mesa
#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 10014): Unknown Emoji```
slate swan
#

Why you're even appending the name into a list, there will always be one name for one guild

#

just map the id with name

vale wing
glacial mesa
#
@client.command()
async def Poll(ctx , *, question):
    bot_msg = await ctx.send(f"**{ctx.author.name}#{ctx.author.discriminator}** asks: `{question}`")
    await bot_msg.add_reaction(':πŸ‘:')
    await bot_msg.add_reaction(":πŸ‘Ž:")```
vale wing
#

And yeah None as well

vale wing
slate swan
#

datetime and any python object will just be stored as the string iirc

cloud dawn
slate swan
#

Yes, I think so rooThink

glacial mesa
cloud dawn
vale wing
#

Yeah keys have to be str I think

slate swan
#

will it allow me to use commands as well as messege.content.startswith('$kick)

vale wing
#

How to handle this in error handler?
NotFound: 404 Not Found (error code: 10008): Unknown Message
I tried both isinstance(commands.NotFound, error) and isinstance(discord.NotFound, error) but none of them worked, what class should I use to handle it

slate swan
#

!d isinstance

unkempt canyonBOT
#

isinstance(object, classinfo)```
Return `True` if the *object* argument is an instance of the *classinfo* argument, or of a (direct, indirect, or [virtual](https://docs.python.org/3.10/glossary.html#term-abstract-base-class)) subclass thereof. If *object* is not an object of the given type, the function always returns `False`. If *classinfo* is a tuple of type objects (or recursively, other such tuples) or a [Union Type](https://docs.python.org/3.10/library/stdtypes.html#types-union) of multiple types, return `True` if *object* is an instance of any of the types. If *classinfo* is not a type or tuple of types and such tuples, a [`TypeError`](https://docs.python.org/3.10/library/exceptions.html#TypeError "TypeError") exception is raised.

Changed in version 3.10: *classinfo* can be a [Union Type](https://docs.python.org/3.10/library/stdtypes.html#types-union).
vale wing
slate swan
slate swan
vale wing
cloud dawn
vale wing
#

@bot.command()

slate swan
modern pewter
#

How do I avoid getting rate limited?

vale wing
#

Don't send many requests?

cloud dawn
slate swan
#

yeah

#

use heroku

#

or some other host

cloud dawn
#

Heroku is almost equally bad

vale wing
#

Dont use heroku πŸ€¦β€β™‚οΈ

slate swan
slate swan
vale wing
#

Use VPS lemon_swag

slate swan
#

?

cloud dawn
#

Or just use localhost or else an vps

slate swan
slate swan
cloud dawn
#

Nothing in life is free

slate swan
cloud dawn
slate swan
vale wing
#

Air is free. yet

slate swan
#

thnx

slate swan
dim wing
#

can i trigger a command of my bot using an api of a website?

slate swan
cloud dawn
slate swan
#

Btw

slate swan
#

Wait api? Are you sending them response your bot is acting like a server

modern pewter
slate swan
slate swan
dim wing
#

umh I haven't done anything yet

slate swan
#

then its fine

dim wing
#

im looking for ideas

visual island
slate swan
#

Fine then

slate swan
#

pls no

slate swan
#

i am sorry

#

my frndfs

dim wing
#

lol

slate swan
#

pls no

visual island
slate swan
#

sed lyf

#

i dont have any frnds

boreal ravine
slate swan
cloud dawn
slate swan
visual island
#

!d asyncio.loop.run_in_executor

unkempt canyonBOT
#

awaitable loop.run_in_executor(executor, func, *args)```
Arrange for *func* to be called in the specified executor.

The *executor* argument should be an [`concurrent.futures.Executor`](https://docs.python.org/3.10/library/concurrent.futures.html#concurrent.futures.Executor "concurrent.futures.Executor") instance. The default executor is used if *executor* is `None`.

Example:
visual island
#

wait

cloud dawn
visual island
#

synchronous?

#

PIL is

slate swan
cloud dawn
#

PIL Will always be sync

boreal ravine
visual island
#

no but you can run it in an asynchronous executor

boreal ravine
visual island
slate swan
cloud dawn
boreal ravine
slate swan
# visual island you dont?

I just make them to fill my github repos and pass time. After dpy got discontinued, I archived all the repos and now finding some another project blobpain

#

hello im new

cloud dawn
slate swan
#

wth is this

#

ummm

boreal ravine
#

Doesn't matter

slate swan
#

:/

cloud dawn
slate swan
#

anyway

#

how do i use this

#

Use what? Dpy?

visual island
slate swan
cloud dawn
unkempt canyonBOT
#
Resources

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

slate swan
#

ohh thanks

#

wait whattt

#

the heck

cloud dawn
#

Just fork dpy and implement slash commands and done

slate swan
#

what is this

#

lol

slate swan
visual island
#

don't use asyncio.run

#

its incompatible with running loops

#

loop.run_until_complete

#

or yea that

slate swan
#

since im new how should i start and what is this

cloud dawn
#

!d asyncio.loop.run_until_complete

unkempt canyonBOT
#

loop.run_until_complete(future)```
Run until the *future* (an instance of [`Future`](https://docs.python.org/3.10/library/asyncio-future.html#asyncio.Future "asyncio.Future")) has completed.

If the argument is a [coroutine object](https://docs.python.org/3.10/library/asyncio-task.html#coroutine) it is implicitly scheduled to run as a [`asyncio.Task`](https://docs.python.org/3.10/library/asyncio-task.html#asyncio.Task "asyncio.Task").

Return the Future’s result or raise its exception.
slate swan
#

like

#

how do i start

cloud dawn
slate swan
#

lol

slate swan
#

Don't click on 3rd one please notlikeblob

#

helphh

#

ok....

slate swan
cloud dawn
slate swan
slate swan
slate swan
cloud dawn
slate swan
#

tell me pls

slate swan
#

@cloud dawn

slate swan
slate swan
#

?

#

wait can a 13 y/o use this

#

:/

#

age doesnt matter

#

i'm 14 bruh

slate swan
slate swan
visual island
#

um, ghost ping?

cloud dawn
slate swan
cloud dawn
#

Imo, age does matter.

gloomy pewter
#

How do I check if the user's reaction is emoji based on the emoji I chose?

slate swan
slate swan
# slate swan

i suggest you use bot and also its await add_reaction(emoji)

#

and also the emjo should be named like this !SwagHappy

#

You timed out responding, also idk how discord_slash work but looks like you took more than 3 secs to respond

#

to get it you would have to do it like this \SwagHappy and send it

slate swan
vale wing
#

@slate swan

elif isinstance(error, discord.NotFound) or isinstance(error, discord.errors.NotFound):``` doesn't catch the exception I need
#

What class to put to there

slate swan
#

I think unwrap it

#

class is okay

slate swan
vale wing
#

Wdym unwrap?

vale wing
#

It works with all other exceptions besides this one

slate swan
#

Slash commands are fine, bad but not much, yeah their implementation is much different than usual

slate swan
cloud dawn
slate swan
slate swan
vale wing
cloud dawn
slate swan
cloud dawn
#

They will disallow any bot to read user messages

slate swan
#

bruh.

#

are u sure ?

#

panda

vale wing
cloud dawn
slate swan
slate swan
#

@slate swan

vale wing
#

Reading user messages is not only for commands yk

cloud dawn
slate swan
visual island
#

just like reaction and members

slate swan
slate swan
#

No

slate swan
#

then how did danny know that ?

#

He's not even a developer lol, he's a medical professional blobpain

cloud dawn
slate swan
#

@slate swan

vale wing
#

@slate swan so how to fix this

elif isinstance(error, discord.NotFound) or isinstance(error, discord.errors.NotFound):```
slate swan
#

ohk

slate swan
slate swan
vale wing
#

Ok

vale wing
#

I guess I gotta go to help channels...

cloud dawn
#

I can't really help anyone rn since I'm on my phone lmao

slate swan
# slate swan opened it?

on the on_message funcion or define message in your function and add this

      await message.add_reaction(':Heart~2:')
      await message.add_reaction(':heartEyes~1:')```
#

It's irritating to see 1 blocked message everywhere on the screen notlikeblob

visual island
vale wing
#

Uh

#

And full code?

visual island
#

CommandInvokeError needs to be unwrapped

visual island
slate swan
slate swan
slate swan
slate swan
vale wing
#

No I mean like

elif isinstance(getattr(error, 'original', error), discord.NotFound):```?
slate swan
visual island
#

idk then

vale wing
slate swan
#

i was trying in dms

slate swan
slate swan
slate swan
vale wing
#

@visual island

elif isinstance(getattr(error, 'original', error), discord.errors.NotFound):``` didn't work, I am sure I did it wrong, could you show an example?
slate swan
#

@slate swan it works on me not on my bot lol

slate swan
#

just make a check that checks if its a bot and if its a bot it would react with that

visual island
vale wing
#

Will it affect other handlers?

visual island
#

no

vale wing
#

Even custom exceptions?

slate swan
#

unless they have any original attr, no

visual island
maiden fable
slate swan
#

That's why I don't believe in forks notlikeblob