#discord-bots
1 messages ยท Page 317 of 1
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
๐
what does right clikc mean
maybe
Right click on file in sidebar and copy path
Use \\ or /, not \
you gotta set it to utf-8
\ is used for special characters
no
or that
lol
.
!e
"\U"
@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
haha
I have a doubt , why do it gives error?
should \U be escaped like \n
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
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
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
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.
Iโd probably look into this
Why not just use cogs
What is this lmao
yes
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
ok, good
๐
That's other question xd But in docs they are only defining normal commands using cogs. So how can I use tree command in my case?
https://gist.github.com/AbstractUmbra/a9c188797ae194e592efe05fa129c57f#file-05-extension_no_group-py
Id take a look at this example, and the gist in general
discord.py 2.0+ slash command info and examples. GitHub Gist: instantly share code, notes, and snippets.
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
idk tbh how to load them and convert from lottie to webP(i might have to use pillow for that, im aware of that)
What the full error
If pillow supports it that would probably be the best solution
Probably rule 5 as well
yes
but idk if it does, it probably doesn't
It is
this package sucks ngl
complexity for no reason
very old website and not even maintained
Yeah I know, documentation sucks
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
i litterally am forced to use this
why
im trying to convert a lottie file into a webp
bc discord stickers use them
(default ones mostly im aware)
this one example
are you trying to create sticker or smth
well i try to store it as a image
He got them fake js
so i can send it via webhook bc of the annoying limitation of webhooks not being able to send stickers
why not just use the bytes?
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.
!d discord.Sticker check docs ig
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.
well i try to just do that
There's that url attribute you can pass anywhere
use bytes and write them in a .webp file
i wanna store them quite forever
or whatever file you want
yes, i try to do that. But i have to basically load the lottie json data
Can you send a screenshot of your terminal when you run this?
then export it to a webp, so i need a library for that
the url doesnt return byte or smth?
it returns, but
sec
i want to store it
Just write them
Aiohttp is sufficient for downloading image and saving it
resp = ...read() # returns byte
open('somestff.webp', 'wb').write(resp)
something like that
wb mode
oih w
let me get to the problem in more detail
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)
ok next..
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
mhm
Detail is enough, you wanna save the image in webp format. You fetch it with aiohttp by making GET to sticker's url, reading its contents and writing to any file
wait wait wait
tf
And yeah urls are not affected by channels deletion, only by sticker deletion
i thought Sticker has a read method sus
wait this gives me a idea
btw storing urls now bad anyway, yk url will get expired after some period of time
basically you cannot use discord as filehost now
You'd want to only store sticker IDs btw if you don't care about stickers getting deleted
yes
exen you shoud stop abusing it ๐
Well I told them to download image
I never told to store url
You just can't download it without url
@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...
For bobux bot db backups never
Can you show us your terminal output
yh
I have daily backups for each db in cluster
What do you mean terminal output?
@sick birch how do we promote bobux please help ๐ญ
Is that it?
sedly Sticker dont have read method su gey
Just GET it
Click on the "terminal" tab
just get good
Run --> command --> no errors..
And you typed !ping in discord?
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)
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...
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)
Absolutely!
In the same server as the bot? After it was online?
Yes, even after restarting
the bot
WAit
I found smth
@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
Yes
lottie json?
thanks did paid attention
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.
huh lemme debug rq
its SVG but animated
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}......
dunno what r you talking about https://discordpy.readthedocs.io/en/latest/api.html#discord.StickerItem.url
a StickerItem always has a url
wait
uh fk my internet issue is going on thats why unable to debug
fk this internet providers man 
my sticker box aint even loading bruv

