#discord-bots

1 messages ยท Page 317 of 1

robust fulcrum
#

I told him 2 times

#

Don't ask chatgpt for such thing

#

Its doesn't know about your file system

#

And it's super dumb in coding

#

your choice , I already told

#

I am done

mystic marsh
#

do what i said

#

just fucking right click and copy the path

#

..

robust fulcrum
#

๐Ÿ˜‚

mystic marsh
#

what does right clikc mean

robust fulcrum
#

I guess he need a pc tutorial

#

Jk

mystic marsh
#

maybe

robust fulcrum
#

Right click on file in sidebar and copy path

buoyant quail
#

Use \\ or /, not \

mystic marsh
#

you gotta set it to utf-8

buoyant quail
#

\ is used for special characters

robust fulcrum
#

no

mystic marsh
#

or that

buoyant quail
#

lol

robust fulcrum
#

๐Ÿ˜‚

#

Btw was it a json error?

mystic marsh
#

.

buoyant quail
#

!e

"\U"
unkempt canyonBOT
#

@buoyant quail :x: Your 3.12 eval job has completed with return code 1.

001 |   File "/home/main.py", line 1
002 |     "\U"
003 |     ^^^^
004 | SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 0-1: truncated \UXXXXXXXX escape
robust fulcrum
#

oh

#

I learnt about new error today

mystic marsh
#

haha

robust fulcrum
#

should \U be escaped like \n

buoyant quail
#

Because \n exists and \U doesn't

#

But it tries to find it

robust fulcrum
#

Oh , i thought it exists

#

lol

#

Why you wana delete flannels

#

Bruh

#

Vscode has powershell embedded

#

They are not different

#

We told you about it already 2 times

#

Its also already told to you

mystic marsh
#

check isnt defined

#

how about u learn to code

#

so?

#

its a slow process

#

i started at around 14-15

#

17

#

fucking google or some shit

solar glen
#

I get this apparently as a error Application Command raised an exception: TypeError: Cannot read stickers of format "lottie".

#

and i need some way to read lottie files so i can transform them into GIFs

#

i will need a way to transform the lottie files which default discord stickers hold to webP

hybrid light
#

Hello, anyone knows how to define tree command in separate class in separate file and import it to main. Now I'm using normal commands and everything works fine but i need tree commands for hints in chat.

final iron
final iron
#

What is this lmao

solar glen
#

but i can't get the bytes of what is made the file of

#

bc sticker.read() raises a type error and thats also for sticker.save()

#

i could just get its URL and send a request to download the file but it sounds inefficient

robust fulcrum
#

ok, good
๐ŸŽ‰

hybrid light
final iron
#

You should also make your main function asynchronous as you shouldnโ€™t really be messing with the event loop as you are now

#

Furthermore, sqlite3 is synchronous, and will block the event loop

#

You need to use aiosqlite, or asqlite

solar glen
final iron
#

What the full error

final iron
final iron
solar glen
#

but idk if it does, it probably doesn't

final iron
solar glen
#

complexity for no reason

#

very old website and not even maintained

final iron
solar glen
#

im gonna use something called pyrlottie

#

and i realised

#

It doesn't support mac

#

:/ god f_ck this

#

stickers are really annoying

#

to work with

#

hmmm, i might use javascript on the same project and work with both python and js

#

and it sounds a bit dumb

#

but like what else can i do. Lottie is besides a very unrecognised format, like i didn't even knew it existed until some searches

solar glen
#

why

shrewd fjord
#

what happened

#

what are you trying to do ? pithink

solar glen
#

bc discord stickers use them

#

(default ones mostly im aware)

#

this one example

shrewd fjord
#

are you trying to create sticker or smth

solar glen
#

well i try to store it as a image

vale wing
solar glen
#

so i can send it via webhook bc of the annoying limitation of webhooks not being able to send stickers

shrewd fjord
hollow zinc
#

main.py

import discord
from discord.ext import commands
import os
import asyncio

# Intents for the bot
intents = discord.Intents.all()
bot = commands.Bot(command_prefix='!', intents=intents)


@bot.event
async def on_ready():
    print('[main.py]: working.')


async def load():
    for filename in os.listdir('./cogs'):
        if filename.endswith('.py'):
            await bot.load_extension(f'cogs.{filename[:-3]}')

async def main():
    async with bot:
        await load()
        await bot.start("I won't put my token in here.")

asyncio.run(main())

cogs/Ping.py

import discord
from discord.ext import commands

class Ping(commands.Cog):
    def __init__(self, bot):
        self.bot = bot


    @commands.Cog.listener()
    async def on_ready(self):
        print('[cogs.Ping]: working.')


    @commands.command()
    async def ping(self, ctx):
        bot_ws = round(self.client.latency * 1000)
        await ctx.send(f'Pong! {bot_ws} ms.')


async def setup(bot):
    await bot.add_cog(Ping(bot))

No errors shown in the console but the ping command isn't working.

vale wing
unkempt canyonBOT
#

class discord.Sticker```
Represents a sticker.

New in version 1.6.

str(x) Returns the name of the sticker.

x == y Checks if the sticker is equal to another sticker.

x != y Checks if the sticker is not equal to another sticker.
solar glen
vale wing
#

There's that url attribute you can pass anywhere

shrewd fjord
solar glen
shrewd fjord
#

or whatever file you want

solar glen
sick birch
solar glen
#

then export it to a webp, so i need a library for that

shrewd fjord
#

NW_huh the url doesnt return byte or smth?

shrewd fjord
#

sec

solar glen
#

i want to store it

vale wing
#

Aiohttp is sufficient for downloading image and saving it

shrewd fjord
#

something like that

shrewd fjord
#

oih w

solar glen
#

let me get to the problem in more detail

shrewd fjord
#

forgor

#

its for reading bytes mb

solar glen
#

so i am making a bot that backups channels and stores them in 1 file. This file is encrypted and holds all of the data of the channel plus messages from up to 100 + all pinned ones(25 max)

shrewd fjord
#

ok next..

solar glen
#

i want the file to be unaffected by changes like deletion of channel and all of that. So urls are generally avoided for storing them

shrewd fjord
#

mhm

vale wing
shrewd fjord
#

tf

vale wing
#

And yeah urls are not affected by channels deletion, only by sticker deletion

shrewd fjord
#

i thought Sticker has a read method sus

solar glen
shrewd fjord
#

btw storing urls now bad anyway, yk url will get expired after some period of time

#

basically you cannot use discord as filehost now

vale wing
#

You'd want to only store sticker IDs btw if you don't care about stickers getting deleted

shrewd fjord
#

exen you shoud stop abusing it ๐Ÿ’€

vale wing
#

I never told to store url

#

You just can't download it without url

hollow zinc
# hollow zinc

@sick birch It's just running normally and when I run the command it is not showing any errors and the command isn't working aswell...

vale wing
sick birch
shrewd fjord
vale wing
#

I have daily backups for each db in cluster

hollow zinc
vale wing
#

@sick birch how do we promote bobux please help ๐Ÿ˜ญ

hollow zinc
shrewd fjord
#

sedly Sticker dont have read method su gey

vale wing
#

Just GET it

sick birch
hollow zinc
sick birch
#

strange

#

the cog is loaded

hollow zinc
#

Run --> command --> no errors..

sick birch
#

And you typed !ping in discord?

solar glen
#

Ok, here we go again. I don't think you guys got the problem yet so its ok il explain it again. Basically as i said i backup a channel with all of its attributes including messages. People can send whatever they want and yeh one of these are stickers, bc i can't send stickers through webhooks(which is what the recreation process), i thought of just sending the image as i have no other way of doing. Here are some example old vids i recorded for the implementation(do not take seriously the chat, its purely for testing the snapshot command aka backups)

hollow zinc
# sick birch the cog is loaded

yes, I used the listener to see if it can reach the cogs files and yes, the @commands.Cog.listener() is working but the commands.command...

solar glen
#

bc discord uses lottie json for their default stickers. Im getting the json and if i try to send that. It won't get rendered into a sticker. So i need a way to transform that json into webP format(basically GIF's better brother)

hollow zinc
sick birch
hollow zinc
#

the bot

#

WAit

#

I found smth

sick birch
#
    @commands.command()
    async def ping(self, ctx):
-       bot_ws = round(self.client.latency * 1000)
+       bot_ws = round(self.bot.latency * 1000)
        await ctx.send(f'Pong! {bot_ws} ms.')
#

Though this should cause an error

hollow zinc
#

Yes

shrewd fjord
#

lottie json?

hollow zinc
#

thanks did paid attention

shrewd fjord
#

oh default stickers

#

!d discord.StandardSticker

unkempt canyonBOT
#

class discord.StandardSticker```
Represents a sticker that is found in a standard sticker pack.

