#discord-bots
1 messages Β· Page 830 of 1
it's in int?
Right, on_ready() doesn't provide you with context, and unban() takes a snowflake
Anyway
!d discord.Guild.unban
await unban(user, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Unbans a user from the guild.
The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to do this.
refer to that for more information
You shouldn't be doing anything in on_ready. Discord has a tendency to disconnect you if you make requests in that event
it's supposed to be an integer, but I doubt if it's a string
@sick birch i have my member id and role id
Is there a code that will make the command works for bot owner only?
it does work though, not sure how it affects my bot.
whats the command to unban the member id when bot starts?
Is your bot in the server you're banned in?
@commands.is_owner() check on the command
Okay thank you
Did you read what I said?
This just seems wrong lol. If he was banned, it was prob for a reason
ye, i'll just keep doing that until the bot breaks lol
I redirected him to all the docs and explain cases π
But man directly needs the code to copy paste
exactly
π¦
None of us are going to give you the code to copy paste, so either find a different community that will, or read up on the docs and learn from what we're telling you
We dont spoonfeed here
This is relevant question....
i never used python my life and its a one time things why u sendimg me docs xd
also i noticed that get_user ends just there...
why can't you just wait ?
its just a quick help
You should then learn the basics
We arent a candy store that gives out code lol
bcs im worried of how i got ban?
So you code discord bot python just to unban yourself, and it's your first experience on python?
That doesn't change the fact that we're not going to give you code to copy and paste
Its just pycharm/your ide being slow
u dont wanna help me bascially
i came here to get the docs
I guess it would be better to witre support email to discord team
It is?
discord team are evven slower
No, just read #rules, no spoon feeding code
No, we dont want to give you the code. We want to help you learn it
we gave you the docs: https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.unban
I guess yes, because if bot does not exist in that server then how he could unban himself?
And we gave you the docs, so what's the issue?
Thats basically what we can do to help
man can u just accept friend req
it takes 2 mins ill leave u
Like I mentioned before I don't do dm help
damn
- Full stack Javascript developer
- Arch Linux user
- Helper at https://www.discord.gg/python
- Ping friendly, always available to help π
- DMs & friend requests closed, ping me to talk
I also don't want to be held liable for helping people potentially break TOS
Yes, what else do you want me to do? Spoonfeed you?
we would already finish 30 mins ago
@slate swanbro if you don't want to learn, just use the money you got from selling acc to get a custom bot on fiver or something
True
Man spittin fax
Yes we would've, if you took the 3 minutes it takes to read the documentation
With this he is excepting you to be a person learning python, not just finding a piece of code to unban yourself from a server
????
Probably too dumb to read the docs lol
Those 2 are events
exactly
You're not looking for that, you're looking for the coroutine that actually unbans the user
Do keep in mind the bot needs to have the sufficient permissions to do so
Thats an event, not a utility func
it has it
Learn python
Variables with spaces are not valid names
Var names cannot be separated by a space. You rlly should look into some tutorials
this i what i want to do XD
Oh my yeah this is really not going to work
If you want to copas only
see ??
Search on google
What is going on
Unless you wanna learn
i never opened python bro just lemme copy paste
πΏ
No lol
We will not spoonfeed you code. Period.
I cant π
ok well then advice me xd
We don't spoon feed in this server. It never helps anyone learn
I DONT WANAN LEARNNN
Learn python
!resources spend some time here. Best advice i can give
Totally wrong
whats correct command ?
buddy, everyone here is trying to help you... But, you must understand that people here can provide the context and references to solve the problem they can't write the whole script. And, also you mentioned that you never did programming right? Then it's impossible to read doc and create bots so, it would be ideal for you to wait for your friend. I can understand what you are going because the same incident did happen with me when one of my friends banned me...
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Then I'm afraid you've come to the wrong server. This server is meant to help for people who are interested in programming, not people who just want to be spoonfed code
its a command not a "whole script hack"
im interested in programming to get this shit fixed
Couldn't have put it better myself, if you're expecting to get spoonfed you're in the wrong place. Find another community that may do so
I'm not aware of any
Discord
Don't know of any. You should look around for an online forum. Those would probably be your best bet
Theres a reason we dont do that. You can pay people to do that, thatβs about it
Utilise bot.http if you are too rookie for doing objects
await bot.http.unban(your_id, server_id) inside an async function π
wat
This way you will might be muted here or mat be banned π¬
@slate swanayo it's working now, thanks... my ide was being slow lol
bro i told u again its just a one time thinig
Time and time again I've told you that does not change anything
I can understand but, if you never did programming you will be not able to understand what people are saying here
If you just want working code, the best way ik of is to hire someone to do it for you
Guys can we calm down with the threats? I understand that some of you don't like this person but keep in mind, we should still be respectful
Called us all useless B*** lol
Remove ()
Doesn't have ()
On @bot.event
Remove the brackets
Doesn't mean you should respond back in an aggressive manner
Yaa ya, i agree... I mean we don't hate him at all... We just trying calm down him he really seems to worried
Your bot is not in that guild then
Wait that's an actual thing?
The guild you got banned
Can I have the documentation?
The guild that contains the user to unban
Not tryna sound confrontational, but has anything i said come off as rude? Kinda curious now π
If your bot is not in the guild you want to unban yourself in you cannot do anything
it works without that
That's not documented
ah yes, VALORANT
How did you find it?
Yes, but your bot is not the guild so there's nothing you can do
Is it an internal method only?
Digging around the source code is something I recommend everyone to do, helps you learn things you didn't know before
I keep breaking into the source code often :)
guild is the server?
Yes, guild = server
it is in the server bro
Look it wors
How do u know if you were banned
I might do that tbh
The bot does, yeah
That part working doesn't mean anything, it's just your bot is not present in the ID you specified
Either its the wrong id or ur bot isnt there
This is exact question it was asked... I was also wondering if bot already exist in the sever that mean he knows python and if he never used both that means both does not exist which means no matter what he do bot will not work
Bots arent magic lol
Who knows if the bot was removed too
cause they claim the bot was in the servr
will recommend printing bot.guilds
Oh might possible
Well the API doesn't lie, you probably put in the wrong ID or are looking at something else
Why does that look so sketch lol
Not trading, selling
why dont u come dm and see proof?
In which case we should stop helping them
Idk whatever
πvalorant accounts market?
Since we would be violating rule 5
What ive been sayin lol
omg no
cause the bot name suggests that.
dont do that never will be my intention
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
Ima just back out of this
Oof
Why are you still trying...
@slate swan
@slate swan give this
Never your intention huh
Bot doesn't have permission to unban members!
Bot doesnt have perms looks like
Wha
Roles don't matter, permissions do
dude is the most sus person ive seen in awhile
Bro how is this guy not banned yet lol, he was banned from a server where u sell skins/accs it looks like
k lets try adding a role then ?
Seems like that
Would this break rule 5?
For sure
Yep
who still runs gen servers anymore π€£
<@&831776746206265384> Not sure if whats going on breaks rule 5 but I would rather be safe than sorry
by the way he is illicitly cracking/stealing valorant accounts and essentially selling them
Well
im asking how to add a role with python
No need to ping all mods, just mention a single person xd
Ye, so u can unban urself and sell more accs
who?
stop autoadvertise my server
u can get banned it break rules
809525714046418944
Also sent this lol #discord-bots message
yeah that i noted
!rule 6
would you mind DMing @novel apex please with whatever relevant information you have? i'm not finding anything obviously actionable here
Will do
i wanted to catch an error when the bot doesn't get a permission to certain channel, this is the error:
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
which except should i make? is it except discord.errors.Forbidden:?
He dm advertised to me
some"one" do it
you cant say yeah look at my bio and your bio is full of links of servers thats just like saying yeah open this door and the door is full of a room with advertisements
show code, also it won't do that in on_command_error event
Ok that was pretty easy
Damnn
your commit of the day and now your gonna be lazy like always?
impressive π
I guess I should support all 256 colors
very nice
andy complete Rewrite when
No I need to make it look pretty first!
The model rewrite?
Could we not just let user specify RGBA? π€ Just wondering
what are you waiting forπ
@slate swan
does it work?
That is true, you can use RGB for ANSI escape codes. I will be adding that anyways as I have planned
Great π
π
what does the http attr do and id is a built in an not an attr to the Member class
yessir, I tried using the model-rewrite branch
Seems like objects like message are yet to be done
http is some weird internal thing hikari&rin lover found
It's not documented
I have no ETA on when that will be finished π
wut you mean to make request?
Uses a bit of science and some black magic
Yup
Seems nice you can unban someone with just their id and server id
its to much to readπ
I don't know why thats not a public method
Seems illegal lol
And they don't care to document it either
Ive never seen it in action, so i question if ur just pulling our legs lol
Nah
what if you dont have legs
π³
@slate swan
hey man do i need server id here?
id is a built in still
variables can't have spaces
vars should be in snake_casing
Not english casing lel
lmaoooo
I'm not free enough just to mess around fooling others
https://github.com/Rapptz/discord.py/blob/master/discord/client.py#L220
discord/client.py line 220
self.http: HTTPClient = HTTPClient(connector, proxy=proxy, proxy_auth=proxy_auth, unsync_clock=unsync_clock, loop=self.loop)```
that looks clean
can u addrole with http.?
but who would read internals
π
But i am π
π³
I read that.
read what
What what
Lol
ποΈποΈ
Someone who changes them
Didnt read the second one sadly
π
wheres your commit thenποΈ ποΈ
...
I do that for personal use xd
π³
cause my code is never worth pushing
Basically I just shorten things
lolll
Into the wrapper itself
same
i read rin tho
not dpy
Someone better not say "my life" i swear-
idk what rin is, is it some kind of washing soap
I was reading rin's src , totally understandable
!pip rin
a discord api wrapper
So is chip gone?
Made by andy
The music bot?
Rin is made by andy?
Nah the weird guy selling the account thing
Yeaaaaaa
It seems as if so
we all love andy
Hopefully
They gave up
they didn't get banned
Andy should have helpers role whos with me? π
Rip I was gonna try to send them a video from the guy who taught me how to make a discord bot. Not sure if you guys watched Lucas but he got me started on discord bots
Any way I can see its source code?
Probll be back asking how to grab ips w python
I guess so
oh not him
lucasπ
fccπ
Same... But he was very very basic...
yes
He just got into the idea you can't actually make a bot by only watching his videos
Ofcourse it's public! https://github.com/an-dyy/Rin
yeah
Yeah but he had a tutorial on ban and unban
vco has the best tutorial imo and disnakes guide is great as well
Oh yikes that guy
That's 1 line thing... 3 at most
Watch it be stretched into a 10 min vid
@bot.command()
async def ban(ctx, member: discord.Member):
await member.ban()
worst i could do
the chip guy seemed a little confused so I figured Iβd send the video and heβd be on his way. That way we could avoid any interaction with him promoting sus activity
xD
kind of a problem when you just today discovered that you can "program computers to do something you want? what??"
tried my best to make it bad
@bot.command()
async def ban(ctx): await ctx.guild.get_member(637458038915203127).ban()```
bro
Why you want to make a command just to ban one guy xD
I'd love to see this being added to all bots!
10/10 feature
Cause the guy is okimii
#esoteric-python is a thing or better yet just dm meπ
can anyone
Insta ban the dude np matter what server hes in lol
teach meeeeeeeee
good one
discord.pyyyyyyyyyyyy
Vco can
π³
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
ty
jeezπ³
The context manager is actually useful for once
That's cool
Clears the past lines in the builder
def __enter__(self) -> ANSIBuilder:
return self
def __exit__(self, *_: Any) -> None:
self.clear()
It manages context
self.clear calls self.lines.clear()
thanku for losing 4hrs of my time btw
Oh thanks i knew it
Just wanted Oki to answer it
Kein Problem.
No need for that buddy
Let's keep it civil
only hikari tried to help for real
no bro i legit list 4hrs im sick and worried
lost
Β―_(γ)_/Β―
oh, so I assume you did something similar with the ActionRowBuilder too , to call the cache_all() function?
hikari should be moderator here
Yea basically, but for the rewrite I'll be getting rid of the context managers for action rows
probably idk
its like opening a door and it shuts itself
pog right
Context managers are pretty cool, I was looking at RoboDanny's source code and it used one for database connection, making and closing cursors I thought that was pretty ingenious
It's a no brainer to do context managers for database cursors
Same with file pointers
You wouldn't want to go into C and malloc 10000 bytes without freeing it later
Yah honestly after I saw that I got mine working and never went back to the old way whatever it was
that would be helpful for someone like me who doesn't like using withs often
I've seen user and member objects being resolved through a context manager, to add attributes from the database
It's very useful lol
agreed, easily one of my favourite features
yo bro did you saw what happend with victor?
you probably dont know who i am but i know victor
Not really something I'd discuss here, but yeah
yeah but you know right?
I think yes
he discussed it with you guys i suppose?
Yep, we had a talk before he left
thats great
Sounds like someone got laid
!ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
Hey you started it
Text inputs limit where I can implement them, but there's still potential
verification stuff, feedback idk
dang
Yeah, eh
Imagine if van rossum was here
whats the limit?
The limit of?
text
Well, a paragraph text input has a limit of 4000 characters
π
isnt that enough?
Great, discord seems to not support 255 colours
ποΈ π ποΈ
I can't make the rainbow method of ANSIBuilder truly colorful
No but like, having dropdowns and file attachments, and so on
Hm?
Tried it with javascript, it's actually not too bad
default is 2k for nitro users its 4k how is that not enough what are you writting 5 pages?
Lmao
They didn't have official support for it so I had to implement it myself, but regardless was pretty easy
Sort of, had to do most of it myself
Seems like some highly technical talks are going on here, I'mma just go
It's just a POST request
Yep yep
seems easy
but their on_interaction is much less sophisticated than ours, it doesn't pick up interactions it doesn't recognize, i.e MODAL_SUBMIT
They don't even support rgb ANSI colour codes
discord.py does actually pick it up if only to give you the raw data
lmao π
damn
damn for modals?
so unfortunately i was not able to listen to modal submits using d.js but i believe if you're implementing it using d.py you should be able to
that, context menus, and slash commands
dang
smh i had context managers on my mind
FREE DISCORD NITRO
enter your email id :
enter your password :
Below you will get an email asking to verify the login, authorise it.
For a sec I thought you were hacked 
nah it has a big yellow box saying to not enter sensitive info
authorise seems about right
doesnt seem fake
by meπ³π³π³π³π³

