#discord-bots
1 messages ยท Page 948 of 1
no it stops executing it
Okay. It's just ignoring it so the process isnt ended?
Is an mute command hard to make
No
!e
def a():
print("lol")
raise KeyError
print("lol")
a()
@slate swan :x: Your eval job has completed with return code 1.
001 | lol
002 | Traceback (most recent call last):
003 | File "<string>", line 5, in <module>
004 | File "<string>", line 3, in a
005 | KeyError
Can you help?
only printed the first string
Okay, just doesn't stop the entire process, which is why it says ignoring?
@slim ibex help make an mute and unmute command?
Create a role that has no perms to talk in any chat. Give that role to the muted user
@slim ibex stops executing since python is an interpreted lan right? just to confirm i assume yes
but if you use a try except, you can execute code if an error wasnโt raised, or regardless of the result of try or except
or you can just use on_command_error to eat all the errors
@cold stag most code
none you shouldnt copy paste code lol
!e
try:
print(2/0)
except ZeroDivisionError:
print("error")
else:
print("error didnโt occur")
finally:
print("I donโt care about try or except")
lol
@slim ibex :white_check_mark: Your eval job has completed with return code 0.
001 | error
002 | I donโt care about try or except
forgor a quotation ๐
Yeah, so that catches them and won't stop the process
How would i start a @tasks.loop from a cog
finally allows you to execute code regardless of the result of try and except. else runs if there wasnโt an error
finnally is good if youre not gonna use context managers
yeah you can close the file object with that
Moai how to make the mute command?
What would the difference be from putting finally and just putting code after that block
I get this <cogs.testmusic.Song object at 0x0000016F5B311EE0> instead of actually getting my embed
try:
print(2/0)
except ZeroDivisionError:
print("error")
else:
print("error didnโt occur")
print("I donโt care about try or except")
Like this?
Rustโs way is better (this is reading a file)
let contents = fs::read_to_string(config.filename)?;
i love getting ignored
same thing happens
youre sending the embed just use the kwarg
@slate swan
what
look at message
??
Would finally run it's code even if a different error was caught? Whereas the code after wouldn't?
smh
!e print(str)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
<class 'str'>
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
await ctx.send(embed=your_embed)
so funny do it again
Binary guy
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