New in version 2.0.

str(x) Returns the name of the sticker.

x == y Checks if the sticker is equal to another sticker.

x != y Checks if the sticker is not equal to another sticker.
shrewd fjord
#

huh lemme debug rq

solar glen
#

lottie can be in json form

#

and is human unreadable. Like this

#
{"v":"5.6.2","fr":60,"ip":0,"op":120,"w":320,"h":320,"nm":"Clyde_20_Greetings","ddd":0,"assets":[{"id":"comp_0","layers":[{"ddd":0,"ind":1,"ty":3,"nm":"Null | Character","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[390.546,418.677,0],"ix":2},"a":{"a":0,"k":[-17.47,-2.001,0],"ix":1},"s":{"a":0,"k":[130,130,100],"ix":6}},"ao":0,"ip":0,"op":120,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":3,"nm":"C | Face","parent":13,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11}......
shrewd fjord
solar glen
#

wait

shrewd fjord
#

uh fk my internet issue is going on thats why unable to debug

#

fk this internet providers man RH_ieonn_se_pareshan

#

my sticker box aint even loading bruv

solar glen
#

true

#

feel u man

shrewd fjord
solar glen
#

tbh the thing is i just wanna store stickers

shrewd fjord
#

sec

#

imma dibug with bot now

solar glen
#

can stickers show up when they are typed as text, like emojis with :something:

shrewd fjord
solar glen
#

lottie to be exact

shrewd fjord
#

๐Ÿ’€

solar glen
#

i mean

#

yeh i shouldn't say

#

(im crying for help, its so painful)

shrewd fjord
#

internet issue meant to send this skull emoji later

solar glen
#

ok

shrewd fjord
#

discoed better keep their word

#

๐Ÿ’€ discord being discord

solar glen
#

yeh lmfaoo

#

tbh

#

one question, can i send lottie files just like image files. And discord would take care the rendering part? or not

#

nvm, its quite of a problem i cannot upload them as images

#

otherwise the problem would be easier to deal with

shrewd fjord
#

appereantly bots can send stickers let me see how

#

!d discord.Message

solar glen
#

i mean its discord being discord ๐Ÿ’€

shrewd fjord
#

real

#

at this point use an api lol

#

!pip pylottie or usethis

unkempt canyonBOT
solar glen
#

i've tried

#

idk how to open the json file so i can transform it into webP

shrewd fjord
#

oh onl ythis problem ?

solar glen
#

the convertLottie2Webp

#

has these arguments

#
fileName str - file path of the lottie file
newFileName str - name of the file to write
quality int, optional - Quality of the returned sequence. Defaults to 1.

But i work with bytes and BytesIO

shrewd fjord
#

well just temporarily write the lottie json to a json file?

solar glen
#

i don't like this approach

#

i perfer the use of stuff like BytesIO and those things

agile cedar
solar glen
#

opens the browser and all of that

sick birch
shrewd fjord
cold sonnet
#

no way I haven't seen that phrase in my entire life and now I did twice in 2 minutes

#

crazy

shrewd fjord
#

here and where

solar glen
#

apparently the lottie package even sucks at converting lottie json to webp

#

i got this from this

solar glen
cold sonnet
#

nuh uh

solar glen
#

im even thinking to skip the stickers entirely

#

and just ignore them bc of their annoying nature to work with

shrewd fjord
#

!ytdl

unkempt canyonBOT
#
Our youtube-dl, or equivalents, policy

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTubeโ€™s robots.txt file; (b) with YouTubeโ€™s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
cold sonnet
#

nuh uh was way funnier

shrewd fjord
solar glen
#

like?

#

if i try to get the url and send it, it doesn't really work

robust fulcrum
#

Download ffmpeg , it's a cli tool

shrewd fjord
robust fulcrum
#

And add it to path

cold sonnet
#

and bro's helping

shrewd fjord
#

you can just check if the format of the sticker is lottie or not if lottie then send the raw url if not then send the image

solar glen
#

if i send this

#

it wouldn't render into the actual sticker

shrewd fjord
sturdy egret
#

How do i mention a user with webhook desc in a message i forgot

slate swan
#

user.mention / <@user_id>

final iron
unkempt canyonBOT
solar glen
#

if its unreadable mess

#

i might look into "borrowing" some of the code of pyrlottie

#

that i care ofc

#

like exporting the json lottie to webp

vale wing
#

Why tf am I laughing at this

solar glen
shrewd fjord
unkempt canyonBOT
shrewd fjord
#

@solar glen use stickers name if its default else show image so no mess xd

solar glen
#

wait so

#

for wave, its just Wave

celest bramble
#

!d help

unkempt canyonBOT
#

help()``````py

help(request)```
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.

Note that if a slash(/) appears in the parameter list of a function when invoking [`help()`](https://docs.python.org/3/library/functions.html#help), it means that the parameters prior to the slash are positional-only. For more info, see [the FAQ entry on positional-only parameters](https://docs.python.org/3/faq/programming.html#faq-positional-only-arguments).

This function is added to the built-in namespace by the [`site`](https://docs.python.org/3/library/site.html#module-site) module.
unkempt canyonBOT
#

help()``````py

help(request)```
Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console. If the argument is a string, then the string is looked up as the name of a module, function, class, method, keyword, or documentation topic, and a help page is printed on the console. If the argument is any other kind of object, a help page on the object is generated.

Note that if a slash(/) appears in the parameter list of a function when invoking [`help()`](https://docs.python.org/3/library/functions.html#help), it means that the parameters prior to the slash are positional-only. For more info, see [the FAQ entry on positional-only parameters](https://docs.python.org/3/faq/programming.html#faq-positional-only-arguments).

This function is added to the built-in namespace by the [`site`](https://docs.python.org/3/library/site.html#module-site) module.
slate swan
#

much useful ๐Ÿ‘

slate parrot
#

@shrewd fjord is there any spotify or soundcloud python packages

final iron
#

Has nothing to do with discord bots

#

What

#

The channel says discord-bots

slate parrot
#

does anyone know why this error is happening?

error:

    raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: guild_name is a required argument that is missing.```

code (from this SO post: https://stackoverflow.com/questions/56403367/command-to-make-my-bot-leave-a-specific-guild-discord-py-rewrite):

```python
# leave guild command
@bot.command()
@commands.is_owner()
async def leave_guild(self, ctx, *, guild_name):
    guild = discord.utils.get(self.bot.guilds, name=guild_name)
    if guild_name in bot.guilds:
        await self.bot.leave_guild(guild_name)
        print(f"Bot successfully left {guild_name}")
    if guild_name == None:
        await ctx.send("No guild name was added!")
        print(f"Bot could not leave a guild, because there is no guild to leave.")```
final iron
final iron
#

Where is what

final iron
#

When the user invokes a command and an argument is missing that error is raised

slate swan
#

Hey, does anyone know how I can make a discord bot that logs the clients IP when they authorize it?

#

^^ Security purposes

slate parrot
final iron
#

Like I said, it's missing when a user invokes the command

#

Not in the code itself

slate parrot
#

yeah i put the guild name tho

#

do i have to put the id?

slate parrot
final iron
#

Depends on what you think fixing it is

slate swan
final iron
slate swan
final iron
#

I have no clue what that is and how it works

slate swan
#

Damn, alright. I'll do some more digging

slate parrot
#

@final iron would this code work:

# leave guild command
@bot.command()
@commands.is_owner()
async def leave_guild(self, ctx, *, guild_id):
    guild = ctx.guild
    guild_id_int = int(guild_id)
    if guild_id_int in bot.guilds:
        await self.bot.leave_guild(guild_id_int)
        print(f"Successfully left {guild}.")
        await ctx.send(f"Successfully left the guild!")
    if guild_id == None:
        await ctx.send(f"No guild was provided!")
        print(f"Did not leave any guild due to no guild being provided.")
    else:
        await ctx.send(f"Guild is not in bot guilds!")
        print("Bot did not leave any guild.")```
#

BRUH

slate parrot
#

SAME ERROR WHY IM PUTTING THE ID

final iron
#

What is bot.leave_guild

slate parrot
final iron
#

And, it'll still error

final iron
#

How is your file even configured

#

How is the bot variable in the class scope

#

Doesn't make any sense

slate parrot
#

bro how do i fix it ur asking me questions i do not know how to answer and now im getting annoyed

#

is there any code or anything

slate swan
final iron
final iron
#

How is your bot variable in the class scope

#

You're providing self as the functions first argument, therefore denoting it's in a class

slate swan
slate parrot
slate swan
#

He's shown logs of the bot

final iron
#

It provides the admins with users IP data?

slate swan
#

Correct.

final iron
#

wtffff

#

major, major fucking breach

#

Literally illegal in the European union

slate swan
#

Idk, I seen it and was wondering how to do it.

#

I was thinking maybe a redirect

final iron
slate swan
#

but at that point I don't think discord would authorize it

final iron
#

The bot doesn't have users visit their website to verify?

slate parrot
final iron
#

And this is why we don't copy and paste random code

#

!resources

unkempt canyonBOT
#
Resources

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

final iron
#

I'd take a look at this probably to get you started off

slate swan
#

let me check rq

final iron
#

Most likely the scenario

slate parrot
final iron
#

Providing administrators users IPs is crazy though

#

That's an extreme breach of user privacy

final iron
slate parrot
final iron
slate parrot
#

i looked at it and tried using it but tried making it my own

final iron
#

Do you know what self is in a class?

slate parrot
final iron
#

Okay, that's a problem then

#

Understanding classes is essential in discord.py as it's primarily based around OOP

slate parrot
#

whats oop

naive briar
#

Object Oriented Programming

slate swan
#

@final iron yeah redirects to restorecord

slate parrot
#

ok

slate parrot
#

ive seen people do something like class #something

final iron
#

Why do you need to create a class

slate swan
#

lol

slate parrot
final iron
#

I never said anything about creating a class

final iron
#

Yeah, understanding classes

#

Step 1 to understanding classes is not making them

#

Visit the resources page and look at some articles

slate parrot
#

!classes

#

!class

unkempt canyonBOT
#
Classes

Classes are used to create objects that have specific behavior.

Every object in Python has a class, including lists, dictionaries and even numbers. Using a class to group code and data like this is the foundation of Object Oriented Programming. Classes allow you to expose a simple, consistent interface while hiding the more complicated details. This simplifies the rest of your program and makes it easier to separately maintain and debug each component.

Here is an example class:

class Foo:
    def __init__(self, somedata):
        self.my_attrib = somedata

    def show(self):
        print(self.my_attrib)

To use a class, you need to instantiate it. The following creates a new object named bar, with Foo as its class.

bar = Foo('data')
bar.show()

We can access any of Foo's methods via bar.my_method(), and access any of bars data via bar.my_attribute.

final iron
slate parrot
slate parrot
final iron
#

ok...

slate parrot
final iron
#

Start what

shrewd fjord
shrewd fjord
shrewd fjord
final iron
slate swan
#

You can just use a single page

shrewd fjord
final iron
shrewd fjord
slate swan
#

Yeah, users would read the Terms of Service

#

So how exacly would I grab the users IP creating a flask page?

shrewd fjord
shrewd fjord
shrewd fjord
#

and get the ip

slate swan
#

alright, and you said it was the X-Forward-For?

rugged shadow
slate swan
#

Alrighty

shrewd fjord
slate swan
#

Bot doesn't have that ig

shrewd fjord
#

!d flask

unkempt canyonBOT
#

This part of the documentation covers all the interfaces of Flask. For parts where Flask depends on external libraries, we document the most important right here and provide links to the canonical documentation.

shrewd fjord
#

hm it has flask

brazen raft
brazen raft
slate swan
brazen raft
#

I'm saying maybe there's a better way to solve your security concern

#

I need to know what it is to begin with

slate swan
brazen raft
#

Stop your bot from showing any of that information to its users

#

Problem solved

#

Leaking is your fault, so stop doing that

slate swan
brazen raft
#

If the service's only interface is the Discord user, their IP address will be useless

#

Best to block the Discord user

slate swan
#

Will not be useless as our members may do something about it.

slate swan
ruby valve
#

Where can i find the docs for discord.py slash commands? been looking but all I can find is other libraries

brazen raft
slate swan
unkempt canyonBOT
#
Certainly not.

No documentation found for the requested symbol.

unkempt canyonBOT
#

class discord.Interaction```
Represents a Discord interaction.

An interaction happens when a user does an action that needs to be notified. Current examples are slash commands and components.

New in version 2.0.
brazen raft
#

Have them sign up a contract

ruby valve
#

ty

shrewd fjord
#

open this, it will show you the interaction api refrence

slate swan
shrewd fjord
#

hm

brazen raft
#

I can help you create your bot, but I can't help you get an IP address with it because they don't need it

slate swan
#

Almost like restorecord as if you will

brazen raft
#

The sliest solution would be a Discord login on your website or service and then get the IP once they log in

slate swan
brazen raft
slate swan
#

problem solved

slate swan
#

people caring about IP addresses ๐Ÿฅฑ

brazen raft
#

I'm not answering your messages if that's what you think I'm doing. I'm suggesting ways to do what you want

#

A "no thank you" response suffices

slate swan
#

Not sure how that's supposed to prevent that but I guess you know your architecture better

brazen raft
#

They can get all that just in the invitation page interface?

slate swan
#

Wdym

#

Getting access to your source code just like that is pretty weird tbh

slate swan
brazen raft
# slate swan Wdym

If they get all that leaked information from somewhere else other than the invitation webpage, you must store the IP address in a database to have it anytime you need it

slate swan
brazen raft
#

Well sure if it stores the IP address in its database to fetch it later when needed

#

Sending someone's IP address through a webhook seems intereseting legally speaking

#

But I'm not keen on that

slate swan
slate swan
#

I mean, I'm fine with storing IPs they're most of the time pointless but just trying to understand

slate swan
slate swan
#

Yeah I mean why not, but then you should probably make some legally binding contracts, NDA, etc.

#

Which has more influence than an IP

slate swan
#

I just wouldn't send IPs around via webhooks

#

Storing them? Yeah well why not, every service does it today so who cares

slate swan
#

Still, legally, not sure if that's allowed

slate swan
#

But not to be shared with Discord, the company

#

That's "almost" like selling that data

#

I see what you're saying, very good point.

#

Put it in your privacy policy that you share IP addresses with Discord, then yeah it's fine I guess

slate swan
#

So now, how do I get this up and running? I have the flask page setup.

#

Probably something better for #1035199133436354600 or the channel for the topic you're using, not sure at what step you are and what next you want/need

#

Alright, thanks.

stark nexus
#

How can i let me bot delete message when pressed reaction?

#

(reaction already added)

shrewd fjord
#

!d discord.on_reaction_add

unkempt canyonBOT
#

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

Note

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

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

Note

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

Thanks

shrewd fjord
#

yep

stark nexus
shrewd fjord
unkempt canyonBOT
stark nexus
#

interaction.message.delete()?

shrewd fjord
#

yes

stark nexus
#

Ty

patent lark
#

whats the best way to implement discord.ext.commands.Bot.change_presence? As i know using discord.on_ready can cause issues

#

Just call it after on_ready has been complete?

slate swan
#

hey, i have this dmall system, and i wanted to ask how can i make await member.send(embed=embed) run every 10 seconds to avoid getting my bot banned? ```py
@bot.command()
@commands.has_permissions(administrator=True)
async def dmall(ctx, *, args=None):
if args != None:
members = ctx.guild.members
for member in members:
try:
embed = discord.Embed(title="MESSAGE", description=args)
await member.send(embed=embed)
print("'" + args + "' sent to: " + member.name)

    except:
      print("Couldnt send '" + args + "' to " + member.name)
else:
  await ctx.channel.send("You didnt provide arguments.")
patent lark
#

why do you want to run it every 10 seconds?

slate swan
#

cause discord will ban it for spamming

#

so i want it to dm everyone slowly

patent lark
#

so you want the for loop to send a message to all members, and wait 10 seconds in between each member?

slate swan
#

yeah

patent lark
#

just add await asyncio.sleep(10) before you call .send()

#

make sure you import asyncio

slate swan
#

so, ```py
@bot.command()
@commands.has_permissions(administrator=True)
async def dmall(ctx, *, args=None):
if args != None:
members = ctx.guild.members
for member in members:
try:
embed = discord.Embed(title="MESSAGE", description=args)
await asyncio.sleep(10)
await member.send(embed=embed)
print("'" + args + "' sent to: " + member.name)

    except:
      print("Couldnt send '" + args + "' to " + member.name)
else:
  await ctx.channel.send("You didnt provide arguments.")
patent lark
#

yes

slate swan
#

kk

#

do you think that 10 secs is enough for discord not to ban my bot for spamming?

vale wing
#

Mass dms bots can be spotted by discord no matter the delay

vale wing
#

I don't get the point of this, just ping everyone

slate swan
#

which bots also send to other 1.255 members

#

but they dont get banned

vale wing
#

Can be banned any minute

slate swan
#

how is it possible?

vale wing
#

Just wait till someone cares to report

patent lark
slate swan
#

its not considered spamming

patent lark
#

Obviously depending on the amount of members. But i can see this being useful for certain things

slate swan
#

i have 250 members

patent lark
#

But why're you wanting to dm all members?

slate swan
patent lark
#

Ehhhh

slate swan
#

or to remember that my server exists

patent lark
#

Perhaps you should do something different

#

That doesnt seem reasonable

vale wing
#

Unsolicited bulk messages. If any user considers it a spam they will just straight up report and you won't be able to prove anything

#

You may ask discord themselves for legal advice tho

patent lark
#

unless you literally spammed their dms

slate swan
#

bro be spamming me

#

3 months now

#

him too

vale wing
#

You can report

#

If you care ofc

slate swan
#

yeah i dont want to

#

people are doing their jobs

vale wing
#

Well you of course can create a mass dm bot just as you can create a selfbot, but this is not 100% safe

slate swan
#

i dont want to use it to spam their dms

#

i rarely use $dmall

patent lark
#

I feel like this is harmless unless he spams the command

slate swan
#

or less

vale wing
#

Ask discord about this to be safe

slate swan
#

in discord support?

vale wing
#

Yes

slate swan
#

link?

slate swan
#

ty

#

anyone that knows how can i make a modal appear after clicking a button?

#

send it in button callback

#

wym "send it"

#

eh always get it wrong

#

!d discord.InteractionResponse.send_modal

unkempt canyonBOT
#

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

Responds to this interaction by sending a modal.
slate swan
#

so, await send_modal(MyModalsName)?

patent lark
#

um

slate swan
#

no

#

you dont put the / when calling the method

#

then why is it there

#

to tell you modal is positional only argument

#

i forgor

#

so, await send_modal(MyModalsName)?

#

send_modal doesnt spawn randomly

#

its Interaction.response method

#

so, await discord.InteractionResponse.send_modal(MyModalsName)?

patent lark
#

yes

slate swan
#

no

#

yesnt

patent lark
#

Well thats not exacrtly\

slate swan
#

you need instance to call a method

patent lark
#

what you implement

#

Well essentially he gets it

slate swan
#

interaction instance you already get in button callback

#

so...?

#

!D discord.Interaction

unkempt canyonBOT
#

class discord.Interaction```
Represents a Discord interaction.

An interaction happens when a user does an action that needs to be notified. Current examples are slash commands and components.

New in version 2.0.
slate swan
#

so you have InteractionResponse under .response

#

i've never used classes

#

idk how they work

#

then you should have learned them first

#

ill try

#

how can i make buttons never expire

#

basically work after restarting the bot

#

?

#

you need a persistent view

#

teach me

#

also make sure to actually read the comments to understand what is being done

#

i cant understand shit - how can i add Persistent Buttons to messages?

shrewd fjord
patent lark
#

This is the class you're technically referencing

shrewd fjord
#

if bot creating a dm too freq or atleast some time a based they will get flagged by discord no matter what how much delay you provide

#

discord's this algorithm is kinda impressive

#

even like
10 dms today
another 10dms 4 days later and another 5 days later will cause you get flagged anyway xd

slate swan
#

how can i make a thing where when a user sends a message in a specific channel it turns it into an embed?

shrewd fjord
#

!embed

#

hm

unkempt canyonBOT
#

class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if itโ€™s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

x == y Checks if two embeds are equal.

New in version 2.0...
shrewd fjord
#

then send the embed using this...

#

!d discord.TextChannel.send

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

Sends a message to the destination with the content given.

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

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

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed) object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list) of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed) objects. **Specifying both parameters will lead to an exception**.
shrewd fjord
#

pass the embed in embed=

slate swan
#

no

#

i mean

#

if a random member sends like a random message in a specific channel

#

that message turns into an embed

stoic falcon
slate swan
#

yeah

#

but it says who sent it

#

as the embed's author

shrewd fjord
#

track their msg using on_message

#

or for delete

#

use on_message_delete event

naive briar
#

Track ๐Ÿ™€

shrewd fjord
#

and set the msges content as the embed desc?

#

catty be appearing for 0.5 s

slate swan
gritty flint
#

!d init

unkempt canyonBOT
white citrus
#

How should I use persistent view for all servers?

#

In nextcord

hushed galleon
# white citrus How should I use persistent view for all servers?

as in you want a single view to respond to the same components sent across multiple servers? if so, it looks like the persistent view mechanisms arent that different between nextcord and discord.py so it should be as simple as using Client.add_view() without a message_id= argument

see also my short guide to persistent views where the above is described as "stateless"
https://gist.github.com/thegamecracks/0f9ab7ad3982e65ff4aa429acb39cc4e

white citrus
solar glen
#

via webhooks

#

by first deleting the user's messages

#

and creating a embed

#

then use a webhook already made

#

and send it that way, with avatar_url set to the author's avatar and username to their username(display name in this case)

#

the code would look like this

burnt idol
#

I am trying to import function wait_func from call_backend to wallet_manager.py

โ”œโ”€โ”€ cogs
โ”‚ย ย  โ”œโ”€โ”€ __init__.py
โ”‚ย ย  โ””โ”€โ”€ wallet_manager
โ”‚ย ย      โ”œโ”€โ”€ call_backend.py
โ”‚ย ย      โ”œโ”€โ”€ __init__.py
โ”‚ย ย      โ””โ”€โ”€ wallet_manager.py
โ””โ”€โ”€ main.py```
in my main.py i have imported wallet_manager cog as `cogs.wallet_manager.wallet_manager` 
and in my wallet manager i have imported callbackendd as `from . import call_backend` | ` from cogs.wallet_manager.call_backend` import wait_func 
is there anything iii am doing wrong or this isen't supported in dpy
solar glen
#
@bot.event
async def on_message(message: discord.Message):
  embed = discord.Embed(title = "Lorem Ipsum", description = message.content)
  webhook = await bot.fetch_webhook(YOUR_WEBHOOK_ID)
  author = message.author
  await message.delete()
  await webhook.send(embed = embed, username = author.display_name, avatar_url = author.avatar.url)
#

i haven't tested the code

#

but its probably 99% correct

#

or smth

#

just be sure u created a webhook

#

and get its ID, then replace YOUR_WEBHOOK_ID with the actual ID

burnt idol
#

y would u need that?

solar glen
burnt idol
#

i meant like this can be done by bot alone

#

or is there some advantage

solar glen
#

the advantage is this

#

username = author.display_name, avatar_url = author.avatar.url

#

u can customise the username and avatar of the webhook, for that specific message

#

i use it for my snapshot / channel backup feature

slate swan
#

guh

#

need some help

#

So i got made bot to send automessages on a timer and those messages and times can be updated with !set_message !set_interval problem is i needed a default message and time for me to test in such. everything seems to work, the messages print at the deafult times and everything, and the commands work too printing "message changed to (blah blah blah)" except they dont update. its hell bent on sticking with the defaults.

#

is there somthing im missing

stuck radish
#

guys I was trying to implement some cogs in but without success can someone help me?
this is the function where i load the cogs

async def load():
    for filename in os.listdir("./cogs"):
        await bot.load_extension(f"cogs.{filename[:-3]}")
        print(f"Filename: {filename}")

a test class to test it

from discord.ext import commands


class Test(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.command()
    async def test(self, ctx):
        channel = ctx.channel
        await channel.send("Ready to work")


def setup(bot):
    bot.add_cog(Test(bot))
solar glen
#

here is the old algorithm implementation

solar glen
# solar glen Ok, here we go again. I don't think you guys got the problem yet so its ok il ex...

which is something i worked, truly with blood and sweat(but learned in the way a lot of things. Like compression and the thinking process of how to shrink data without losing information to a certain extent. One method in which i use is called "Message Chunking" which chunks messages toggether in 1 message instead of 5 based on conditions, this not only speeds up the recreation part dramatically but also becomes much smaller for file size)

slate swan
#

BACK TO THE VOID

burnt idol
#

like if i want to make the bot interactive

#

like conversation handler or somethign

solar glen
#

hm?

slate swan
#

I suppose you have the message content intent enabled, if not it may be a smart idea to enable it krWriting

Would be better to explain more than just "not working" e.g. up until where it doesn't work

spark nimbus
idle radish
graceful basin
#

Hi guys, is it possible for a Bo to yo give a specific role based on what a persons status is? Fo4 example, if the user has the status โ€œjohnโ€, it gives them the role โ€œpogโ€

white citrus
#

my view doesn't stay persistent

graceful basin
sick birch
graceful basin
white citrus
#

Does anyone have an example where I can keep a button persistent with the message id or custom id?

slate swan
#

!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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

young dagger
#

!source

unkempt canyonBOT
young dagger
#

Will the Python bot remove the DM if the ban is revoked?

slate swan
#

hi, can someone help me?
trying to make a ban command
code: https://paste.pythondiscord.com/EHKA
traceback:

Traceback (most recent call last):
  File "C:\Users\acatt\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 124, in wrapped
    ret = await coro(arg)
          ^^^^^^^^^^^^^^^
  File "C:\Users\acatt\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 978, in _invoke
    await self.callback(self.cog, ctx, **kwargs)
  File "c:\Users\acatt\OneDrive\Desktop\kasabot\cogs\ban.py", line 33, in ban
    await username.ban(reason=reason)
          ^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'ban'

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

Traceback (most recent call last):
  File "C:\Users\acatt\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\bot.py", line 1114, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "C:\Users\acatt\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 375, in invoke
    await injected(ctx)
  File "C:\Users\acatt\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\commands\core.py", line 132, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'str' object has no attribute 'ban'```
slate swan
#

wtf

#

also why you need /ban command when there is already one provided by discord

young dagger
#

What could I call the DM generated by the bot that we insert into the database?

slate swan
#

also theres like no duration lol

#

Never understood the reason behind temp bans kek

#

Either you ban them or not, if you don't you timeout them

young dagger
#

How can we save the DM so that when we revoke the warning, it also deletes the DM that the bot sent to the user?

slate swan
#

save the sent message id to db and then remove it?

young dagger
slate swan
#

messageId ?

young dagger
# slate swan messageId ?

Do we need to fetch the message when deleting it?

dm_message_id = warning.get("dm_message_id")

dm_message = await member.fetch_message(dm_message_id)

await dm_message.delete()```
young dagger
#

To database and delete it

slate swan
#

idk how you wanna delete message by having jump url but sure

young dagger
slate swan
#

i dont know

#

i you know that python bot has such system you can check its source code

#

!src

unkempt canyonBOT
brazen raft
# young dagger Do we need to fetch the message when deleting it? ```py dm_message_id = warning...

Do we need to fetch the message when deleting it?
I believe DM messages cannot be deleted by recipients, so no

await member.dm_channel.get_partial_message(dm_message_id).delete()

It would be wise to check whether member.dm_channel isn't None though. It probably shouldn't be the case as long as you haven't deleted the message already, but I'm not experienced enough to think of other situations where this might be the case right away

young dagger
brazen raft
#

I don't know how to bind a Python callback to an SQL DELETE transaction

#

That is if you mean you want to delete the DM when deleting the record from the database

young dagger
#

What is the different between fetch_message and get_partial_message anyway?

brazen raft
#

I assume get_partial_message uses the channel's cached messages because there's no waiting for a response because I assume no request is sent

young dagger
brazen raft
#

fetch_message awaits a response

#

for a potentially rate limited request

sick birch
#

It makes a sort of "fake message"

#

Useful if you want to edit a message with just an ID, for instance

brazen raft
#

Basically with a snowflake object

#

I have no idea how get_partial_message fills the object's attributes

#

But at least you can use it to delete the message

young dagger
brazen raft
#

I refuse to believe ORMs can't bind Python callbacks to DELETE transactions

#

That seems like something very neat that they would support

buoyant quail
#

And created_at can be calculated based on id it seems

sick birch
sick birch
young dagger
sick birch
burnt idol
#

i have a dropdown view i want it to disapear after user selects one of the options? how can i acheive that
bcz interaction.delete_original_meassage isen't working

#

i can't even edit it for some reason

slate swan
tiny nimbus
#

getting the error related with session what do i do

final iron
spark nimbus
#

i am not getting any error

vocal snow
#

does the print in the on_ready tell you how many commands were synced?

spark nimbus
spark nimbus
#

tryed moving it to its own event but didnt worked

buoyant quail
#

Your setup_hook is inside the on_ready. It's not even a method here

winter token
#

!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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

winter token
#

it sent ques3, ques4 and ques5 at once without waiting for the reply. why did it happen?

golden portal
#

on_message also triggers for your own bot message

naive briar
#

That's why we have checks ๐Ÿฅด

golden portal
#

in the check you need to exclude your own bot's message so it doesnt trigger the wait_for

shrewd fjord
naive briar
#

Or if the message was sent by the command executor

golden portal
#

well tbf the channel is in a dm but i guess

naive briar
#

Oh right

winter token
golden portal
#

why not a modal btw, it's for that purpose

#

a lot more prettier too

winter token
#

should i try updating the check?

golden portal
#

both works

winter token
#

ok

buoyant quail
#

You don't have Cogs directory, but you are trying to load file Cogs/ticket.py

#

@spark nimbus

brazen raft
brazen raft
buoyant quail
brazen raft
#

Through discord.User.dm_channel or discord.Member.dm_channel it's probably complete, otherwise those properties return None instead of any channel object

buoyant quail
#

Do what? Just give a correct path to your extension

spark nimbus
buoyant quail
#

If you have

main.py
cog.py

It's load_extension("cog")
If you have

main.py
HELLO/
..cog.py

It's load_extension("HELLO.cog")

spark nimbus
#

do you mean like: and cog list?

slate swan
slate swan
#

I Have a ticket system which works like that, and i have defined the role that the user needs to be able to see tickets. How can i make that role change for every ticket selection? Like for the support ticket i want it to be donation manager, but for the support ticket the staff.

#

i use if select.values[0] == "01":, if select.values[0] == "02": etc.

#

help

void mauve
#

So basically the issue with setup_hook() function. If i call client.load_extension() it works perfectly, but inside BotClient() class it just doesn't. Any ideas?

# run.py
import os
import asyncio
import discord
import logging.handlers

from discord.ext import commands

from bot.logs.logger import logger
from bot.misc.config import token


class BotClient(commands.Bot):
    def __init__(self):
        intents = discord.Intents.all()

        super().__init__(intents=intents)

    async def setup_hook(self):
        for file in os.listdir(os.path.abspath('bot/cogs/commands')):
            if file.endswith('.py') and file != '__init__.py':
                cog = f'bot.cogs.commands.{file[:-3]}'
                try:
                    self.load_extension(cog)

                except Exception as e:
                    logger.exception(e)

    async def on_ready(self):
        logger.info(f'Bot is up and ready. Logged in as {self.user}. ID: {self.user.id}')

        await self.setup_hook()


client = BotClient()


if __name__ == '__main__':
    client.run(token)
naive briar
#

You shouldn't have to manually call setup_hook if you're using discord.py

#

And calling setup_hook in on_ready isn't any different than just on_ready

#

Also, if you're really using discord.py, you'd need to await the load_extensions

void mauve
slate swan
#

hello

#

i have proplem

#

c

#

if i write event and commands in same file the code is stopped and just events work without commands

#
import discord
from discord.ext import commands
import random

# ุฅู†ุดุงุก Client
bot = commands.Bot(command_prefix='!', intents=discord.Intents.all())

# ุงู„ุฃู…ุฑ ุงู„ุจุณูŠุท


@bot.command()
async def say(ctx):
    await ctx.send(f'lol')


@bot.command()
async def Mot(ctx):
    rand_o = ('ุงู„ู†ุฌุงุญ ู‡ูˆ ุงู„ู†ุชูŠุฌุฉ ุงู„ู…ุดุฑู‚ุฉ ู„ู„ุชุญุฏูŠุงุช ุงู„ุชูŠ ุชูˆุงุฌู‡ู‡ุง.',
              'ุงู„ุซู‚ุฉ ุจุงู„ู†ูุณ ู‡ูŠ ุงู„ู…ูุชุงุญ ู„ุชุญู‚ูŠู‚ ุฃูŠ ู‡ุฏู.',
              'ุงู„ุนู…ู„ ุงู„ุฌุงุฏ ูŠุญู‚ู‚ ุงู„ุฃุญู„ุงู….',
              'ุงู„ุงุจุชุณุงู…ุฉ ู‡ูŠ ู„ุบุฉ ุชุญูŠุฉ ุชุตู„ ุฅู„ู‰ ุงู„ู‚ู„ูˆุจ.',
              'ุงู„ูุดู„ ู‡ูˆ ูุฑุตุฉ ู„ู„ุชุนู„ู… ูˆุงู„ู†ู…ูˆ.',
              'ุงู„ุงุณุชู…ุฑุงุฑูŠุฉ ู‡ูŠ ุงู„ุณุฑ ุงู„ุญู‚ูŠู‚ูŠ ู„ู„ู†ุฌุงุญ.',
              'ุงู„ุฅูŠู…ุงู† ุจุงู„ู†ูุณ ู‡ูˆ ุงู„ุจุฏุงูŠุฉ ู„ูƒู„ ุฅู†ุฌุงุฒ.',
              'ุงู„ุฅูŠุฌุงุจูŠุฉ ุชุฌุนู„ ุงู„ุญูŠุงุฉ ุฃูƒุซุฑ ุฌู…ุงู„ู‹ุง.',
              'ุงู„ุงุจุชูƒุงุฑ ู‡ูˆ ู…ูุชุงุญ ุงู„ุชุทูˆุฑ ูˆุงู„ุชู‚ุฏู….',
              'ุงู„ุนู…ู„ ุงู„ุฌู…ุงุนูŠ ูŠุญู‚ู‚ ุงู„ู†ุฌุงุญุงุช ุงู„ูƒุจูŠุฑุฉ.',
              'ุงู„ุตุจุฑ ู‡ูˆ ุงู„ุณู„ุงุญ ุงู„ุฃู‚ูˆู‰ ููŠ ุชุญู‚ูŠู‚ ุงู„ุฃู‡ุฏุงู.',
              'ุงู„ุนู‚ู„ ุงู„ุฅูŠุฌุงุจูŠ ูŠุญู‚ู‚ ุงู„ู†ุฌุงุญ ูˆูŠุชุบู„ุจ ุนู„ู‰ ุงู„ุชุญุฏูŠุงุช.',
              'ุงู„ุงู…ุชู†ุงู† ูŠุฌุนู„ู†ุง ู†ุฑู‰ ุฌู…ุงู„ ุงู„ุญูŠุงุฉ.',
              ' ุงู„ุนู…ู„ ุจุดุบู ูŠุฌุนู„ ุงู„ุญูŠุงุฉ ุฃูƒุซุฑ ุฅุดุฑุงู‚ู‹ุง.',
              'ุงู„ุญู„ู… ู‡ูˆ ุจุฏุงูŠุฉ ูƒู„ ุฅู†ุฌุงุฒ ุนุธูŠู….',
              'ุงู„ุนุฒูŠู…ุฉ ู‡ูŠ ุงู„ู‚ูˆุฉ ุงู„ุชูŠ ุชุญู‚ู‚ ุงู„ู…ุณุชุญูŠู„.',
              'ุงู„ุฅุฑุงุฏุฉ ุงู„ู‚ูˆูŠุฉ ุชุญู‚ู‚ ุงู„ุฃู‡ุฏุงู ุงู„ุนุธูŠู…ุฉ.',
              'ุงู„ุนู…ู„ ุงู„ุฐูƒูŠ ูŠุนุฒุฒ ุงู„ุฅู†ุชุงุฌูŠุฉ ูˆุงู„ุชููˆู‚.',
              'ุงู„ุนู‚ู„ ุงู„ู…ุชูุชุญ ูŠุชูŠุญ ู„ู†ุง ุงูƒุชุดุงู ุงู„ุนุงู„ู….',
              ' ุงู„ุญุจ ูˆุงู„ุชุณุงู…ุญ ูŠุตู†ุนุงู† ุนุงู„ู…ู‹ุง ุฃูุถู„.'
              )

    rand = random.choice(rand_o)
    await ctx.send(rand)


@bot.command()
async def Help(ctx):
    embed = discord.Embed(title="Help Command ",
                          description="ู…ุณุงุนุฏุฉ ููŠ ุงูˆุงู…ุฑ ุงู„ุจูˆุช ", color=discord.Color.random())
    embed.add_field(name="ู„ู„ุบุฉ ุงู„ุนุฑุจูŠุฉ ุชุญููŠุฒ ุจู„ุบุฉ ุงู„ุนุฑุจูŠุฉ ",
                    value="!Mot", inline=False)
    embed.add_field(name="English Lnaguage ",
                    value="SOON MY FRIENDS", inline=False)
    embed.set_footer(text="By : Lucky Nord")

    await ctx.send(embed=embed
#

@bot.command()
async def on_ready():
    print(f'THE BOT IS GOING UP LETS GOO')


@bot.command()
async def on_message(message):
    if message.author == bot.user:
        print("it is bot")
        return
    if 'hello' in message.content:
        await message.channel.send('hello')


trt = open("games\gg.txt", 'r')


@bot.command()
async def pall(ctx):
    trt = open("games\gg.txt", 'r')
    tt = trt.readline
    rand = random.choice(tt)
    await ctx.send(rand)


bot.run('MY TOKEN IS HERE')
slate swan
#

thanks you

#

my friendooo

golden portal
#

welcome

slate swan
#

@golden portal

#

the event On_ready dosenot work like this

golden portal
#

wdym

slate swan
#

what

#

i dont understand lol

young dagger
#

How can I use get_partial_message to delete a DM?

golden portal
slate swan
#
@bot.event
async def on_ready(ready):
    print(f'THE BOT IS GOING UP LETS GOO')
    await bot.process_commands(ready)

#

doesnot work

#

[2023-10-29 13:50:10] [ERROR ] discord.client: Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\Orbit\AppData\Local\Programs\Python\Python311\Lib\site-packages\discord\client.py", line 441, in _run_event
await coro(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
TypeError: on_ready() missing 1 required positional argument: 'ready'

#

like this erorr

golden portal
#

also on_ready doesn't take any argument

slate swan
#

then what

#

i use to program

#

can i use listen ?

golden portal
vale wing
slate swan
#

yes it so beautifl

young dagger
#

Regarding moderation tools

golden portal
#

yes you need to store both the channel and the message id, you can't just have a singular message id

#

wait

#

wdym for warning im so confuse

young dagger
#

"You have been warned for: NSFW"

Okay this was a mistake lets revoke this case...

The bot will now remove the warn and delete the DM sent out to the user, as it was a mistake.

golden portal
#

o oke, yea just store the dm channel id and message id

#

since user id and their dm channel id is different

#

doin user.create_dm is possible to get em but that defeats the purpose of the partial messageable

young dagger
golden portal
#

nop ```py
message = bot.get_partial_messageable(channel_id).get_partial_message(message_id)

#

!d discord.Client.get_partial_messageable

unkempt canyonBOT
#

get_partial_messageable(id, *, guild_id=None, type=None)```
Returns a partial messageable with the given channel ID.

This is useful if you have a channel\_id but donโ€™t want to do an API call to send messages to it.

New in version 2.0.
young dagger
golden portal
#

eh my bad, idk why i put await there

golden portal
#

i do be getting kinda disoriented

young dagger
golden portal
#

๐Ÿค”

#

u sure it's correct then? how do you save the channel id + message id

young dagger
# golden portal u sure it's correct then? how do you save the channel id + message id

Basically I'm just trying out the function:

    if message.content.startswith('!send_random_dm'):
        user = message.author
        random_message = "Test"
        sent_message = await user.send(random_message)

        channel_id = message.channel.id
        await message.channel.send(f"Sent DM. Channel ID: {channel_id}. Message ID: {sent_message.id}")

    if message.content.startswith('!delete_dm'):
        inputs = message.content.split(' ')

        if len(inputs) == 3:  # Assuming command format is "!delete_dm [channel_id] [message_id]"
            channel_id = int(inputs[1])
            message_id = int(inputs[2])

            dm_message = client.get_partial_messageable(channel_id).get_partial_message(message_id)
            await dm_message.delete()```
golden portal
#

well, that isn't a dm channel you're saving there, do ```py
dm_channel = await user.create_dm()
sent_message = await dm_channel.send(random_message)

then you use that channel id instead of whatever message.channel is
#

user.send under the hood uses create_dm anyways, so no worries about it

buoyant quail
#

(or just sent_message.channel.id)

golden portal
#

oh true

young dagger
# golden portal oh true

I need to await to actually delete the message?

dm_message = client.get_partial_messageable(channel_id).get_partial_message(message_id) 
await dm_message.delete()```
golden portal
#

the delete method yes

young dagger
#

Thanks

hollow zinc
#

Is it gonna work also for subfolders?

#

instead of files in the cogs folder
cogs folder - main
folders like - admin, mod, misc etc
files like - ping.py, mute.py, play.py

golden portal
#

nope, os.listdir doesnt go subdirectories, maybe you want glob.glob instead?

slate swan
shrewd fjord
#

Could u show what category is

slate swan
#

sure

slate swan
golden portal
#

probably one of the overwrites a None obj

slate swan
lunar gale
#

who knows about wavelink?

slate swan
#

Someone in a ~400k member server likely does

ivory storm
#

Hi

#

i have problem, my bot don,t respond on my server but on private mesage respond

#

does anyone know why

slate swan
#

!message-content-intent

unkempt canyonBOT
#
Discord Message Content Intent

The Discord gateway only dispatches events you subscribe to, which you can configure by using "intents."

The message content intent is what determines if an app will receive the actual content of newly created messages. Without this intent, discord.py won't be able to detect prefix commands, so prefix commands won't respond.

Privileged intents, such as message content, have to be explicitly enabled from the Discord Developer Portal in addition to being enabled in the code:

intents = discord.Intents.default() # create a default Intents instance
intents.message_content = True # enable message content intents

bot = commands.Bot(command_prefix="!", intents=intents) # actually pass it into the constructor

For more information on intents, see /tag intents. If prefix commands are still not working, see /tag on-message-event.

ivory storm
#

I have all intents intents = discord.Intents.all()

golden portal
golden portal
#

that is literally your code lol

final iron
final iron
# slate swan Idk

Itโ€™s your code. You should know where it is. If you donโ€™t know, you can quite easily figure it out.

slate swan
#

How should i define it

#

overwrites = ?

final iron
#

!d discord.Guild.create_text_channel

unkempt canyonBOT
#
await create_text_channel(name, *, reason=None, category=None, news=False, 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/latest/api.html#discord.TextChannel) for the guild.

Note that you must have [`manage_channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_channels) 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) of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member) or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role)) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#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/latest/api.html#discord.TextChannel.edit) will be required to update the position of the channel in the channel list...
final iron
#