LOL
for reference
Have those been added?
seem nice still wont learn themπ
Indeed
yes
to the forks? don't know about that
modals
but it's an official thing yes
think they've all added them already
they're either on master or in release - disnake has them in 2.4
The modals? Disnake got it
Don't do discord bots much anymore so yall can be the judge of that
No idea about others
I remember the docs saying that required for a text input was false by default, and it was incorrect
devsnek got to it later
bro, what. Discord doesn't even support bright fore & background colours of the 8-16 colour codes
they dont? what
yea they only support the regular 8-16 colour codes
damn thats bad
Can you send the docs?
So that rainbow method from earlier is basically the best it gets colour wise
sad
https://guide.disnake.dev/interactions/modals shows how to use them
def run_id(id = ""):
Client = commands.Bot(command_prefix=".", help_command= None )
token = " "
@Client.event
async def on_ready():
#while not Client.is_closed():
command = Client.get_command("test")
await command()
#command = Client.get_command("bruh")
#await command()
#command = Client.get_command("wow")
#await command()
print("online")
@Client.command()
async def test(ctx):
await ctx.send("hello")
Client.run(token, bot = True)
run_id(id = "x")
run_id(id = "y")
The second function never runs cause the first one never closes. How do I fix this ? Any ideas ?
even more sad
!d disnake.ui.Modal
class disnake.ui.Modal(*, title, components, custom_id=..., timeout=600)```
Represents a UI Modal.
New in version 2.4.
I don't want to see how to use them. I want the actual docs
what is this
Thanks
Ah oka :P
Okay thats interesting
lowercase client pls
That's really cool
thats what im saying
Your can't fix that, Client.run is blocking
giving me a stroke
Okimii want to make a discord bot project
fr
I want to create one but if I do it myself its boring
im making a bot for a server if yall wanna help lol
do i know you
All these new interactions are cool as hell
Yeah
its disnake
can I use anything else except Client.run
That's what I use
I don't know tbh
but i don't rlly plan on it being open source.. if i have collaborators though i must make it open source though
im doing akenos canary if you want to contribute
π
Can you make a private github repo and sort of add people to it?
You could just make a private repo and add collaborators :P
oh ye im stupid
yes, see you here#939303161380888581
ye
so yall interested? i barely started it today
I'll contribute to both
lol
I'm getting a bit bored of Akeno
its going to be a general purpose bot that covers shit like moderation, automod, reaction roles, verification, config, etc
cause you cant make objs?
but only for one server π

#python-discussion is a thing
That makes it a lot easier
Looks good enuff to push
I will tmr
Totally steal-able code
what
why are colors all caps
Yea you could steal it, you don't need to use rin specifically to use it
Enum convention
@slim ibex Send me a msg so I don't forget
bro
explain
It's 11
idcπ
Enums are constant so meant to be all CAPS
Okay bye
mhm
byeπ
glad but also sad that it's only the 8-16 colors
Glad I don't need to add shit ass many colours
Sad I don't get cool colours
Sup awesome people
Yo
Can someone explain to me the advantages of subclassing the bot constructor than doing it the conventional way?
maybe adding more arguments and methods
You can add extra things to the bot in an easier manner
Otherwise you'd be shadowing the objects attributes/methods
define your own methods in the class and customize stuff
yup
Still don't understand but I guess I should do it
broπ
class Bot(InteractionBot):
def __init__(self, **options) -> None:
intents = Intents.all()
super().__init__(**options, intents=intents)
# noinspection SpellCheckingInspection
@staticmethod
async def _connect_to_db() -> None:
async with connect(r"...") as db:
BUILD_PATH = r"..."
if os.path.exists(BUILD_PATH):
with open(BUILD_PATH, "r") as f:
await db.executescript(f.read())
await db.commit()
async def on_ready(self) -> None:
await self._connect_to_db()
log.info("Successfully established database connection.")
log.info(f"Ready: {self.user} (ID: {self.user.id})")
def load_cogs(self) -> None:
for filename in os.listdir("./src/cogs"):
if filename.endswith(".py"):
self.load_extension(f"cogs.{filename[:-3]}")
log.info(f"Loaded cog: {filename[:-3]}")
this is why subclassing good. i wouldn't be able to establish database connections or load cogs without having to do it in a procedural way with tons of lines of unorganized code
You could've just overwritten the bot's connect method and add your db connection impl there
Lol
class Foo(commands.Bot):
async def connect(self) -> None:
... # db stuff here
ooo forgot about that
And this makes it so it only connects once a life-time
Rather than doing it on_ready
oh shjit thanks
intents = Intents.all() why
Imagine forgetting to call super().connect()
should i specify the specific intents?
It was mostly pseudocode!
no but why make a var
true
def __init__(self, **options) -> None:
super().__init__(**options, intents=Intents.all())
yes
async def connect(self) -> None:
async with connect(r"...") as db:
BUILD_PATH = r"..."
if os.path.exists(BUILD_PATH):
with open(BUILD_PATH, "r") as f:
await db.executescript(f.read())
await db.commit()
await super().connect()
@pliant gulch ?
Are questions related to self_bot are forbidden ?
Yes
yes
pogg
LGTM
Is the file you're reading your schema.sql?
Lmao
it reads the sql file and executes it, then commits it to the db
Something to note though, connect takes 1 arg reconnect but technically you don't need to change anything as by default it's set to true
ye ik that
i cna also load cogs in the connect method right?
instead of making a separate method and calling it in on_ready
There isn't a point to do it in connect I don't think you're not running any coroutines so
You can just add it to bot.run()
oh ok
Same way with how you overwritten connect
ye ive done that before
if reset_after is not False:
?????????
Andy procrastinating -> Hunter going on a Hunt for someone
What about it
If you don't add a reset code your colours will mishmosh
dont tell me you want him to use if not reset_after it's bad.
why not True?
Idk you could do is True as well
then why add is not False
I guess I randomly wrote it like that for some reason
I cba to commit again tonight π
esoteric
I could've made the builder esoteric
rin/models/builders/ansi.py line 48
the forground color code, and the second being the background color code.```
Probably could've used @type.__call__
Heres your chance for a free PR sarthak!
π³ sure
how can i require either a specified role or a permission for a cmd?
use the commands.has_role check
actually imma check other stuff too
@commands.has_any_role(roleID)
@commands.has_permissions(administrator=True)
i tried this
is roleID a variable?
yes
It won't work like that, decorators run at runtime
Unless you set roleID right away it won't work
and it will first check if the user has admin perms
i do
You should show your roleID definition
roleID = 926477597423067178
snake_case should be used for variable and function names
Where is this set? Just module level or
roleID = 926477597423067178
@client.command()
@commands.has_any_role(roleID)
@commands.has_permissions(administrator=True)
litterly there
also, when i run it requires the role, it doesnt work if you have admin perms
At that point you'd just pass the int itself right?
If the variable is literally right above it
???
TypeError: Bot.connect() got an unexpected keyword argument 'reconnect'
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000002CD6BAEE830>
Traceback (most recent call last):
File "C:\Users\binds\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Users\binds\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\binds\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 745, in call_soon
self._check_closed()
File "C:\Users\binds\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 510, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
πΏ
async def connect(self) -> None:
async with connect(r"...") as db:
BUILD_PATH = r"..."
if os.path.exists(BUILD_PATH):
with open(BUILD_PATH, "r") as f:
await db.executescript(f.read())
await db.commit()
await super().connect()
same function
why do you have that check there?
cuz idk where else to put it... and thats why im here -_-
Add reconect to the method parameters
can you guys just tell me how i can get the user's permissions? or check if a user has a sertain permission?
what? you dont know what you want to do?
i mean even someone who does not know a single programming langauge may understand what has_permissions(administrator=True) would mean
bro ik what it means
!d discord.Member.guild_permissions
property guild_permissions: discord.permissions.Permissions```
Returns the memberβs guild permissions.
This only takes into consideration the guild permissions and not most of the implied permissions or any of the channel permission overwrites. For 100% accurate permission calculation, please use [`abc.GuildChannel.permissions_for()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel.permissions_for "discord.abc.GuildChannel.permissions_for").
This does take into consideration guild ownership and the administrator implication.
oh ok
THANK YOU, now goodbye
quite a coincidence that the method is named connect when i also use another method inside that connect method named connect to connect to my db
anyways thanks for help @pliant gulch ily. gonna head to bed
tell me when i can make the first big Rin bot
π³
Andy got fans π
!d discord.on_member_ban
discord.on_member_ban(guild, user)```
Called when user gets banned from a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.bans`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.bans "discord.Intents.bans") to be enabled.
Hmm
Cool!
Cool! Are you willing to share the code you are most proud of?
yes , but I am not too familiar with GitHub and what not but once I'm finished sure !
I just learned how to use cogs today
Nice
Ah cogs, remember when I learned about them I thought they were insanely cool
indeed
Progress is real 
I started with cogs when I didn't know what are classes
haha real
Yikes, how'd you do it?
I still don't know what a class is
I remember being ecstatic with discord.py now looking back I'm kind of just dissapointed
At what aspect of it are you dissapointed in?
Idk, overall mostly everything
Don't ask tbh haha
It was a hell of a journey. Copy pasting without understanding anything
Just not the wrapper for me
I assume that's why you're working on your own?
Yea
I memorized most of the syntax can barely understand classes π
I think I've found my true interest with python. Working with APIs and analyzing data
The only reason Andy works alone is so that no one can tell him to push stuff today or smth. He likes procrastinating, yk
also cause I got like real bad coding OCD
I understand you. It took me like 2 months to understand those
Ouch
Black mostly solves it though
Just follow pep8 and y'all will have the same style
π but then the semantics
Hahahaha
To follow PEP 8 or to not follow PEP 8
Probably why I've done atleast 5 or 6 rewrites on rin
BTW
I think okimii doesn't like my obsession with pep8. I made a commit just to fix the import order of a file
Probably 1 or 2
But I'll make sure to make those two hate me, for the amount of rewrites I will be doing
Only slightly joking
Ok i have 2 different bots in the same folder how do i make one reference a .env file in another folder in the folder that the starting file is in.
I use this py load_dotenv() TOKEN = os.getenv('DISCORD_TOKEN') GUILD = os.getenv('DISCORD_GUILD') intents = discord.Intents.default() intents.members = True
Good thing I don't use rin. I hate making changes to the bot code
π³ i use rin to find mistakes/bugs innit
can someone help with my question? or no clue
environments are folder/workspace based, you cannot just import them..
from what i know
Writing your own wrapper is acutally really cool, though I don't like to do it in Python, really good learning experience regardless
or use a system variable which works globally on your system
@sick birch any good resources on that
well how about absolute path?
Rin will probably never see v1.0.0, we gonna be perpetually stuck at v0.1.12394 or something
On writing your own wrapper? Doesn't seem to be common knowledge, I had some trouble finding people to help me out but the discord docs are honestly the best for it
Iβd love to right a wrapper to some c++ functionality for image processing
I want to attempt smth. Wanna help me?
v0.1.69420
Write a wrapper?
πΌ
I actually mean in general iβve never written my own python wrappers
In binary π₯Ί
I'll warn you I'm only good with the connecting and API part, not with the classes and objects and whatnot π
i'll pass
π€£
Ah nevermind
Oh yea connecting to the API is easiest part
Facts
Models and whatnot are so tedious to add
though anyone who writes a discord library in binary would acquire godlike powers
explains why i never went farther than that π
You'd spend 5 years a lone writing the websockets in binary
Then you'd spend another 10 years making it work
I wrote a pyscript for a motion system and camera for work and rewrote it in c++ for performance boost on the image processing
Lmaooo
Python also integrates nicely with c++ c, rust etc since they have a C api
One of the optimizations i had looked into before just calling the rehaul bad been writing a wrapper for the c++ code to do the processing
You could've written bindings for it in c++ code keeping some parts python, good learning expirence
Makes sense that the processor would be c++ code though
Yeah what iβm looking for im young not a year out of college
I learned on the job how slow python can be comparitively
But god is it a beautiful language to use
Sounds like the python curse
Does anyone have a good example to follow of a python discord bot on github for project / file structure?
RoboDanny
Created by the same person who made discord.py, so i trust it
Python's syntax is so unique, it's clean. But python is also slow π
I don't know about the syntax, personally I prefer typescript in terms of syntax
If python is your first lang and you get really used to it, I'd def say it impacts your learning
I looked into cython as an optimization and trying to implement it just seemed to be a pain
Prefer rust and c++ syntax
Will check out the repo, thanks
Javascript syntax is ok, but the conventions are weird
I still need to actually try numba that didnt seem too bad to implement
2 space indentation isn't very good