tbh the thing is i just wanna store stickers
can stickers show up when they are typed as text, like emojis with :something:
https://cdn.discordapp.com/stickers/816087792291282944.json
i see its a json url indeed
lottie to be exact
๐
internet issue meant to send this skull emoji later
ok
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
i dont think it will work but give it a try ig
appereantly bots can send stickers let me see how
!d discord.Message
it didn't work
i mean its discord being discord ๐
oh onl ythis problem ?
i mean its one of the simple problems
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
well just temporarily write the lottie json to a json file?
Anybody have thoughts on nextcord vs discord.py?
it also uses playwright which yeh.......
opens the browser and all of that
Both are decent though I would recommend discord.py because it's got more support
ye lol
Thanks for the input
no way I haven't seen that phrase in my entire life and now I did twice in 2 minutes
crazy
here and where
apparently the lottie package even sucks at converting lottie json to webp
i got this from this
its litterally awful ๐
im even thinking to skip the stickers entirely
and just ignore them bc of their annoying nature to work with
huh did you send that sticker? or is t from that file cxd
!ytdl
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)
nuh uh was way funnier
maybe just send the url lol
Download ffmpeg , it's a cli tool
just send the raw url for lottie file
And add it to path
and bro's helping
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
ik, something is better than nothing xd
How do i mention a user with webhook desc in a message i forgot
user.mention / <@user_id>
!d discord.User.mention
property mention```
Returns a string that allows you to mention the given user.
but there isn't any point of sending it
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
Why tf am I laughing at this
bc of unnesscarry complexity?
The stickerโs name.
@solar glen use stickers name if its default else show image so no mess xd
!d help
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.
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.
much useful ๐
@shrewd fjord is there any spotify or soundcloud python packages
Rule 5
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.")```
guild_name is a required argument that is missing
where
Where is what
where is it missing
When the user invokes a command and an argument is missing that error is raised
Hey, does anyone know how I can make a discord bot that logs the clients IP when they authorize it?
^^ Security purposes
Like authorized via oauth?
yeah ok where is it missing i even put guild_name in the leave_guild(self, ctx, *, guild_name) part
how do i fix it
Depends on what you think fixing it is
Yeah
Don't believe that's possible. You can view the oauth scopes here:
https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes
So how does security bots work like Security Premium?
I have no clue what that is and how it works
Damn, alright. I'll do some more digging
@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
No?
SAME ERROR WHY IM PUTTING THE ID
What is bot.leave_guild
i saw it on the stack overflow post i provided
And, it'll still error
Yes, probably around 5 years old
How is your file even configured
How is the bot variable in the class scope
Doesn't make any sense
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
Bot : https://securitybot.gg/
Security is a powerful Discord bot offering robust moderation, anti-nuke, anti-raid, anti-spam, and verification features - all for free and at lightning speed.
Can't be bothered to go through it. Why do you think it logs users IPs
Scopes is just basic python
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
I know it does, someone who owns a server uses it for security purposes just incase someone attempts to leak something of like src code etc
are u talking about bot = commands.Bot(command_prefix=".", intents=discord.Intents.all())
Okay, how do you know it does
He's shown logs of the bot
It provides the admins with users IP data?
Correct.
No, I'm talking about the scope of your class, as you're passing in self as the functions first argument
but at that point I don't think discord would authorize it
The bot doesn't have users visit their website to verify?
look idk man i saw it in the post
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
I'd take a look at this probably to get you started off
Maybe, never checked
let me check rq
Most likely the scenario
it wasnt copy and pasted i try to use that code and make it my own
Providing administrators users IPs is crazy though
That's an extreme breach of user privacy
i try to use that code and make it my own
This denotes you took it from somewhere
bro i didnt select it ctrl c and ctrl v into my ide
I would learn basic concepts first like classes and scopes, and then try discord.py
i looked at it and tried using it but tried making it my own
Do you know what self is in a class?
no
Okay, that's a problem then
Understanding classes is essential in discord.py as it's primarily based around OOP
whats oop
Object Oriented Programming
@final iron yeah redirects to restorecord
ok
so how would i make a class
ive seen people do something like class #something
Why do you need to create a class
lol
idk bro u mentioned the class thing for self
I never said anything about creating a class
u said this
Yeah, understanding classes
Step 1 to understanding classes is not making them
Visit the resources page and look at some articles
yeah ok this isnt helping me though
!classes
!class
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.
Did you go over the resources
no im going to sleep
i looked at this tho
ok...
@final iron where do i start from here
Start what
yh its up to you how u customize it,,
usually the ip is in the req headers with the key X-Forwarded-For
as long as the user opt-in and knows what they are doin
I mean...if we're being real, the % of users who know that it's even happening is incredibly low
So would I have to rediret my user somewhere or no? If I can, would it cost me money to redirect them or could I use a simple flask page to grab the IP?
You can just use a single page
i mean they should know that they are using their ip to enter a website so ofc its visible to the website
Thatโs a given, but apparently the IPs are available to discord server administrators
yeah you can do the 2nd one, but make sure tell users what you are doin 
Yeah, users would read the Terms of Service
So how exacly would I grab the users IP creating a flask page?
agreed, but tbh taking ip isnt a issue these days, since mostly ips are dynamic and changes real fast
hope so
well create a flask app add a get endpoint to /redirect or smth then get the header using flask.Request.headers
and get the ip
alright, and you said it was the X-Forward-For?
Alrighty
its just a key in the header
Bot doesn't have that ig
!d flask
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.
hm it has flask
If getting the IP on that page is unsupported by Discord, it shouldn't be done
Lay out your security purposes first
It will be in the terms of serivce, if the user wants to use their IP address they can, if not they can leave. Not a big deal.
I'm saying maybe there's a better way to solve your security concern
I need to know what it is to begin with
Security purposes just incase of our src code, stocks, any of that type of stuff get leaked.
Stop your bot from showing any of that information to its users
Problem solved
Leaking is your fault, so stop doing that
Bot doesn't do that, we have "trusted" people who hold, host, update, etc to our src & stocks. If any of them decide to leave they will probably leak stocks, src, etc. Not as simple as you may think.
If the service's only interface is the Discord user, their IP address will be useless
Best to block the Discord user
Will not be useless as our members may do something about it.
Once the src gets out its out.
Where can i find the docs for discord.py slash commands? been looking but all I can find is other libraries
Hold them accountable in court
!d discord.app_commands # whatever, well it's that
No documentation found for the requested symbol.
!d discord.Interaction
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.
Have them sign up a contract
ty
open this, it will show you the interaction api refrence
It's a security procedure. If you're not going to be able to help me create my bot then I am all set.
hm
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
I can create that myself, I just need to know how to setup the bot to send the flask link
Almost like restorecord as if you will
The sliest solution would be a Discord login on your website or service and then get the IP once they log in
Okay, good talking to you.
You can set up a dashboard website or something like it then tell the users about it
problem solved
I am not going to fight with you if I want to log my clients IP's, as I said its a security procedure and I will do as I please.
people caring about IP addresses ๐ฅฑ
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
I've already clarified the way I want it. I am not going to be holding up a database just to get a clients IP. I am using this information as I said before to prevent leaking src code, invalid authenticated users, or stock leaks.
Not sure how that's supposed to prevent that but I guess you know your architecture better
They can get all that just in the invitation page interface?
I'm not sure if I understand this but if my admins/providers decide to leak my stocks, I will be giving it to people who know how to deal with this type of situation
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
I would have it sent through a webhook into my server.
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
Also, if I were to store it in a database, it would be a private folder only authenticated towards me.
Why would they even be given access to that in the first place
I mean, I'm fine with storing IPs they're most of the time pointless but just trying to understand
Providers are the people who give fresh stocks, and admins update the code here and there.
Agreed, as I said I would just like to have it as a procedure.
Yeah I mean why not, but then you should probably make some legally binding contracts, NDA, etc.
Which has more influence than an IP
Agreed, I see what you are saying. But if the user agrees to my terms of service there would no illegal bindings to it.
I just wouldn't send IPs around via webhooks
Storing them? Yeah well why not, every service does it today so who cares
It would be only authenticated to me and it would have a passcode along side with a ID to get access to the channel.
Still, legally, not sure if that's allowed
User would agree to the Terms of Service making a agreement showing that they had given permission to store it.
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
Will do
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.
delete which message?
!d discord.on_reaction_add
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.
use await reaction.message.delete()
I added
yep
Ty it worked
What about button?
(Just curious)
!d discord.Interaction.message
The message that sent this interaction.
This is only available for InteractionType.component interactions.
interaction.message.delete()?
yes
Ty
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?
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.")
why do you want to run it every 10 seconds?
i dont want it to run like 0.1 secs
cause discord will ban it for spamming
so i want it to dm everyone slowly
so you want the for loop to send a message to all members, and wait 10 seconds in between each member?
yeah
just add await asyncio.sleep(10) before you call .send()
make sure you import asyncio
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.")
yes
Mass dms bots can be spotted by discord no matter the delay
ahh really?
I don't get the point of this, just ping everyone
2 bots are sending me dms every day
which bots also send to other 1.255 members
but they dont get banned
Can be banned any minute
how is it possible?
Just wait till someone cares to report
i dont think the bot dming all server members with a delay would cause an issue
^
its not considered spamming
Obviously depending on the amount of members. But i can see this being useful for certain things
i have 250 members
But why're you wanting to dm all members?
to like tell them to check announcements or something
Ehhhh
or to remember that my server exists
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
In what case would a user recieve a dm and report it as spam
unless you literally spammed their dms
Well you of course can create a mass dm bot just as you can create a selfbot, but this is not 100% safe
I feel like this is harmless unless he spams the command
i use it like 3 times a month
or less
Ask discord about this to be safe
in discord support?
Yes
link?
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
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.
so, await send_modal(MyModalsName)?
um
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)?
yes
Well thats not exacrtly\
you need instance to call a method
interaction instance you already get in button callback
so...?
!D discord.Interaction
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.
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?
well you dont know the current algo
This is the class you're technically referencing
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
how can i make a thing where when a user sends a message in a specific channel it turns it into an embed?
!d discord.Embed
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...
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**.
pass the embed in embed=
no
i mean
if a random member sends like a random message in a specific channel
that message turns into an embed
so the user's msg gets deleted and the bot sends the user's msg as an embed?
Track ๐