View the docs

slate swan
#

Yeah

#
overwrites = await create_text_channel(name, *, reason=None, category=None, news=False, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=..., ...")
```?
final iron
#

???

#

what

#

The docs literally have an example on how to pass overwrites

slate swan
#

OHHHHHH

#

i have overwrites

slate swan
final iron
#

You have multiple instances of overwrites

#

One of them is None

slate swan
#

i only have 1 instance

final iron
#

Share your entire error

slate swan
#
Traceback (most recent call last):
  File "/home/container/.local/lib/python3.11/site-packages/discord/ui/view.py", line 427, in _scheduled_task
    await item.callback(interaction)
  File "/home/container/main", line 214, in my_callback
    created_channels.append(channel.id)
                            ^^^^^^^
UnboundLocalError: cannot access local variable 'channel' where it is not associated with a value```
#

@final iron

#

I Never changed the code

#

its been the same for years now

#

it appeared now

slate swan
final iron
#

Share the entire code

#

!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 Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

slate swan
#

bc people will steal it

final iron
#

Ok

slate swan
#

send me a dm

final iron
#

Okay, so

final iron
slate swan
#

Imagine people caring that much about ๐Ÿ code yawn

final iron
#

Nobody is going to steal this guys code lmao

#

Itโ€™s not unique

#

Itโ€™s just a ticket system

slate swan
#

File "/home/container/main", line 214, in my_callback
created_channels.append(channel.id)
^^^^^^^

#

oh im fucking dumb

final iron
slate swan
#

214

#

created_channels.append(channel.id)

#

The paste goes up to line 136

slate swan
#

Considering we have a paste and not your code, give the line for the paste instead

#

i did

slate swan
final iron
#

No you didnโ€™t

slate swan
#

That's your code. Not the paste

#

line 117 in pastebin

#

The paste has a maximum line number of 136, so it cannot be 214

slate swan
#

And there seem to be some inconsistency with the indentation overall

final iron
#

Itโ€™s very spaghettified

#

Hard to read

slate swan
#

now help me

#

anyone that can help??

#

any bot makers

final iron
#

Nested functions, random naming, overwriting variables

final iron
sick birch
final iron
# slate swan KK

Look into subclassing View and Select as that'll help your code become more readable

#

You're doing way too many things in 1 function

oak abyss
#

hey @tropic burrow

slate swan
tender bobcat
#

aint going to fix this repeatively recurring nested function

final iron
hallow kernel
#

Can i get pfp of some user, nit having any bot token? So without bot account

#

Just by their id/nickname

#

Or i need some bot to
bot.fetch_user("nickname")

slate swan
hallow kernel
slate swan
#

They are not doing things as Discord wants to, from what I last heard Discord staff were looking into that

#

(They're doing things against the ToS)

latent jay
#

How long does it take for commands to sync when syncing tree to specific guild?

latent jay
# final iron It varies

my bots only in one guild and it's kinda annoying having to wait for the commands to show up

final iron
#

How often are you syncing

cold oyster
#

discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interactionWhat error is this?

cold oyster
# cold oyster ```discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interacti...
@client.hybrid_command(name="java_status")
async def java_status(ctx, serverip):

    server = JavaServer.lookup(serverip)

    status = server.status()
    latency = int(status.latency)
    try:
        query = server.query()
    except Exception as e:
        query="Failed. Make sure the server has query enabled in `sever.properties` file"

    

    embed = discord.Embed(
        title=f"Minecraft java server status",
        description=f"Status for {serverip} java server.",
        color=discord.Color.random()
    )
    embed.add_field(
        name="Online Players",
        value=f"The server has {status.players.online} player(s) online."
    )
    embed.add_field(
        name="Ping",
        value=f"`{latency}`ms"
    )
    embed.add_field(
        name="Player List",
        value=f"{query}"
    )
    await ctx.send(embed=embed)

This command runs fine when I use it as a normal command but as a slash command it fails

fading marlin
#

It's taking too long to respond to the interaction

latent jay
#
TypeError: Interaction client is not derived from commands.Bot or commands.AutoShardedBot```
I'm trying to use  `commands.Context.from_interaction`
fading marlin
#

You're using discord.Client instead of the commands.Bot alternative

latent jay
#

but with slash commands I thought you have to use .Client?

fading marlin
#

Or Bot, either work

#

Though to use Context, you necessarily need Bot

latent jay
#

how would I initialize it with Bot?

fading marlin
latent jay
#

How would I sync then?

fading marlin
#

Using Bot.tree

cold oyster
latent jay
#
blah = discord.Client(intents=intents)
tree = app_commands.CommandTree(blah)
await tree.sync(guild=discord.Object(id=blahblah))

would change to?

blah = commands.Bot(command_prefix=',', intents=intents)
tree = app_commands.CommandTree(blah)
await blah.tree.sync(guild=discord.Object(id=blahblah))
fading marlin
#

Kind of, you don't need to initialize a tree yourself, as that is already done by commands.Bot

#

!d discord.ext.commands.Bot.tree

unkempt canyonBOT
#

property tree```
The command tree responsible for handling the application commands in this bot.

New in version 2.0.
cold oyster
# fading marlin Using Bot.tree
  File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\hybrid.py", line 438, in _invoke_with_namespace
    value = await self._do_call(ctx, ctx.kwargs)  # type: ignore
  File "C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\commands.py", line 846, in _do_call
    raise CommandInvokeError(self, e) from e
discord.ext.commands.errors.HybridCommandError: Hybrid command raised an error: Command 'java_status' raised an exception: NotFound: 404 Not Found (error code: 10008): Unknown Message

I sent a message when the command is executed and then edit the message after 5 seconds, This is the error I got

fading marlin
#

What does your code look like?

cold oyster
# fading marlin What does your code look like?
@client.hybrid_command(name="java_status")
async def java_status(ctx, serverip):
    message = await ctx.send("*Please wait*")

    server = JavaServer.lookup(serverip)

    status = server.status()
    latency = int(status.latency)
    try:
        query = server.query()
    except Exception as e:
        query="Failed. Make sure the server has query enabled in `sever.properties` file"

    

    embed = discord.Embed(
        title=f"Minecraft java server status",
        description=f"Status for {serverip} java server.",
        color=discord.Color.random()
    )
    embed.add_field(
        name="Online Players",
        value=f"The server has {status.players.online} player(s) online."
    )
    embed.add_field(
        name="Ping",
        value=f"`{latency}`ms"
    )
    embed.add_field(
        name="Player List",
        value=f"{query}"
    )

    time.sleep(5)

    await ctx.message.edit(embed=embed)```
#

pretty long ig sry

fading marlin
#

You're trying to edit the message that invoked the command, not the intial message that you sent

cold oyster
#

im dumb

fading marlin
#

Assuming blah = commands.Bot(...)

latent jay
#

does that sync globally?

fading marlin
#

If you don't give it a guild, yes

latent jay
#

I though if you provide guild it'll sync automatically?

fading marlin
#

It'll sync to the guild you provided, you still have to call sync

latent jay
#

hmm I don't see any slash commands still

fading marlin
#

If you're syncing to a guild, the commands should also be marked for that guild

latent jay
#

and the deco would be @blah.command() still no?

fading marlin
#

If you just want slash commands, no. It changes to @blah.tree.command(...). For convenience, some set tree equal to bot.tree below their bot definition, which means you can do @tree.command(...) instead

latent jay
#

gotcha it worked.

#

thanks

fading marlin
#

Sure thing

latent jay
#

does interaction.response.send_message reply to the original message?

hallow kernel
shrewd apex
latent jay
#

anyway to make it just send instead of reply?