for speed? i heard rust is a contender for very fast applications
My first language was java in hs
apparently they're making operating systems with it
Then c -> c++ -> python in college
int main() {
void *foo = malloc(9000000000000);
return 0;
}
``` π³
Rust i can believe is getting os applications
I mean theres gotta be a good reason all of solana is either in rust or c
I have only worked minimally with rust so far
And a lot of it was being abstracted away by anchor
I will have to take your word for it at the moment
But thats good to hear my interests in writing solana contracts wont be leading me down the dark path
@client.event()
async def on_message_delete(message):
embed=discord.Embed(title="{} deleted a message".format(message.member.name),
description="", color="Blue")
embed.add_field(name= message.content ,value="This is the message that he has deleted", inline=True)
channel=client.get_channel(937566314522902538)
await channel.send(channel, embed=embed)
Trying to make my bot be able to log events
I started with this but I'm getting this error and I'm not sure what to do.
I'm stupid... Thanks
Still a problem. I deleted a message and it didn't put the deleted message in my logs channel
Okay
await channel.send(embed=embed)
I made it this and now I'm getting this error
File "c:\Users\13129\Desktop\Python Bot\Sloth.py", line 57, in on_message_delete
embed=discord.Embed(title="{} deleted a message".format(message.member.name),
AttributeError: 'Message' object has no attribute 'member'
message.author
this? format(message.member.name) to this? format(message.author)
same thing when i try do this
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
oh
also remove description="" since its empty anyways
how can i make a discord.py code doing βif messages are in this channel, react with βπββ
on_message
if message.channel = channel
message.add_reaction(emoji)
oh
ty
is the channel part suppose to be the channel id or channel name?
channel object
yep
so any of them?
class discord.TextChannel```
Represents a Discord guild text channel.
x == y Checks if two channels are equal.
x != y Checks if two channels are not equal.
hash(x) Returns the channelβs hash.
str(x) Returns the channelβs name.
The cog class needs to inherit from commands.Cog
an instance of this
k lemme checkk
@quick gust
I can kiss you 
Now Iβm going to do the same things for all the other eventa
π
in {message.channel.name}
u can also do {message.channel} only
channel = bot.get_channel(channel_id)
now u can just do this
:P
u know how do get user id?
@quick gust 
message.created_at?
if image is None:
image = discord.File(f"data/images/{species.id}.png", filename="pokemon.png")
embed.set_image(url="attachment://pokemon.png")
``` wdym by this
Oh it's the delete time
his png database is like a image without background but new updates bot makes the image spawn with a merged background at back :|
@maiden fable Do you know how to actually do that in code format? Also do I have to import anything?
how can i make a discord.py code doing βif messages are in this channel, react with βπββ
or @quick gust lol
event doesnt need ()
and its in a cog there isnt events
its
@commands.Cog.listener()
datetime.datetime.utcnow() or something i don't remember
and u need to import datetime
yeh
you're not gonna get spoonfed, I already told u the concept
since its a method from that
code:py @bot.listen() async def on_message(msg): if 'wfl' in msg.content: await msg.add_reaction('\U0001f1fc') await msg.add_reaction('\U0001f1eb') await msg.add_reaction('\U0001f1f1') for word in filtered_words: if word in msg.content: await msg.delete() if message.channel = 943049242174427206 message.add_reaction(π)error:
if message.channel = 943049242174427206
^
SyntaxError: invalid syntax```
not the valid operator
and wut comparing a channel obj to an int?
And what if I do
from datetime import datetime
datetime = None
what should i do instead?
!resources = is for assigning == is for comparing
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
= is used for assigning vars you should compare the id of the channel which is a snowflake and compare it to the given int since a channel obj wouldnt return an int
From when u know this much about the API π
from youπ
well channel has an id attr no?
you can compare the name or the id it doesnt matter
@bot.listen()
async def on_message(msg):
if 'wfl' in msg.content:
await msg.add_reaction('\U0001f1fc')
await msg.add_reaction('\U0001f1eb')
await msg.add_reaction('\U0001f1f1')
for word in filtered_words:
if word in msg.content:
await msg.delete()
if message.channel == 943049242174427206
message.add_reaction(π)``` this instead?
u forgot the f
o
wdym? @slate swan
^^^^
the name is more limited like a title whats the useless var for
no.
could u give me an example on what to put instead
- forgot a colon
- use regex
- where are you pulling channel from if message is not defined
- add reaction is a coro
- param naming
So, if you're talking about the time var what should I do instead?
you sure it's in ms? or in seconds? you might want to multiply it by 1000 for ms?
isnt default in ms
?
nope
nano?
probably not lmao
bro
!d discord.ext.commands.Bot.latency
property latency: float```
Measures latency between a HEARTBEAT and a HEARTBEAT\_ACK in seconds.
This could be referred to as the Discord WebSocket protocol latency.
no idea lol
tbh no idea
Idk this much
or do you?
?
Idk what's a snowflake no cap
nice eval cmd
random sequence of ints
eval(expression[, globals[, locals]])```
The arguments are a string and optional globals and locals. If provided, *globals* must be a dictionary. If provided, *locals* can be any mapping object.
like a snowflake which is always unique
Who tf says that
i do

Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
in binary jeez
So its showing this when a message is deleted:
HOw do I get it to display like carl bot lol
Use the timestamp kwarg
ah so its a femtosecond just multiply it for a second
!d discord.Embed.timestamp
The timestamp of the embed content. This is an aware datetime. If a naive datetime is passed, it is converted to an aware datetime with the local timezone.
maths hard
Just multiply it by 1000 smh
Your wish
So how do I do that?
Multiplying by 1000 returns the ms
one quadrillionth of a second. is a femtosecond
Embed(timestamp=datetime.utcnow())
UTCnow()
Never denied that
still wrong? since a millisecond multiplied by 1000 makes it a second
I have that?
It shows this
I want it to show something like this
But I have no clue where to change t
Would I put it in the footer where {timestamp} is?
Dude nvm I pass it
So what do I do to get it to display the local time
mathπ
of when it happened
Technically microseconds but sure
use the timestamp kwarg in the embed class constructor
no?
A millisecond multiplied by a thousand converts it to microseconds
oki, why u ain't listening to anyone rn
ugh i hate math
Then just ignore that thing
Yes, a second multiplied by a thousand is a thousand milliseconds
Milli is a thousandth, micro is a millionth
huh
my brain is having a stroke lets change topic pleaseπ
okay but where do I actually get it to display?
no inside the constructor
There is set_timestamp
timestamp=datetime.utcnow()
Or do that
but the timestamp kwarg takes all the footer
the kwarg makes it so that it shows it like this 12:13 AM
instead of including everything else
yeah
okay
if you want text then use footer
I'm so confused on what I'm putting in the footer to make it look like 12:15 AM
like where do I look?
you mean a timestamps format