!d init
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
Did i need only the message ID?
u could try to simulate it
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
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
@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
u can use webhooks within ur bot?
y would u need that?
yeh
for this dude
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
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
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))
which if ur interested
here is the old algorithm implementation
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)
Nevermind i just had to refresh discord
BACK TO THE VOID
can interaction.follow up be used without webhooks too?
like if i want to make the bot interactive
like conversation handler or somethign
hm?
I suppose you have the message content intent enabled, if not it may be a smart idea to enable it 
Would be better to explain more than just "not working" e.g. up until where it doesn't work
if some one could help me on https://discord.com/channels/267624335836053506/1167857377811365958 it would be helpful
Got it. I tried to print while that was not possible that why i didnt see it. Stupid mistake. Thanks anyways for takiing a look!
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โ
my view doesn't stay persistent
Yes
Oh fr? Where can I find it in the docs?
The on_presence_update event is called whenver users change their status or activity. You can listen for this and use discord.Member.add_roles to add a role to the user as normal.
The reverse is also true - you'd still use on_presence_update to detect if a user changed their status to not include the terms you want, and then use discord.Member.remove_roles to remove the role from that member.
Thank you! Appreciate it a ton :)
Does anyone have an example where I can keep a button persistent with the message id or custom id?
!paste
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.
!source
Will the Python bot remove the DM if the ban is revoked?
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'```
looks like username is a string
wtf
also why you need /ban command when there is already one provided by discord
What could I call the DM generated by the bot that we insert into the database?
cuz custom command
also theres like no duration lol
Never understood the reason behind temp bans 
Either you ban them or not, if you don't you timeout them
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?
save the sent message id to db and then remove it?
What can we call the field in the database? Do you have any suggestion?
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()```
why dont you try
Why not just save the url with dm_message.jump_url?
To database and delete it
idk how you wanna delete message by having jump url but sure
Do you know if this is something done with the Python bot? @slate swan
i dont know
i you know that python bot has such system you can check its source code
!src
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
I want to delete the warn message/DM from the bot itself. So that when you remove the warning it should also delete the DM, if that makes any sense
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
Correct
What is the different between fetch_message and get_partial_message anyway?
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
Sorry, I mean to save the url for the DM and then delete it by using the URL instead of fetching the id
get_partial_message doesn't make an API request
It makes a sort of "fake message"
Useful if you want to edit a message with just an ID, for instance
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
When I revoke a case, such as a warning, I want the bot to remove the DM that was sent with the warning to the user. What do you recommend using for this purpose?
I refuse to believe ORMs can't bind Python callbacks to DELETE transactions
That seems like something very neat that they would support
It doesn't actually fill anything
These ids are the only thing it has, because they are enough to make requests like send, delete, ...
(For example, delete: /channels/{channel.id}/messages/{message.id})
And created_at can be calculated based on id it seems
That's the neat part: it doesn't
Is the ID stored in the database?
Not yet. But yeah that is the idea
Well, once you have the IDs you can use it to get a partial message and delete it
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
delete_original_message isn't a method on Interaction, you're probably after delete_original_response()
getting the error related with session what do i do
Whatโs the error
hello i need help few days ago i started to convert my code to cogs and i cant get my commands to sync
thats the main:
https://paste.pythondiscord.com/7RTQ
thats the cog aka ticket:
https://paste.pythondiscord.com/GCYA
i am not getting any error
def init(self): you meant to do def __init__(self):
does the print in the on_ready tell you how many commands were synced?
its in the code __init__
yes
tryed moving it to its own event but didnt worked
!paste
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.
it sent ques3, ques4 and ques5 at once without waiting for the reply. why did it happen?
on_message also triggers for your own bot message
That's why we have checks ๐ฅด
in the check you need to exclude your own bot's message so it doesnt trigger the wait_for

Or if the message was sent by the command executor
well tbf the channel is in a dm but i guess
Oh right
yea
i dont have much knowledge about interactions
should i try updating the check?
ok
changed it and now it gives me this error:
https://paste.pythondiscord.com/FLTA
You don't have Cogs directory, but you are trying to load file Cogs/ticket.py
@spark nimbus
Oh so the attributes channel and guild are partial too or something?
Yeah, it's in every Discord snowflake ID
Channel is partial (but can become a normal like TextChannel, not sure when tho), guild is just optional
Through discord.User.dm_channel or discord.Member.dm_channel it's probably complete, otherwise those properties return None instead of any channel object
how do i do it?
Do what? Just give a correct path to your extension
i dont really understand how to do it
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")
do you mean like: and cog list?
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
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)
doesn't work in what way?
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
doesnt load cog
oh i see
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')
welcome
wdym
How can I use get_partial_message to delete a DM?
what do you mean
@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
process_commands is only for on_message, by default, on_message process commands, but upon using bot.event specifically for on_message, it will override it, hence why you need to put it in there
also on_ready doesn't take any argument
you at the very least need to have DM channel ID to do that, if you have a dmchannel object, do await DMChannel.get_partial_message(message_id).delete(), but if you dont, use bot.get_partial_messageable with get_partial_message
@listen() is actually a preferred way, you can have several handlers for one event and you don't need to process commands
yes it so beautifl
Should I store both DM and Message ID for my warnings or is Message ID enough? What do you recommend?
Regarding moderation tools
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
So when I revoke warnings, bans, mutes etc it should delete the DM for the user as well
"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.
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
Do I need to fetch the channel ID?
channel = await client.fetch_channel(channel_id)
await channel.get_partial_message(message_id).delete()```
nop ```py
message = bot.get_partial_messageable(channel_id).get_partial_message(message_id)
!d discord.Client.get_partial_messageable
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.
Hmh, what am I doing wrong?
dm_message = await client.get_partial_messageable(channel_id).get_partial_message(message_id)
await dm_message.delete()```
eh my bad, idk why i put await there
the first line doesnt need await hehe
i do be getting kinda disoriented
dm_message = client.get_partial_messageable(channel_id).get_partial_message(message_id)
await dm_message.delete()```
`discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message`
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()```
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
(or just sent_message.channel.id)
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()```
the delete method yes
Thanks
nope, os.listdir doesnt go subdirectories, maybe you want glob.glob instead?
Could u show what category is
thats it
probably one of the overwrites a None obj
How to fix?
who knows about wavelink?
Someone in a ~400k member server likely does
Hi
i have problem, my bot don,t respond on my server but on private mesage respond
does anyone know why
!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.
I have all intents intents = discord.Intents.all()
problem is, where was overwrites defined?
Idk
that is literally your code lol
Show how youโre passing it into your bot constructor
Itโs your code. You should know where it is. If you donโt know, you can quite easily figure it out.
I Prolly deleted it
How should i define it
overwrites = ?
!d discord.Guild.create_text_channel
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...
View the docs
Yeah
overwrites = await create_text_channel(name, *, reason=None, category=None, news=False, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=..., ...")
```?
if i have overwrites, whats the problem?
i only have 1 instance
Share your entire error
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
How is channel defined
channel = await guild.create_text_channel(f"๐ธ{interaction.user.name}-donate-ticket", category=category, overwrites=overwrites)
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.
Ok
send me a dm
Which line is erroring
Imagine people caring that much about ๐ code 
Nobody is going to steal this guys code lmao
Itโs not unique
Itโs just a ticket system
check the error
File "/home/container/main", line 214, in my_callback
created_channels.append(channel.id)
^^^^^^^
oh im fucking dumb
The line the traceback is showing will not coincide with the line in the paste bin
i mean 214 in the ss
Considering we have a paste and not your code, give the line for the paste instead
i did
^
No you didnโt
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
didnt know
And there seem to be some inconsistency with the indentation overall
yes bc i like spaghetti
now help me
anyone that can help??
any bot makers
Yes, your code is just insanely difficult to read and follow
Nested functions, random naming, overwriting variables
#โ๏ฝhow-to-get-help, and don't ask to ask, If you have a question, just ask it
Most people in this channel are one, yes
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
hey @tropic burrow
so cant fix?
subclass it to different view
aint going to fix this repeatively recurring nested function
You can fix it, itโs just going to be 10x more difficult than just reworking your code
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")
Kk
You cannot get the hash of a user's profile picture without doing a request to the API
There is discord.id on the web, is it uses some bot account too?
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)
Whats so hard about it?
How long does it take for commands to sync when syncing tree to specific guild?
It varies
my bots only in one guild and it's kinda annoying having to wait for the commands to show up
How often are you syncing
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interactionWhat error is this?
@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
It's taking too long to respond to the interaction
TypeError: Interaction client is not derived from commands.Bot or commands.AutoShardedBot```
I'm trying to use `commands.Context.from_interaction`
You're using discord.Client instead of the commands.Bot alternative
but with slash commands I thought you have to use .Client?
how would I initialize it with Bot?
How would I sync then?
Using Bot.tree
oh alright tysm
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))
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
property tree```
The command tree responsible for handling the application commands in this bot.
New in version 2.0.
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
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
You're trying to edit the message that invoked the command, not the intial message that you sent
huh, Ohh yeah ctx.message sry
so, I'd just do blah.sync?
im dumb
No, blah.tree.sync
Assuming blah = commands.Bot(...)
does that sync globally?
If you don't give it a guild, yes
I though if you provide guild it'll sync automatically?
It'll sync to the guild you provided, you still have to call sync
hmm I don't see any slash commands still
If you're syncing to a guild, the commands should also be marked for that guild
and the deco would be @blah.command() still no?
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
Sure thing
does interaction.response.send_message reply to the original message?
Still fetch_user gives same info, not requires common guild, only some valid token
to the slash command invocation
anyway to make it just send instead of reply?