<@&831776746206265384>
Bro stop
!silence
โ silenced current channel for 10 minute(s).
!mute 864611146740924437 spamming 1s
:incoming_envelope: :ok_hand: applied mute to @soft flame until <t:1648852845:f> (59 minutes and 59 seconds).
!unsilence
โ unsilenced current channel.
thanks!
๐
But it has to get the embed from my class
๐
i thought the spam filter was gonna catch him๐ก
guess lx did 
the syntax
Btw how to make good spam filter
Yeah. I guess it just didn't come within one of the rules that triggers the filters.
Without AI
use regex
this before that guy started spamming 1s
I need help making an mute/unmute command can anyone help me?
Which is quite on-topic for this channel actually 
How would that help
what syntax? The fs::read_to_string?
correct
weird it shouldve gotten triggered by the new line rule
all of it
do the filters catch the same character repeated? or just different messages
cool thanks
the funny thing is ? does all of it
It needs to go up to the class and get the embed nor can I use CTX because I'm using interactions
Nah, it was all on one line, per message: https://paste.pythondiscord.com/qepiqicocu
!source
Yeah, so to catch that, would you just have to catch repeated characters?
regex is used for searching patterns which regex means regular expressions
await interaction.send() then
right right its just continues on the next line. thats weird discord really doesnt count it as a new line after a limit of variables?
learn regex or stack
but what is your class/embed looking like?
^
I'm aware I have that but that still does not get the fact that it's not getting the embed and it's just getting a bunch of random stuff also I'm pretty sure interaction.send is not a thing
i ment its ways lol
I literally can't imagine the spam pattern
so all the symbols
!d disnake.Interaction.send
await send(content=None, *, embed=..., embeds=..., file=..., files=..., allowed_mentions=..., view=..., components=..., tts=False, ephemeral=False, delete_after=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message using either [`response.send_message`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionResponse.send_message "disnake.InteractionResponse.send_message") or [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send").
If the interaction hasnโt been responded to yet, this method will call [`response.send_message`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionResponse.send_message "disnake.InteractionResponse.send_message"). Otherwise, it will call [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send").
Note
This method does not return a [`Message`](https://docs.disnake.dev/en/latest/api.html#disnake.Message "disnake.Message") object. If you need a message object, use [`original_message()`](https://docs.disnake.dev/en/latest/api.html#disnake.Interaction.original_message "disnake.Interaction.original_message") to fetch it, or use [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send") directly instead of this method if youโre sending a followup message.
๐
Oh cool. Actually so cool to see the official bot for this, I like seeing how official bots are set up.
r"\d{69+}"```
@tasks.loop(hours=24)
async def changedaily(self):
print("Dailystart")
self.rnd = random.randrange(0, 201, 1)
This is inside a cog btw, how would i start it? Is there a function that loads up when a cog gets loaded in or something?
Cause I'm still learning, so it's neat to see that maybe I could put all my decorators in one file like this bot does
I forgor one side limit
To be honest, heuristics can work well enough.
Since i cant really start it through main because of the "self"
self.your_loop.start() in __init__
so this??? py song = Song(source) await interaction.send(song) await interaction.response.send_message(embed=discord.Embed( title="Added to queue", description='Enqueued {}'.format(str(source)), color=0x02020 ))
mhm ic
why are you using format?
I would also add a cog_unload method and cancel the task there also
It is on the discordpy docs so why not
and is your code formatted in 9001 ๐
Turns out it's easier to create antispam AI or smth
Ive literally done this and it didnt work and now it works
That's not the point
sometimes i believe magic is real
Actually, that rule is kind of the bane of mods' existances. It gets triggered at least a few times per day by people just pasting large code-blocks into messages.
It still doesn't help me on why I can't get the first set of embed to work
damn cant you just check if theirs keywords that python uses or maybe the codeblock end and start prefixes?
like with regex
or will it be hard?
Although that wouldn't catch some cases of legitimate spammy messages.
bro the error says it all? youre sending the object
People have in the past posted long empty code-blocks as a trolling tactic.
yeah people would just use the code block but thats why im saying cant you just search for something pythonic?
I'm sorry that I'm struggling and I can't figure it out I am honestly trying to fix it
you have to send it with the kwarg
del_msg_user= await client.fetch_user(int(message.author.id))
returns:<coroutine object Client.fetch_user at 0x7ffb24015e40> when i delete a message anyone know why this happens?
await interaction.send("song") so this??
That would send back the word song, because it's sending a string
what is that๐
I got an idea
๐๐๐
@slash.slash(name="Pickups", description= 'Host a pickup')
@has_any_role ('Franchise Owner', 'General Manger', 'Head Coach', 'Pickup Captain')
async def Pickups(ctx):
embed = discord.Embed(
title = 'Title',
description = 'A pickup is being hosted!',
colour = discord.Colour.orange()
)
embed.set_image(url='<img src="https://tr.rbxcdn.com/7c4c32d6e3671dff15f512f089fe94d8/768/432/Image/Png" alt="Football Fusion 2 - Roblox"/>')
embed.add_field(name='Field Name', value='Field Value', inline=True
)
embed.add_field(name='Field Name', value='Field Value', inline=True)
embed.add_field(name='Field Name', value='Field Value', inline=True)
await ctx.send(embed=embed)```
?
i busted out laughing ๐
!d discord.Client.fetch_user
Amount of unique words, amount of unique characters, amount of words and amount of characters combined to train an AI model
For the antispam
Cant pass ctx in slash command
o
Ok ig ima do that tomorrow
what are you trying to do delete the user or something?
Except when you don't use dpy 2.0
well ultimately you cant tell what their intentions are, and the more leeway you give the more exploitable it is, so its either that or having a mod to sign off false positives
yeah it would be very hard
u busted out laughing because you misunderstood the name of a variable?
nah thats not why๐
Man I still can't get this to work and I've got it just like the old version I had before I started integrating the new version of discord.py
then?
my point is what the heck are you even trying to do? delete a user with the del keyword or something?
๐
binds with his moments
I was trying to replicate the memory address
ah
del_msg_user is for the username of a user that has deleted a message
no
clearly your variable doesnt show that
well yes
youre trying to delete an object
Not sure how to replicate the memory address
wait nvm i thought you tried del user_obj ๐
lmao
that little underscore i didnt saw lmfao
๐ฆฅ
well are you trying to print the object?
still odd that you got a coroutine, can you show the rest of the code?
yeah
one sec
having a binds moment right now leave me alone
what does a "binds moment" consist of
!e print(id(str))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
140237910890528
theirs the memory loc
async def on_message_delete(message): if message.author.id != client.user.id channel2 = client.get_channel(id) del_msg_user= await client.fetch_user(int(message.author.id)) await channel2.send("User:@"+str(del_msg_user)+ " Deleted Message: "+message.content)
awaiting a coroutine outside of a coroutine
oh hold up
true tbh
I think Python is starting to drift from my brain
how can i "import" declarations from a function for example:
async def test():
test = "hello"
print(test)
You can import in functions, yes
what do you mean?
what
why do you need to fetch the user though? the message.author is already a user, so you could get the mention text for them with message.author.mention
you can use the import keyword inside of a function
oh god
!e
def foo():
import __hello__
foo()
@slim ibex :white_check_mark: Your eval job has completed with return code 0.
Hello world!
it wouldnt matter as keywords have their own functions
im dumb lol
so when i defined something in a function i want to use it outside of the function
^ @slate swan
you can use global or just return the value
you only import in functions if you need something locally
i didnt meant that
okay
you said import declarations 
yeah i didnt know how to say this question
just return it, as okimii said
@slate swan :white_check_mark: Your eval job has completed with return code 0.
Hello World!
lmao
you didnt saw that
What he do
nothing
cap
no cap
prolly forgot to call the function
that would be very funny
yes i would love to see you cry
petition to replace Robin with me
nah youre bad
๐
trying to call a coro outside of a coro๐
my fault man
happens
sorry that I donโt use Python anymore sir
you traitor
replace robin with me im loyal to python unlike robin who uses js
JS ๐
ikr smh
bloated language
lmao
ur running the skull emoji into the ground ๐ญ
where do you put skulls?
the ground
๐ฆ

how do i change my bots name and pfp using code? (like how can i do it without the discord developers website)
!d discord.ClientUser.edit iirc
await edit(*, username=..., avatar=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the current profile of the client.
Note
To upload an avatar, a [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object "(in Python v3.10)") must be passed in that represents the image being uploaded. If this is done through a file then the file must be opened via `open('some_filename', 'rb')` and the [bytes-like object](https://docs.python.org/3/glossary.html#term-bytes-like-object "(in Python v3.10)") is given through the use of `fp.read()`.
The only image formats supported for uploading is JPEG and PNG.
Changed in version 2.0: The edit is no longer in-place, instead the newly edited client user is returned...
is there any easy way to convert a image to bytes?
If this is done through a file then the file must be opened via open('some_filename', 'rb') and the bytes-like object is given through the use of fp.read().
i want to make it use a servers icon has the avatar
so the avatar url?
? I don't understand what you mean by this
!d discord.Asset.read
await read()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves the content of this asset as a [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "(in Python v3.10)") object.
!d discord.Guild.icon
property icon```
Returns the guildโs icon asset, if available.
ty
Hello, does anyone here know how to test if a received file attachment is encoded in utf8? Thanks
anyone know the unicode for the ๐๏ธ or Pythons trashcan emoji? I'm trying to add it to a message like thispy async def wait_for_deletion( self, message: Message, user_ids: Sequence[int], deletion_emoji: Sequence[str] = ":wastebasket:", timeout: float = 60 * 5, attach_emojis: bool = True, allow_mods: bool = True, )but I'm evidently not doing it right as I get this error
File "C:\Users\Teagan\Documents\Coding\Zupie\env\lib\site-packages\discord\client.py", line 373, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Teagan\Documents\Coding\Zupie\bot\cogs\code_snippets.py", line 366, in on_message
await self.send_snippet(message)
File "C:\Users\Teagan\Documents\Coding\Zupie\bot\cogs\code_snippets.py", line 360, in send_snippet
await self.wait_for_deletion(
File "C:\Users\Teagan\Documents\Coding\Zupie\bot\cogs\code_snippets.py", line 110, in wait_for_deletion
await message.add_reaction(deletion_emoji)
File "C:\Users\Teagan\Documents\Coding\Zupie\env\lib\site-packages\discord\message.py", line 1505, in add_reaction
await self._state.http.add_reaction(self.channel.id, self.id, emoji)
File "C:\Users\Teagan\Documents\Coding\Zupie\env\lib\site-packages\discord\http.py", line 501, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 10014): Unknown Emoji```
that's the vaguest thing i've ever heard anyone say. it could literally be anything
how would that help
you could just copy and paste it into your strings
Anyone?
you mean into thispy await message.add_reaction(deletion_emoji)I don't want to do that as I want to declare it once for any new funcs to also use nice and easily. and if you mean do\:wastebasket:in chat to get the emoji, I have done, that's how I got that string
if it's a default emoji you should be able to copy and paste right into code
๐๏ธ
Send it here
oh thanks, don't really know why :wastebasket: wouldn't work but heyo, now about that :trashcan: emoji @unkempt canyon uses, do you know how I can add that one as it's not a defualt emoji but I can't find it in this servers emojis
U ran ur bot inside a command
To run the bot, u would need to run the command, but to run a command, the bot must be running, which it can't do because you would need to activate the bot first
An easy fix though, I'm gonna give you some time to find it
You're welcome!๐
name is a kwarg
His issue was that his bot didn't run
I just told him the solution to that
look a the kwarg
its clearly raising the error since he isnt calling the kwarg right
@commands.Cog.listener()
async def on_guild_update(self, before, after):
icon = after.icon.read()
await self.client.user.edit(avatar=icon)
so this is what i have, and i get this error
which he needs the assigning operator
True, but take a look at his bot.run
.read is a coroutine
ty
yes but the error isnt related to it

I never saw an error, he just told me it didn't run
Probably accidentally typed something at the start
^
The full error
!trace
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
Traceback most recent call last
show code
Thank you so much
bro
^
Anyways, ur bot.run is still placed incorrect
Any commands below bot.run wont be working
!kw
*args and **kwargs
These special parameters allow functions to take arbitrary amounts of positional and keyword arguments. The names args and kwargs are purely convention, and could be named any other valid variable name. The special functionality comes from the single and double asterisks (*). If both are used in a function signature, *args must appear before **kwargs.
Single asterisk
*args will ingest an arbitrary amount of positional arguments, and store it in a tuple. If there are parameters after *args in the parameter list with no default value, they will become required keyword arguments by default.
Double asterisk
**kwargs will ingest an arbitrary amount of keyword arguments, and store it in a dictionary. There can be no additional parameters after **kwargs in the parameter list.
Use cases
โข Decorators (see !tags decorators)
โข Inheritance (overriding methods)
โข Future proofing (in the case of the first two bullet points, if the parameters change, your code won't break)
โข Flexibility (writing functions that behave like dict() or print())
See !tags positional-keyword for information about positional and keyword arguments
Yeah
or nothing will execute until the loop is closed
did you actually read all the info?
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
bro you arent even reading it
its impossible to read that fast, you would understand if you actually read it fully and not the first sentence
bro you read the whole page in a minute ofc you wont get it if you dont even try to read it and learn about the topic
bro
!args-kwargs
*args and **kwargs
These special parameters allow functions to take arbitrary amounts of positional and keyword arguments. The names args and kwargs are purely convention, and could be named any other valid variable name. The special functionality comes from the single and double asterisks (*). If both are used in a function signature, *args must appear before **kwargs.
Single asterisk
*args will ingest an arbitrary amount of positional arguments, and store it in a tuple. If there are parameters after *args in the parameter list with no default value, they will become required keyword arguments by default.
Double asterisk
**kwargs will ingest an arbitrary amount of keyword arguments, and store it in a dictionary. There can be no additional parameters after **kwargs in the parameter list.
Use cases
โข Decorators (see !tags decorators)
โข Inheritance (overriding methods)
โข Future proofing (in the case of the first two bullet points, if the parameters change, your code won't break)
โข Flexibility (writing functions that behave like dict() or print())
See !tags positional-keyword for information about positional and keyword arguments
Oh you sent that already
you have an addiction of proving me wrong which i love (i like learning chill)

!e ```py
def foo(*args) -> None:
print(args)
foo(1)
foo(1, 2)
foo(1, 2, 3)
foo (1, 2, 3, 4)
@pliant gulch :white_check_mark: Your eval job has completed with return code 0.
001 | (1,)
002 | (1, 2)
003 | (1, 2, 3)
004 | (1, 2, 3, 4)
The single asterisks makes it take X amount of arguments
!e ```py
def foo(**kwargs) -> None:
print(kwargs)
foo(foo="bar")
foo(1)
@pliant gulch :x: Your eval job has completed with return code 1.
001 | {'foo': 'bar'}
002 | Traceback (most recent call last):
003 | File "<string>", line 5, in <module>
004 | TypeError: foo() takes 0 positional arguments but 1 was given
double asterisks take's the keyword given and maps to the value
how did you called the function like that ??!?!?! foo (1, 2, 3, 4) ๐ณ
Correct
But also in some cases you don't need ** for kwargs
E.g ```py
def foo(bar, *, baz: str) -> None: ...
Here baz is a keyword argument, but the main difference is since I don't use ** I can't give X kwargs
wait you can, thats so cursed thats like following pep 9001๐
Only 1 kwarg
okay I understand now
but not really
what
you call the kwarg by its name and not its position compared to a positional argument
!e ```py
def foo() -> None: ...
foo ()
@pliant gulch :warning: Your eval job has completed with return code 0.
[No output]
you can still call a positional argument as a kwarg btw
Not unless / is used
the is so cursed on another level
!e ```py
def foo(bar: str, /, baz: str) -> None: ....
foo(bar="qux", baz="qaz")
/ means all the arguments before are positional arguments and only positional while * means all the arguments after it kwargs
in your add_field method you need to do name = ""
basic py
@slash.slash(name="Pickups", description= 'Host a pickup')
@has_any_role ('Franchise Owner', 'General Manger', 'Head Coach', 'Pickup Captain')
async def Pickups(ctx):
embed = discord.Embed(
title = 'Title',
description = 'A pickup is being hosted!',
colour = discord.Colour.orange()
)
embed.set_image(url='<img src="https://tr.rbxcdn.com/7c4c32d6e3671dff15f512f089fe94d8/768/432/Image/Png" alt="Football Fusion 2 - Roblox"/>')
embed.add_field(name='Field Name', value='Field Value', inline=True
)
embed.add_field(name='Field Name', value='Field Value', inline=True)
embed.add_field(name='Field Name', value='Field Value', inline=True)
await ctx.send(embed=embed)```
bro no like i showed above
ion know why that dont work
you do know discord.py is an advanced library right?
!indents
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
why you dont learn anything by copypasting
If you copy and paste, just write the code you might learn better then to just copy and paste
i have this problem when i try to run my bot
The error says it all
you need a global setup function
i have in the greetings file
You're aware requests is blocking?
You have a python REPL open in your VSC terminal, you'll need to exit it before trying to run your code since VSC is just trying to throw the command in there (which of course won't work)
So just exit() the repl
Do you know how asynchronous programming works?
If not, requests basically stops your event loop which is bad
By bad I mean it get you disconnected from the websocket gateway
What's that?
I mean I know what a roster is, but how do you want it to work within a bot
The parser didn't find anything
Basically the bot says what members have that role
when you run the cmd
like this
!d discord.Role.members
property members```
Returns all the members with this role.
like something like this
the name cant be capitalized
it can you just shouldnt
Static content?
@slate swan
ye somethin like that
what
If it's static you can just make a regular embed and send it
you want all the members with a role right well thats the property which returns a list?
Oh
and then just use str.join
So I just add that to my code and make it a cmd ye
!str.join
Joining Iterables
If you want to display a list (or some other iterable), you can write:
colors = ['red', 'green', 'blue', 'yellow']
output = ""
separator = ", "
for color in colors:
output += color + separator
print(output)
# Prints 'red, green, blue, yellow, '
However, the separator is still added to the last element, and it is relatively slow.
A better solution is to use str.join.
colors = ['red', 'green', 'blue', 'yellow']
separator = ", "
print(separator.join(colors))
# Prints 'red, green, blue, yellow'
An important thing to note is that you can only str.join strings. For a list of ints,
you must convert each element to a string before joining.
integers = [1, 3, 6, 10, 15]
print(", ".join(str(e) for e in integers))
# Prints '1, 3, 6, 10, 15'
Sure
"relatively slow", it's magnitudes slower
?
how do i make a command with numberrs in it, such as 10skin
@slash.slash(name="roster", Description='Shows members
property members
colors = ['red', 'green', 'blue', 'yellow']
output = ""
separator = ", "
for color in colors:
output += color + separator
print(output)
colors = ['red', 'green', 'blue', 'yellow']
separator = ", "
print(separator.join(colors))
integers = [1, 3, 6, 10, 15]
print(", ".join(str(e) for e in integers))```
lol would this work
just set arguments?
could you show an example
your quotes are wrong
wym
how would you like to call it exactly?
the deco
you didnt answer my question.
wym,?
i would like to call my command 10skin
you would need command groups or just use an argument which would be called skin 10
!timeit ```py
chars = ["1"*1000]
```py
out = ""
sep = ","
for char in chars:
out += char + sep
@pliant gulch :white_check_mark: Your timeit job has completed with return code 0.
1000000 loops, best of 5: 303 nsec per loop
binds moment
waty
wtf did i summoned you?????????
!timeit ```py
chars = ["1"*1000]
```py
",".join(chars)
@pliant gulch :white_check_mark: Your timeit job has completed with return code 0.
5000000 loops, best of 5: 71.4 nsec per loop
๐
es
ofc the for loop would be slow๐ญ
๐
its python for gods sake
Then why did you send a question mark smh
because you sent a phrase which isnt even in the embed ๐
nvm
are python loops implemented in C
just saw it๐
for loop
thats the quintessential for loop in programming
yeah but it shows a bit of syntax
import asyncio
this man quick
@slim ibex

Go is the best lang because of the gopher, wish we had a cool cartoon python๐
Go sucks ass ten fold
mad rust got no cool cartoon char?
bro ferris is way better
rust could have a rusty nail
no
how do I check if a member exists ina server
you mean if a user is in a guild?
ye
if member in ctx.guild or something like that
user*
it would be more appropriate to use user
yes
and i doubt that would work
i forgor how to use dpy ๐
it would probably show that Guild obj isnt an iterable or something
yeah and just check the id
for member in ctx.guild.members:
...
how do I get user object from uid again
for member in ctx.guild.members:
if member.id == 1234567890:
...
i was about to say
!d discord.ext.commands.Bot.fetch_user
await fetch_user(user_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do.
Note
This method is an API call. If you have [`discord.Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_user()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_user "discord.ext.commands.Bot.get_user") instead.
Changed in version 2.0: `user_id` parameter is now positional-only.

so I should do this?
bro was trying to check for int with == ๐
well a snowflake is an int no?
no you literally used the type itself from python
example, and thats not my point
but abc.Snowflake has an id attribute, yes
sorry ๐ข ๐ญ
you better be sorry
wonder how andy is doing with cursedcord
he should send a gist
i really didn't think he would do it after our suggestion LMAO
he was so bored he was like "yeah sure"๐
How do I make a bot from scratch?
that's the worst way to get a member with id wth
๐คฃ
utils is the same lmfao
Objects/tupleobject.c lines 618 to 626
static int
tupletraverse(PyTupleObject *o, visitproc visit, void *arg)
{
Py_ssize_t i;
for (i = Py_SIZE(o); --i >= 0; )
Py_VISIT(o->ob_item[i]);
return 0;
}```
is it, really...
utils iterates through it no?
idk haven't opened up it's source before
lmfao its still O(n)
tupletraverse
You guys got lucky, since it is april first!
i hate rewriting and reformatting my entire main functionality
I'll make it work soon
make it work before april 2
april 30th take it or leave it
the best way is get_member() which is O(1)
dw bout it
what arguments does that take?
an id
mhm
btw is bot dev all you do๐ญ
obviously
O(1) > O(n) @slate swan get rekt
bot devs dont eat or sleep or have a real life
bro yes
ive spent a decent amount of time with the lib but i havent really been making anything new
same
and no profit 
got boring for me
rewriting my bot is not too high in my priority
im doing api wrappers and web dev now
i'm doing backend web dev and cli apps
with rst?
YE
O(1/n) *techincally speaking, possible > O(1)
i quit cuz of that
im using flask
you always have a point smh
andy always has a damn point smh๐ก
this is a good sign
of course its possible. any valid mathematical expression can be g(n) afaik
show src
pardon
show source code so i can see more good signs
I said cursecord is for april fools, but I have a slight suspision I'm subconciously making Rin rewrite 3
I just don't know how O(1/n) would look in code.
bro stop pulling dannys its annoying
๐
It's only possible by the math
There is no real algorithim that could achieve that
in is O(1/n)
Don't think it's possible
yeah i thought not. it just seems off
Time complexity cannot get smaller as n increases
It's possible!, technically that is
although this doesnt have the current garbage im working on
You just can't achieve it with any algorithim we have currently
It's mostly theoretrical
that would technically mean that you have a line going down on the graph
When we figure out time machine we get bonus O(-1)
true
im hungry for spaghetti now
now my favourite part of testing bots
def get_one(n):
time.sleep(1 / n)
return 1``` :D
waitng 2 and a half minutes for timeout
bro chill
and also it is pretty much impossible atm because an algorithm's number of steps can't go under 0.
its pasta
well it probably is but its not the worst spaghetti ive ever written

ive made actual pasta taht looks worse
does anyone know how to make it where only the person who runs the command can see it
well time to work on my rust cli app!
ephemeral=true
the specific syntax depends on your library but you'd usually have the option to pass an ephemeral= kwarg when responding to the interaction
ty
well thats not ideal
I will be sending you a very angry gist in 10-40 business days
it didnt even send the message for me being removed from the queue
you better go against everything you said before today or else
any extra cost for shipping?
this is so fucked
extra if you want same day delivery
while client.players[ctx.channel.id] makes me feel a certain way
Prob 3 extra days to even off the time wasted by my procrastination
better get to it bozo
I am scratching the 270700034985558017.created_at idea, because I can fishhook and make it work. But the typehint doesn't work
So just because of the typehint I'm getting rid of it
I was gonna have await "gateway/bot".request(...) too
๐
@slim ibex you cant just makea comment about my code and then not elaborate smh
valid
make it look like await "endpoint_url".request(...)


fishhook works, typehint doesn't

so it's a no from me
smh you shouldnt even have annotations
why does it skip the if and do the except smh
error happened somewhere
I need an idea for my bot
ok but
it owuld have to be an error in the while client.players[ctx.channel.id]:
thats uh
not really the syntax its using?
bro
!e
a = {7:[1]}
while a[7]:
print("true")
print("false")
ah its a dict
@glacial echo :x: Your eval job has completed with return code 143 (SIGTERM).
001 | true
002 | true
003 | true
004 | true
005 | true
006 | true
007 | true
008 | true
009 | true
010 | true
011 | true
... (truncated - too many lines)
Full output: too long to upload
prolly should have asked the type of iterable it was first
yeah because an empty list is falsy
yes
oh shit
maybe there is something else in the try's body that is failing. did you ever try except Exception as e and printing e?
!d discord.ext.commands.Context.send
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/master/api.html#discord.File "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 "(in Python v3.10)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "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/master/api.html#discord.Embed "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 "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
it has no ephemeral kwarg
!d discord.Message.reply
await reply(content=None, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").
New in version 1.6.
Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") or [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.10)") instead of `InvalidArgument`.
๐ฟ
i barely know how except works ngl
if there was an error in try, except is run
wait does except escape it in any way?
wdym
could the escape for the timeout error be causing the error to trigger the other except and thus skip the if
ok
what command would you do to send a message from a webhook using a bot?
!e
try:
print(2/2)
try:
print(2/0)
except ZeroDivisionError:
print("Error")
if 5 < 10:
print("foo")
except ZeroDivisionError:
print("error")
@slim ibex :white_check_mark: Your eval job has completed with return code 0.
error
gameIDdict(client.channelGame[ctx.channel.id])
gameIDdict is a dict of int : str
client.cahnnelGame is a dict of ctx.channel.id : int
is this the correct syntax for getting the string from gameIDdict for the int of the ctx.channel.id
you are probably looking for an else block on the try..except where you can execute code if there is no error
!e
try:
print(2/2)
try:
print(2/0)
except ZeroDivisionError:
print("Error")
if 5 < 10:
print("foo")
except ZeroDivisionError:
print("error")
@slim ibex :white_check_mark: Your eval job has completed with return code 0.
001 | 1.0
002 | Error
003 | foo
it executes code if there is no error
since in my code it try: await wait_for and then has a buncha code below that
but as you can see with example 1, there was an error with print(2/0) so it didn't even run the nested try..except
clearly i dont understand try else
example 2 removes that error, and now you can see that the if statement and efverything runs in the nested
the first try should only error on invoking the command
idk man your code looks the same in both your exampls
i changed print(2/0) to print(2/2)
so there is no ZeroDivisionError in the first try..except
aah
but like the first try in my code doesnt error
and its weird cause it seems to be looping the entire code and not just the while
but also not
im stupid
i had indentation messed up
lmao
Share the code
tempCvrtr.py line 78
async def startGame(ctx, gameid: int = 1):```
its a lot so its defo easier to open the github page
than try to manually trim it down with my stupid human brain so it fits on discord
mixedCase ๐ฟ
yeah yeah
pep8 just does not jive ngl
maybe at some point ill go and refactor everything to be pep8 compliant
so
any ideas?
the issue?
weird handling of errors or something like that
meaning it doesnt actually send the proper end game message
probably because conditions are fulfilling
in the try
ans not fulfillig in the if
if thats your issue idk i just scrolled up
oh fuck maybe im stupid
i think i was erroring as i was clearing the players from the list before sending the message
{gameIDdict(client.channelGame[ctx.channel.id])}
ok so this is bad syntax
!e
a = {1:"apple", 2:"orange"}
b = {10:1,20:2}
print(a[b[20]])
@glacial echo :white_check_mark: Your eval job has completed with return code 0.
orange
bruh
Man that is some compact code
gameIDdict[client.channelGame[ctx.channel.id]]
this isnt working but it should function the same as above
I should have not tried to understand all of it just waking up
what dont you understand?
that is getting me a printed value of 1
what the heck does that tell me
probably an exit status of 1 which means there was an error
๐
i dont get whats wrong
it doesnt like my list printing
oh wait
i have that dict reversed
thats weird that it just prints 1. i have never seen that before
waht is wrong
btw why is it top secret
and what is wrong
how can i make step by step stuff inside a command?
python code is executed line by line. that is what an interpreter is
no but let's say i wanted to make a reaction roles setup, how would i do that
disnake
look up the disnake doc section for checking when someone applies or removes an emote, and the section for applying and removing roles
do
donโt
https://gist.github.com/ivan89234/c4674b9a76b4a4a94efce807ae127042 This is my hangman command. It works but whenever there are two duplicate letters in the word it stops working. I have no idea how to fix this. If anyone has any ideas please help me
Sounds like less of a bot issue and more a python one
whatโs it output?
fyi i just spent the last few days programming hangman
it wasnโt too hard
tempCvrtr.py line 90
elif gameid == 2:```
read from here down
for example the word beaver has 2 e's and whenever i guess e it only fills in one
assign the guesses to a list of guessed letter only if the letter hasnโt been guessed
then for i in word: if i in guesses: obfuscated-word.append i
else: obfuscated-word.append []
[] being whatever you want your hidden char to be
ok ill try that
how do i add the links, i know how to do it to title but when i try for field it dont work
doesnt work
thats easy just do this
This will not work somehow, why is that?
?
its value
โembed.add_field(name="donate", value=f"[Paypal](https://paypalme/) โ
"Not work" what's that mean?
here u go
Something "not working" is very generic and does little to understand the problem
Command will not execute when that line is there
โembed.add_field(name="donate",
value=f"Paypal โ
You mean, that field in the embed doesn't show up?
bro add_fields doesnt have description it has value
add_field() doesnt have a description parameter
No, the whole command will not work
it should be value
well whats the error?
Then how did you know it's at that line?
Also you're using "not work" again which doesn't help me in any way
ur error got fixed?
what error?
โembed.add_field(name="donate",
value=f"Paypal โ
not u sry xd
is there a way to leave the name empty?
yup
u can leave it empty
delete the space
yea ik that
You need a special character which is hacky
oh
this* or name=""
A zero-width space, specifically
That won't work
\u200b
This is in the description of the embed
!d nextcord.discord
To work with the library and the Discord API in general, we must first create a Discord Bot account.
Creating a Bot account is a pretty straightforward process.
im still can't send role mention even after set
allowed_mentions = discord.AllowedMentions.all()
Show code?
await interaction.response.send_message(helprole,embed=embed, view=View(embedid = embedid.id, hechannel = helpchannel ), allowed_mentions=discord.AllowedMentions.all())
Ok well I need documentation for thumbnails in an embed
anyone know how to make slash commands for a python bot?
!d nextcord.Embed.thumbnail
property thumbnail: _EmbedMediaProxy```
Returns an `EmbedProxy` denoting the thumbnail contents.
Possible attributes you can access are...
you mean a discord bot?
yeah
async def join(self, ctx):
if ctx.author.voice is None:
await ctx.send('You are not in a voice channel.')
voice_channel=ctx.author.voice.channel
if ctx.guild.voice_bot.is_connected() is False:
await ctx.guild.bot.voice_channel.connect()
else:
await ctx.guild.bot.move_to(voice_channel)
can someone help me with this?
Show ss of the output?
sure, what library are you using
i'm new to discord bots in python and i heard that slash commands are being forced
i'm just doing import discord
Let me get my line I am trying to add that will not work in the embed embed.add_thumbnail(user.avatar_url)
I've the role tho
voice_bot.is_connected isn't a thing?
oh what should it be instead?
right, install d.py master and read this https://gist.github.com/Rapptz/c4324f17a80c94776832430007ad40e6 (an example of slash commands in d.py)
Does the bot have permissions to mention the role?
If I were to remove the embed part to the code, would that work?
yes
Are you sure?
url=user.avatar_url
Oh
this is not working?
Change ctx.guild.voice_bot -> ctx.guild.voice_client
ImportError: cannot import name 'app_commands' from 'discord' (/home/runner/QueensWomen/venv/lib/python3.8/site-packages/discord/init.py)
Install d.py master
where
Did not work
hm
in the shell?
error?
i only see an MD file
do you have an on_command_error
oh
Yes
async def join(self, ctx):
if ctx.author.voice is None:
await ctx.send('You are not in a voice channel.')
voice_channel=ctx.author.voice.channel
if ctx.guild.voice_bot is None:
await ctx.guild.bot.voice_channel.connect()
else:
await ctx.guild.bot.move_to(voice_channel)
how do i fix this?
and type pip install -U git+https://github.com/Rapptz/discord.py
@boreal ravine this is my code:
oh yeah uh i'm doing this on replit btw
@austere vale this
ohh but im using bot instead of client in my code
can you show it's code?
I just showed you
Yeah but it's a method tied to the guild class, you can't randomly change it's name and expect it to work
oo oki
The on_command_error code
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.send(f'This command is on cooldown for {round(error.retry_after)} seconds.')
if isinstance(error, MissingPermissions):
await ctx.send("You are missing permission(s) to run this command.")
async def join(self, ctx):
if ctx.author.voice is None:
await ctx.send('You are not in a voice channel.')
voice_channel=ctx.author.voice.channel
if ctx.guild.voice_client is None:
await ctx.guild.bot.voice_channel.connect()
else:
await ctx.guild.bot.move_to(voice_channel)
what about this then?
do i have to change all the other bots to client as well?
No
Change it to ctx.guild.voice_client
in the if and else statement?
ImportError: cannot import name 'app_commands' from 'discord' (C:\Users\xd\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_init_.py)
do pip show discord.py
show me the output
.
async def join(self, ctx):
if ctx.author.voice is None:
await ctx.send('You are not in a voice channel.')
voice_channel=ctx.author.voice.channel
if ctx.guild.voice_client is None:
await ctx.guild.voice_client.connect()
else:
await ctx.guild.voice_client.move_to(voice_channel)
what should it be instead of connect?
add else: raise error
I just want to know what I need to change to add a thumbnail
try embed.set_thumbnail
OH
thats still 1.7.3
what do i do then
@slate swan
No did not work
code?
try await ctx.send(embed=embed)
which is
how do i get my bot to connect to voice channel?
.
No all the code is working fine, it's that thumbnail line
u need used avatar ?
I did use avatar
user^?
embed.set_thumbnail(url=ctx.author.avatar_url)
Oh yeah
No that did not work either
ERROR: Error [WinError 2] The system cannot find the file specified while executing command git version
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?
Have you installed git?
Yes should i do it in its bash instead?
async def join(self, ctx):
if ctx.author.voice is None:
await ctx.send('You are not in a voice channel.')
voice_channel=ctx.author.voice.channel
if ctx.guild.voice_client is None:
await ctx.guild.voice.client.connect()
else:
await ctx.guild.voice.client.move_to(voice_channel)
how do i fix this?
Fixed
Perhaps when u try to join the vc you meant await ctx.author.voice.channel.connect()
thank you so much!
U mean await voice_channel.connect()
!d discord.Interaction.client
property client```
The client that is handling this interaction.
Not bot
Weird
property bot```
The bot handling the interaction.
Only applicable when used with [`Bot`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.Bot "disnake.ext.commands.Bot"). This is an alias for [`client`](https://docs.disnake.dev/en/latest/api.html#disnake.Interaction.client "disnake.Interaction.client").
looks like you're using a bot instance that hasnt connected to discord?
It's in a Cog currently. I'm fairly new to them.
I tried to put this information in there as well.
intents = nextcord.Intents().all()
bot = commands.Bot(command_prefix = "w!", intents=intents)
bot.remove_command("help")
I'm not sure how to fix it lol
in your case the interaction has a .client attribute so that's the best way to get the bot
but for any cog methods where a context or interaction isnt provided, thats why most examples pass the bot instance to the cog's constructor, so you can reference it from self
class MyCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
def setup(bot):
bot.add_cog(MyCog(bot))```
Oh, I think I'm just formatting it wrong then, let me send more of my code.
I think I just have it above where it should be
Would I need to put the upper part below my -
class command(commands.Cog):
def __init__(self, bot):
self.bot = bot
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
Oh, sorry
what upper part
Should I do that or can I keep it?
Should I pull the codes under
class Select(nextcord.ui.Select):
class SelectView(nextcord.ui.View):
And put them below the
class command(commands.Cog):
def __init__(self, bot):
self.bot = bot
nah donโt do that
Okay, sorry, I'm lost lol.
You said to reference it as self
I've tried to do self.bot earlier on and it gives an error.
How might I make that work if it's right?
for cog methods
when its inside a select you would need to also do the same thing with your cog class, which is overriding the init method to accept a bot parameter
also the issue with writing bot = ... in your cog file is that, assuming you separated the cog into another file, you'll end up creating more than one bot instance, one in your main file that's connected to discord and another one in your cog file that is offline
Okay, I'll make sure to fix that. I didn't realize, thank you.
I think I understand, I need to write this in my other select/class?
I'm new to this, might ask dumb questions.
def __init__(self, bot):
self.bot = bot
er yeah that would be the general idea, although since the view requires its own initialization you would have to call its init using super()
class MyView(discord.ui.View):
def __init__(self, x, y):
super().__init__(timeout=123)
...```
this stuff is part of using subclasses and object oriented programming
Okay, I think I get it. Though I'm unsure of what I'd need to edit in mine.
You have an "x" and "y" - What might I need to add with that then?
class SelectView(nextcord.ui.View):
def __init__(self, *, timeout = None):
super().__init__(timeout=timeout)
self.add_item(Select())
x and y are just example parameters, you could write whatever you want there - in your case you were interested in using self.bot to get the latency, so you'd want to pass the bot as a parameter
Ohhh okay. Let me try it, thank you ๐
I'll just share the code rather than snippets.
Like this?
Try it
Should work
And please don't be like me and forget to commit 1mth worth of bot updates to git before losing it
It's like my fourth week coding, I'll try not to be that guy ๐ญ
02.04 04:35:29 [Bot] TypeError: __init__() missing 1 required positional argument: 'bot'
02.04 04:35:29 [Bot] The above exception was the direct cause of the following exception:
02.04 04:35:29 [Bot] nextcord.errors.ApplicationInvokeError: Command raised an exception: TypeError: __init__() missing 1 required positional argument: 'bot'```
you never passed in the bot parameter for ur View m9
line #43
SelectView(self.bot)
I think I just need to go watch more tutorials on this. lol
Thank you, I'll do that
Practice will carry you to infinity and beyond
Even when adding that, I'm still getting the main error.
I don't know how to fix it lol
02.04 04:41:05 [Bot] AttributeError: 'Select' object has no attribute 'latency'```
I've tried to switch it around.
`self.bot`
`bot.`
`self.`
Show the classes attributes
ayo anyone good with self hosting?
yes
Here's the full code, I've been trying to fix #19
https://paste.pythondiscord.com/casuvoqayo
what does the general process of self hosting look like? Like what application would the code be run through and how would I edit and update the code from another computer while itโs running?
Try interaction.client.latency
Okay, thank you.[
Iโm trying to find a good spot to learn about self hosting but i canโt really find one
It worked, I don't understand, can you explain?
I get the interaction but how does client tie into it?
My bot is bot not client
raspberry pi idrk
because interaction is a discord.Interaction object, and it has a client property
property client```
The client that is handling this interaction.
I thought it had to match, if it was
@bot.run it had to be bot
@client.run it had to be client
I'm not even gonna question it, I'm just happy it worked lol
Just a naming thing
I was wonderinh how to do i add a number to my command, i want my command to be !10skin
!d discord.ext.commands.command
@discord.ext.commands.command(name=..., cls=..., **attrs)```
A decorator that transforms a function into a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") or if called with [`group()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.group "discord.ext.commands.group"), [`Group`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Group "discord.ext.commands.Group").
By default the `help` attribute is received automatically from the docstring of the function and is cleaned up with the use of `inspect.cleandoc`. If the docstring is `bytes`, then it is decoded into [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") using utf-8 encoding.
All checks added using the [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") & co. decorators are added into the function. There is no way to supply your own checks through this decorator.
name kwarg
Someone ask smth plz 
How do i reply
!d discord.Message.reply
how print hello world?? !
await reply(content=None, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").
New in version 1.6.
Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") or [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.10)") instead of `InvalidArgument`.
Bot help
im jus playin
i need help, there is an error on my bot code:```py
@client.command()
async def open(ctx, arg):
cmd_FileName = str(arg)
if str(ctx.author.id) == '716439189834432523':
varCache_cmd_open0 = open(cmd_FileName, 'r')
varRawReadedDAta = varCache_cmd_open0.read()
varReadedData0 = str(varRawReadedDAta)
varCache_cmd_open0.close()
await ctx.send(varReadedData0)
if str(ctx.author.id) != '716439189834432523':
await ctx.channel.send('Perm level too')
Error?
what is the error..
Also why comparing strings? Just compare ints
its on the varRawReadedDAta = varCache_cmd_open0.read()
what does the actual error say?
the error read:varRawReadedDAta = varCache_cmd_open0.read()
AttributeError: 'coroutine' object has no attribute 'read'
ik i never stumbled that error
The command function
Change its name and use the name kwarg in the decorator and set it to open
k
Wait what
Changed the name to a10, a11, a12, and a13 still same error
Show
what show
Code
wait
Nvm changed the a13 still error
Zamn there isalot of unchanged name
@client.command()
async def open(ctx, arg):
a10 = str(arg)
if str(ctx.author.id) == '716439189834432523':
a11 = open(a10, 'r')
a12 = a11.read()
a13 = str(a12)
a11.close()
await ctx.send(a13)
if str(ctx.author.id) != '716439189834432523':
await ctx.channel.send('Perm level too')
the code
what are these variable names
its complicated
and instead of ```py
async def open(ctx, arg):
a10 = str(arg)
You can directly do
```py
async def open(ctx, arg : str):
Ok
and...instead of making the ID into a string and comparing with a string why not just use it as itself (an int)
if str(ctx.author.id) == '716439189834432523':
Becomes:
if ctx.author.id == 716439189834432523:


