#discord-bots
1 messages Β· Page 891 of 1
Databases are a very deep rabbit hole, please don't fret when picking one and just focus on what it is you wanted to get done initially
Me who uses discdb: πΆ
waiting for the "json is best" person
π that's me
It's probably better if you use a more popular database to become familiar with them (will be useful if you decide to pursue software development further)
AYO I made discdb, why u hurt my feelings ;-;
wait isn't that the database used to save CD metadata as Disc objects? lol
Idk about CD, but u can store str objects lol
Like, every type which can be stored in a JSON
ok
That's a different database
am i doing it right
def check(id):
if id == 828182019841327115:
return True
else:
return random.randint(1, 30) == 16
if check(name) == True:```
AttributeError: 'str' object has no attribute 'removeprefix
No wait
πΏ h ow t o f i x
@bot.command(aliases=["pl"])
async def play(ctx: commands.Context, *, search: wavelink.YouTubeTrack):
if not ctx.voice.client:
vc: wavelink.Player = await ctx.author.voice.channel.connect(cls=wavelink.Player)
embed = discord.Embed(title="Music", description=f"> Now Playing: {search.title}\n> duration: {search.duration}\n> author: {search.author}", color=discord.Colour.random())
embed.set_footer(text="noice")
await vc.play(search)
await ctx.reply(embed=embed)
elif not getattr(ctx.author.voice, "channel", None):
return await ctx.send("you have to be in voice channel!")
else:
vc: wavelink.Player = ctx.voice_client
vc.play(search)
can I see more code
wait
What's name there?
some one pls help
https://paste.pythondiscord.com/aqixiyapoc have a good stroke!
So you want it to always be True for someone
And random fors others?
in pins ig, but here, we dont help ytdl devs
That would work
??
it..... doesn't work?
u mean you can help?
errors?
no, just i always got random instead 16
Can I send a .txt file via discord.py?
!d discord.ext.commands.Context.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=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.9)") 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.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.

uhh help i dont know what to do https://paste.pythondiscord.com/jiduvubose
it shows like this
send has a file parameter, add the link to the file and the bot will send it
.sort() is really helpful
whaaaat ????
Ofcourse that's always gotta be random and getting 16 will be rare...
wait, what u wanna do
the names
in your send, add a file kwarg py send(file=discord.File("path to file"))
when i try from stackoverflow
no no, my id is that number, but instead return 16, that still return random
fetch
what you mean in path to file ?
its a levelling system and im storing the things in a json file
!d discord.File
class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.
Note
File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
still, fetch
you mean ? C:\Users\centu\Desktop\Everything\Discord\Attachments\101.txt
how do i-
await bot.fetch_user(id)
get_member(user_id, /)```
Returns a member with the given ID.
await send(file=discord.File("path to file")) ?
orr howw ??????
await ctx.send
Oh hi there Reptile π
await ctx.send(file=discord.File("C:\Users\centu\Desktop\Everything\Discord\Attachments\101.txt"))
@slate swan
Reptile and Hunter. Hmmmmm
no no no no DONT HUNT HIM
π
@slate swan Is that right?
ig attachment://file, that's what i do in my code
or is that embed only?
π³ what
@slate swan says use \\ ||sorry ping||
https://paste.pythondiscord.com/aqixiyapoc the return 16 thing
you have to use the escape character or use os.path to reach the path of the file
where ? Can you write me a code?
@bot.command()
async def send(ctx):
await ctx.send(file=discord.File("C:\Users\centu\Desktop\Everything\Discord\Attachments\101.txt"))
replace all the \ in ur path with \\
all \ ?
that
y e s
disclaimer: the number is my id
so, the issue is IT DOESNT RETURN 16 REEEEEEEEEE
let's see
are you sure that it's ur id and it's int?
πΏ very
^
yes, that reptile cute
:C
def check_lb(test):
print(test)
if test == 828182019841327115:
return 16
else:
return random.randint(1, 30)
if check_lb(name) == 16:``` not give a single thing :tumbleweed:
what is the name :V
yes :sad:
mbe it's an empty str
it would give NoneType object when you print it
the function is not calling for some reason
check my code https://paste.pythondiscord.com/aqixiyapoc, i alr define name whichis the thing i give in check
Pls bal
BRUH lol, your function runs only when this statement here is true: if random.randint(1, 5) == 5)
OOOOOOOOOOH that thing, i just noticed it, ggty :vvvv
lmfao
i mean, why you create a function to check a variable?
@gaunt ice lol
dank memer
whch one
your check function
for example this
@slate swan can you add me ?D:
this too lol just take the whole record
@gaunt ice add dank memer when
2 times hp
and it's just seems bad
I need blobs
i dun think so
lazy to check xD
probably you code with haste, you should take your time, analyze what you want to do, create a sort of mental map and then code
https://paste.pythondiscord.com/sinanujiye still not work
this is just a tip of course, it's not like the code won't work now, but it could be better. When you'll need to modify it would be a mess
idk :V
Can u guys tell me how to update username and avatar of bot?
if u mean like NQN, that';s webhook
from discord developer portal D_D
if the code doesn't run you have to check this if now: if energy > req
Not like nqn bot
well, it still send message, just the randomize systemmmmmmmm, it still not return 16
whic message?
Ok let me try
the check system, i try that but remove that again :V
await ctx.send(
f"{ctx.author.mention} found a {mobEmoji} {mob_}, getting friggin {exp*level} EXP, and {money} coins, lose {total} health, {hp}/{str(m)}")
lemme add again, wait
828182019841327115 <class 'int'>
828182019841327115 <class 'int'>
and it didn't return 16?
OT name idea: Rapptz-never-pay-tax
Thanks it worked
well, yes
np
print val
πΏ wait
val = check_lb(name)
print(val)
idk why but when i add that code it worked :vvvvv
i think i know why
why :V
this?
yeah. this:
f"{ctx.author.mention} found a {mobEmoji} {mob_}, getting friggin {exp*level} EXP, and {money} coins, lose {total} health, {hp}/{str(m)}" doesn't print yes

Imagine not using f strings but concatenation operator (+)

some people do this
It frightens me
including me well that's scary
change using this:
!d discord.ClientUser.edit
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.9)") 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.9)") 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.
bot.user is an instance of ClientUser
Thanks
Thx
How to chain buttons in disnake? Once button is pressed new button is generated in replace of that button
Change the button that is pressed in your view class
then you have to modify the message and send it the modified view class
thx
how can i check if a update is made on the server, in disnake, for ex: the server's name is changed, the owner is changed
!d discord.on_guild_update
discord.on_guild_update(before, after)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") updates, for example:
β’ Changed name
β’ Changed AFK channel
β’ Changed AFK timeout
β’ etc...
thanks
not wrong but imagine still using that.. yikes
f string are the best
I still use +
Cz my school cs teacher dk wtf is f string/str.format function
i don't even use it to add two lists
my school teacher doesnt care if i use f strings or type hinting or even return type of a function and she doest know about it too
Meh my teacher deducts marks, but this talk is ot
at least she knows that a string can be initiated using triple quotes π
idk if my school teacher knows about it ^^^
for my school, it was optional if I wanna take cs or not and I was like: Let's do it, the worst that could happen is that I will fail in it
What is cs? i'm italian lol
computer science
its been 3 hours do I need to wait lil bit more ? it is still not there
@maiden fable π
I did ask for their code, but eh seems like they want help from u lmao
I'm playing valorant ||in school|| cant do much rn
Wait, didn't u drop out of school for the year π
reinvoked
Lmao
anyways ot
@oblique adder mind sharing yr code?
Stop playing valo and help him ezzzz
afk offense penalty π
you cant leave the match in between, afk offense penalty applies
lmao
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
Just want to ruin your party once in a while
I'm out
Thanks.
Hahahaha
π stop pinging me unnecessarily
π pings u after 5 min again
!ruwule 7
π then why me no ping?
Because at least you know how to code hahaha
π I just copy code off stack overflow
Well, if it is already done who you should do it again? just copy it.
eh stop it before someone warns us lol
inv me uwu
why do u make me use the rule command, I am already sick of it π
https://github.com/reactxsw/topupbot
here
cog/topup.py
yes from other bots but not mine
discordpy back again?
yes
When there are multiple slash commands in a server, yours won't be shown until u do /name
Any idea how many commands are there?
Oh Ash back, nvm I will just go and study then cya
no, I'm in agent select menu π
Don't select an Agent
That is what I want u to incur Rip
go study π
Okay then u help him cyaaaaaaaaa
12 commands total
Hmm, idrk nextcord, but try printing bot.slash_commands or smth
idk, try asking in the nextcord server
how do i delete old bot msgs?
!d discord.TextChannel.purge
await purge(*, limit=100, check=..., before=None, after=None, around=None, oldest_first=False, bulk=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Purges a list of messages that meet the criteria given by the predicate `check`. If a `check` is not provided then all messages are deleted without discrimination.
You must have the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission to delete messages even if they are your own. The [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission is also needed to retrieve message history.
Examples
Deleting botβs messages...
u cannot delete messages more than 14 days or smth old
Uhh, yea that too
π Reptile, your pfp do be winking too much
π imagine type hinting and not using a lambda
Uhhh, I beg to disagree
A check? Totally me
wait it is wrong
they wanna delete bot's messages
Just saw lol
Indeed
studying?
actually i need it as bot.. im writing a command where bot deletes its own msgs... so the one in docs is good
Just feeling sad cz I don't follow anything written in the book
π So called "communication etiquettes"
deleting the bot's messages is too easy 
How do I make the bot send a message to a specific channel when it loads up and then shuts off, probably by ctrl+c
I want it to send an online / offline embed whenever the bot goes on or offline
You cannot shut down a bot with CTRL+C
Yyyyes you can.
At least that's how I'm doing it.
Go to the terminal, hit ctrl+c
Oh wait, nvm. Yea it ends the bot gracefully
gracefully?
Oh also Hunter, you use Deta/NoSQL databases for databases, right?
I don't really use DBs much, since I hardly code nowadays, but yea. I prefer using Deta to Mongo personally
iirc its a JSON DB
Calm down calm down, we don't want anyone to cry in here
Uhhh, goes away silently
whagsfhe relational database
SQL DB
pat pat
Lol
Go on, I would love to use that (:
Make that 15 days, thanks
Oh cool! Would be appreciated. Only reptiles are able to achieve that, we humans are too busy in world wars
Let's write it in ASM
@placid skiff istg if u use the ot command
Hhahaha
!ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
then i will write an OS in binary code to only manage a Database
(:
yeah, but i will write a compiler which converts the binary code in human language to run the OS π
@bot.event
async def on_message(message):
if isinstance(message.channel, discord.channel.DMChannel):
query_url = f'http://api.brainshop.ai&{channel.id}&msg={message.content}'
async with aiohttp.ClientSession() as session:
async with session.get(query_url) as resp:
res = await resp.json()
message = res['cnt']
await message.channel.send(message)
else:
pass```
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\phoen\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\client.py", line 532, in _run_event
await coro(*args, **kwargs)
File "c:\Users\phoen\OneDrive\Desktop\some-random-shit\main.py", line 81, in on_message
await message.channel.send(message)
AttributeError: 'str' object has no attribute 'channel'
Whyyyyyyyyyy
You're overwriting message
Oh shit just realized that
query_url = f'http://api.brainshop.ai&{channel.id}&msg={message.content}'
didnt u mean query_url = f'http://api.brainshop.ai/{channel.id}&msg={message.content}'
I don't think so.....
Cuz I edited it........
I don't want to show my key and brain
ah ok
Β―_(γ)_/Β―
simple error
how to disable commands from working in dms?
@commands.guild_only()
Hey guys idk if yall can see the difference but the second image is when discord.Color.random picks out the color and the first is when its discord.Orange there is a slight difference in the sharpness. I came across this which might explain it? But I am not sure how to fix it
thanks
can i make it so that only the owner can use the command in dms?
dunno I can only think of making ur own decoration check
i dont know...
check if author is bot owner, return true.
check if message was a DM, return false
Can u try printing the discord.Colour.random()? Are you sure it's returning discord.Colour.orange and not any other color code?
https://github.com/Rapptz/discord.py/blob/master/discord/colour.py#L146-L165 as u can see, it returns a random color, not one from the predefined colors
use both the oops misunderstood@commands.is_owner() and @commands.dm_only() checks
I looked up every single hex and this is the only one that came even close
@slate swan
Yeah, The saturation and value in the first is maxed, not the same case for the 2nd ig thats the reason
Yups
@paper sluice you can use @commands.check_any() and then place the checks commands.guild_only() and commands.is_owner() inside it so either of those conditions will be accepted
Is there a way for me to do that myself?
What u want to do yourself?
Max the saturation and value
just make a list of colours and use random.choice()
Huh no, I just want orange
and put that in your text colour or whatever
You will have to subclass discord.Color
Oh wait
Alr thank you
Nvm, just see the saturation and stuff for the color code returned by Color.orange and use from_hsv classmethod
from_hsv would come from Color but otherwise yeah thats fine
Wait no, won't work
why so
its a classmethod of Color...
Lemme see what the method takes in
you wont be able to use it without referring to that class
discord.Color.from_hsv(orange, 1, 1)
It needs a float
it doesnt really
discord/colour.py line 136
def from_hsv(cls, h: float, s: float, v: float) -> Self:```
>>> import disnake
>>> disnake.Color.from_hsv(1, 1, 1)
<Colour value=16711680>```
You're right
well we assumed you would define that variable beforehand
Oh wait right right
yeah that seems about right
Told so lol
most arithmetic applies to both ints and floats so they're usually cross compatible, but a Color object is definitely not intended to be compatible with other numbers
Cz it isn't an int/float lol
Ok doing that made the color red π https://cdn.discordapp.com/attachments/950235045698863188/950738667851374622/typerace.png
Huh?
orange = 0xe67e22
color = discord.Color.from_hsv(orange, 1, 1)
That hex code is of orange
thats not a hue value
huh
weirdddd
the hue should range from 0 to 1, where orange is around 0.08 and 0.14 i believe
Yea
the number that the documentation says is an RGB value in hex
Anyways, @slate swan good to know it worked!
no it didnt π
I wanted orange- it made it red
!d discord.Colour.from_rgb
classmethod from_rgb(r, g, b)```
Constructs a [`Colour`](https://discordpy.readthedocs.io/en/master/api.html#discord.Colour "discord.Colour") from an RGB tuple.
I did do that, but their is still a slight difference, its not as sharp
Thats what I did to get the rgb
oh wait I can use the rgb of the hex
Nah its just not bright enough https://cdn.discordapp.com/attachments/950235045698863188/950740087048634378/typerace.png ig ill just tweak it myself
Ah okay cool
!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.
help me!
please
i think u need to wait for some time before it cache it like 10secs @slate swan
let me try
Why are you calling int() on something that's already an integer?
Not working bruh
intents
Makes sense π
!d discord.Intents.guilds
Whether guild related events are enabled.
This corresponds to the following events...
Actually, I'm trying to get dm channel object π
just use fetch D_D
nope, DM has PrivateChannel
ye
the on_message event returns nothing
and has a message object, from the message object you can get the instance of the chat where the message is sent
srcπ³
by learning python
bro thats kayle
with a lot of docs, tutorial and source code example, but first of all you should know python
how does kayle not know python
!d discord.DMChannel also exists
class discord.DMChannel```
Represents a Discord direct message 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 a string representation of the channel
well one of them is a subclass so nothing change
kayle got banned, im his alt 
Iirc DMChannel is a subclass of Messageable
not very well worded
@slate swan go to school, stop lurking
PrivateChannel is an abstract class
class discord.abc.PrivateChannel```
An ABC that details the common operations on a private Discord channel.
The following implement this ABC:
β’ [`DMChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.DMChannel "discord.DMChannel")
β’ [`GroupChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.GroupChannel "discord.GroupChannel")
This ABC must also implement [`Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake").
it implements DMChannel and GroupChannel
Yups
||I sadly hit a rock and lost all my python knowledge||
you hit the rock?
π³
i should work but i don't want to finish my ticket today because after that I have to create the docs and a trial card lol
||goodbye
||
Is this a Goku reference?
||
||
what are you working on?
no lol
How to do my struct of code will looke like this :
<guildMemberObject>.edit ....
electronic invoicing automation
nice
what i should do if i want to have my struct look like this?
uhm
Bruh?
context has a guild attr which returns a guild obj
or you can use the author attr that the context obj has
I feel like your talking about rust lol
depends what error do you have
!d discord.ext.commands.on_command_error

you forgot to call it
Fu....
iirc you need to call it
how should i call it
you forgot ()
ah
you could've just said what the dog said 
nvm you dont need to call it but weird it raises an error
Remove the () lol
if instead you want to make an error handler for 1 command you should do this:
@client.commands(name="my_command")
async def my_command(ctx: Context, *, args):
#Stuff here
@my_command.error()
async def my_command_error(ctx: Context, error: CommandError):
Dog?
His name is okimii, and he ain't a dog (:
i think he is insulting you
You better not call him that from next time

dog sounds cute
im not helping you
π
You've lost a nice helper

lucky for you that me and hunter are here

but only for a while cuz in 15 minutes i've a call
im taking hunter with me
then you're alone


wow
its ok
there is my work partner who has gone to the toilet like 20 minutes ago and he is not returned yet
and he has the call with me lol
stuff got serious π³
i think he shitted out his insides


yes?
you have same name..
probably the naming its overwritting itself
on two functions
||he didn't add return in his Body.sh*t() method||
π³
ah
how should i put those 2 together
hes in a classmethod π³
@clear.error
async def clear_error(ctx, error):
if isinstance (error, commands.MissingRequiredPermissions):
await ctx.send('Imagine no permissions lol xd.')
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send('Please specify an amount of messages to delete.')
check now
like this?
but put elif on the second if
oh yeah
π³
but there isn't an error message when i run the command on my mini without permissions
@spice basalthow did u import has_permissions?
yes
how
ah ok
D_D

well it is in disnake tho
There is no MissingRequiredPermission, only MissingPermission D_D
and it is in ext.commands
ye its MissingPermissions he wants

commands.MissingPermissions not commands.MissingRequiredPermissions
And yea, Akeno boi, also see that only I can call okimii names, one of which is wh- nvm
he calls me a whistle
AttributeError: 'NoneType' object has no attribute 'channel'
channel is None
So now, follow me:
What is the error saying to you?
DON'T SPOILER
Also why the f*ck are you using brackets like you're in Java or C
π
that makes me ill
probably not where its shown as context cant be None
I wonder how black would format it
xd
it will not, it will tell you to delete python and return to Java
xD

you are

changing lines to have longer code is cool
make all code 1 line is cool too
you think so? try to get the source code of a php file from a website
i didn't mean full code 1 line
i mean make it shorter as possible. without that
π you didn't hear him tho
And none except me and andy can call u that (:
I have 
Ouh cool

no

π can we take this to an OT channel?

ah
thanks
Use discord.py 2.0, it has buttons
still isn't working
there isn't an output error message
Basically with on_raw_message_delete call HAPPENS even to messages sent when the bot was offline, but there is no way to get the contents right? Or is there any work around to get the contents of those messages cuz wont those messages be in history
- no
- there is
it has a payload, it means that you can get the message object from the payload id and with the message object take its content
the command won't activate but there isn't an error message
you can get the message id from the payload*
your wording goes brrrrrrrrr
I think
Right now, I use payload.cached_message so instead I should use from the payload.message_id?
What if ur not handling the error. Use an else
!d discord.RawMessageDeleteEvent
class discord.RawMessageDeleteEvent```
Represents the event payload for a [`on_raw_message_delete()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_message_delete "discord.on_raw_message_delete") event.
it has a message_id so yes
instead of making specific command errors, you should handle the possible inside the command or use a global on_command_error
Kay let me try
@buttons.click
async def help(ctx):
await ctx.reply(f"Hi {ctx.member.name}")
@client.command()
async def h(ctx, *, member: discord.Member=None):
member = member or ctx.author
if member is None:
return
nvc = "ΧΧΧ©ΧͺΧΧ© ΧΧ Χ ΧΧ¦Χ ΧΧΧΧ¨"
if member.voice is None:
return nvc
mcontent = f"<@&890317731960868875> | {member.mention} Χ¦Χ¨ΧΧ Χ’ΧΧ¨Χ!\n{member.voice.channel.name}"
await buttons.send(
content=mcontent,
channel = ctx.channel.id,
components = [
ActionRow([
Button(
style = ButtonType().Primary,
label = "ΧΧ€Χ",
custom_id = "help"
)
])
]
)
It is not send the message. No Errors.
@slate swan I hope those are not legit tokens... https://github.com/Dark-Light007/Dark-Light/blob/main/utils.py
she probably regenerated it
Discord automatically regens the token even if they are posted on a private repo
and what you doing in ash's profile
and you get notified
π why u have soo much interest in the same
its fine because im in your gitπ³
i mean mabe it just a string in token.txt
What?
π³
@spice basaltdo u even read your own code or copypasta too hard?
?
nvr used buttons cant help
why are you returning if member is None?
it will never be None
@client.command()
async def h(ctx, *, member: discord.Member=None):
member = member or ctx.author
if member is None: # this willnver run anyway
return
yeah lol @slate swan same

and why is member a kwarg
By the time I fetch the message, the message is gone right? So discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message
yes i think so 404 @untold oriole i think u get same if try delete a message that already been deleted too
couldnt find the msg lol
What?
he ment could't
yeah typo
coc player spotted. opinion accepted.
Yea thats what, so there is no way around? @placid skiff
no the wizard emote just looks too funny and cancerous

it's so funny, and i don't know why
coc hater spotted. returning to hog rider hq.
affirmative
dont know why im doing this tbh
π
HOG RIDDDDDDDDDDDDDDDEEEEEEEEEEEEEEER
!ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
HOG RIDERRRR
sorry
loll
5 minutes i came back to my pc and you can update me
Sure
Ok tell me
Nothing much, since the message is deleted, it cannot find it
I have the message id but its quite pointless if it cant find the message
import asyncpg 2022-03-08T15:33:29.869617+00:00 app[worker.1]: ModuleNotFoundError: No module named asyncpg i installed asyncpg
I kind of installed asyncpg, what's wrong?
my discord bot is supposed to send a random message when it's mentioned, but it's not working. here's code:
#####################
mention = ["I'm ignoring you.", "I don't care what you have to say.", "...", "What do you want? Is it important?", "***WHAT'S THE PURPOSE OF THAT PING? THERE'S LITERALLY NO POINT!***", ":unamused: What was that for?"]
#####################
@bot.listen
async def on_mention(message):
reply = random.choice(mention)
await message.channel.send(f"{reply}")
import asyncpg
on mention event isnt a thing
ok
you have to add the intents in the invite link
wut
then you can try to use cached_message, which returns the message object if it is find in the cache
permissions or role check
has_permissions
nope None
isnt it like a normal command
!d discord.ext.commands.has_permissions
@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.
Note that this check operates on the current channel permissions, not the guild wide permissions.
The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions").
This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
si'mon
you need the content of message that are deleted even if they are not in the cache?

depends on what library you use
what package are you using?
you using discord.py?
it will work
!d nextcord.ext.commands.has_permissions
@nextcord.ext.commands.has_permissions(**perms)```
A [`check()`](https://nextcord.readthedocs.io/en/latest/ext/commands/api.html#nextcord.ext.commands.check "nextcord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.
Note that this check operates on the current channel permissions, not the guild wide permissions.
The permissions passed in must be exactly like the properties shown under [`nextcord.Permissions`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Permissions "nextcord.Permissions").
This check raises a special exception, [`MissingPermissions`](https://nextcord.readthedocs.io/en/latest/ext/commands/api.html#nextcord.ext.commands.MissingPermissions "nextcord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://nextcord.readthedocs.io/en/latest/ext/commands/api.html#nextcord.ext.commands.CheckFailure "nextcord.ext.commands.CheckFailure").
why would it not work in slash command
yes it works with slash commands both are ext.commands
yes
no, you need to mention the permissions too
@commands.has_permissions(send_messages=True (etc etc))
@commands.has_permissions(kick_members=True)
yea
asking for help now - trying later xD oh well
sorry if you've seen this question multiple times but we can no longer change bot profile pic can somebody tell the method to do that
bot.user.edit
!d discord.ClientUser.edit
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.9)") 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.9)") 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.
yea ig, like those types of messages are the ones that are in the channel just before bot gets restarted
tysm
Traceback (most recent call last):
File "main.py", line 86, in <module>
bot.run(os.getenv("token"))
File "/home/runner/EjxCeoBoSAy/venv/lib/python3.8/site-packages/discord/client.py", line 723, in run
return future.result()
File "/home/runner/EjxCeoBoSAy/venv/lib/python3.8/site-packages/discord/client.py", line 702, in runner
await self.start(*args, **kwargs)
File "/home/runner/EjxCeoBoSAy/venv/lib/python3.8/site-packages/discord/client.py", line 665, in start
await self.login(*args, bot=bot)
File "/home/runner/EjxCeoBoSAy/venv/lib/python3.8/site-packages/discord/client.py", line 511, in login
await self.http.static_login(token.strip(), bot=bot)
AttributeError: 'NoneType' object has no attribute 'strip'
what does this error mean?
the token is none
most probably the getenv function is returning None
Are you using a database?
what are you trying to do?
so there is not env named token
uh yeah, there's no env variable as token

lol yea i realize
the emoji isnt even spelled right
Nope, I did not want to manually cache the messages either
I think its fine if I let it go
whats the issue 
I know, am too lazy to edit it
its kanna
Ok hahaha
I mean you can do it but you need a database that saves uncached message with their id and content so you can retrieve them
Like before you turn the bot off you add an event which loop trough message deleted cache and save them in the db
which is a lot of work tbh
Yea true
πi just realised that the custom emojis in status disappears too if you dont have use external emoji perms in a channel
@slim ibex ?
AttributeError: module 'discord' has no attribute 'ButtonStyle'
@bot.command(aliases=["pl"])
async def play(ctx: commands.Context, *, search: wavelink.YouTubeTrack):
if not ctx.voice_client:
vc: wavelink.Player = await ctx.author.voice.channel.connect(cls=wavelink.Player)
await vc.play(search)
embed = discord.Embed(title="Music", description=f"> Now Playing: {search.title}\n> duration: {search.duration}\n> author: {search.author}", color=discord.Colour.random())
embed.set_footer(text="noice")
button = Button(label="Click rn ", style=discord.ButtonStyle.blue, emoji="π€£")
view = View()
view.add_item(button)
await ctx.reply(embed=embed, view=view)
elif not getattr(ctx.author.voice, "channel", None):
return await ctx.send("you have to be in voice channel!")
else:
vc: wavelink.Player = ctx.voice_client
if vc.queue.is_empty and not vc.is_playing():
await vc.play(search)
embed = discord.Embed(description=f"> Now Playing: {search.title}\n> duration: {search.duration}\n> author: {search.author}", color=discord.Colour.random())
embed.set_footer(text="noice")
await ctx.send(embed=embed)
else:
await vc.queue.put_wait(search)
await ctx.reply(embed = discord.Embed(title = "Queue", description =f"added {search.title} to the queue", color=discord.Colour.random(), set_footer = "love your music choices!"))
vc.ctx = ctx
vc.loop = False
setattr(vc, "loop", False)
ytdl π
arent we not allowed to help with youtube music bots
idk I never read the code, sorry
!ytdl nope
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTubeβs robots.txt file; (b) with YouTubeβs prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
thats correct
ahh
ok thaks
pip install git+https://github.com/Rapptz/discord.py
i mean ImportError: cannot import name 'InvalidArgument' from 'discord'
Hmm, that exception was removed from the lib
so what do i do?
folks discord.py back
you knew now?
bru
just remove it?
these people knew ages ago
i didnt believe it
then button no work
They will, just remove the InvalidArgument from code
there is none
how to revert back
thats from import code
from re import search
from discord_buttons_plugin import *
import discord
from discord.ext import commands
from discord.ui import Button, View
import os
from discord_components import *
from typing import Optional
from telegram import Bot, Voice, bot_api_version
from discord.ext.commands import Cog, Greedy, Converter
from discord import Embed, Member, NotFound, Object
import wavelink
import random
import asyncio
these are my imports
this is what vscode shows
hmmm
Idk
XD
i reverted back to discord.py 1.7.3 after that error
then
error gone
could you give code for the revert
there isnt a code
you dont need shit like dislash and discord_componenets
i installed from my requirements.txt
discord.py is back and added all that stuff plus more
use discord 2.0.0 bruh
!pypi discord.py
we all saw that
not updated
you gotta install from git i think
that made my bot worse XD
no
yea
that isnt 2.0.0
!pypi discord.py 2.0
probably because avatar.url and icon.url
π
sed
poetry add "git+https://github.com/Rapptz/discord.py"
i said you have to install it through git
XD
i did
pip install git+https://github.com/Rapptz/discord.py
confusion...
type print(.__version__.)
ah yeah there it is
that isnt beta, this is poetry add "git+https://github.com/Rapptz/discord.py"
poetry makes it so its primary
and doesnt get uninstalled by a new update
I wont update to 2.0 until everyone is ok with it
dude its literally so good
poetry : The term 'poetry' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:1 char:2
- poetry add "git+https://github.com/Rapptz/discord.py"
-
+ CategoryInfo : ObjectNotFound: (poetry:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
the buttons are excuted perfectly
its fine lol
But the slash commands
you need to install poetry lol
I hate the slash commands in discord.py
got a error
If I use slash command in dm's, does then interaction.guild return None?
why?
yup
Or what's the easiest way to determin if user used command from dms
pip install -U git+https://github.com/Rapptz/discord.py
they're so much better than prefix commands
mac@MacBook-Pro-de-mac ~ % pip install pyspark
zsh: command not found: pip
mac@MacBook-Pro-de-mac ~ %
what package are you using?
Disnake :D
guys did someone faace this problem before
do you have Python installed?
yes
try pip3
^
async def on_command(ctx):
if ctx.guild is None:
await ctx.send("why dm!")```
In the forks they are much simpler to use
You can easily use them in cogs but in discord.py itβs not that easy
Itβs feels like they arenβt made for the beginners
forks are going to die when the next discord.py update comes out lmao
Nah
april 30th is the schedule
the tree command thing is interesting, but it isn't that much harder...
but black doesn't work for me i don't know why
discord.py is the only verified python library server that literally bans people for using forks
nextcord is gonna become outdated quickly as it was made for quick noteriety. same as whatever else was there
they dont like people talking about forks there
Collecting git+https://github.com/Rapptz/discord.py
Cloning https://github.com/Rapptz/discord.py to c:\users\admin\appdata\local\temp\pip-req-build-txu2rjtx
Running command git clone --filter=blob:none --quiet https://github.com/Rapptz/discord.py 'C:\Users\Admin\AppData\Local\Temp\pip-req-build-txu2rjtx'
Resolved https://github.com/Rapptz/discord.py to commit 3d74da8d7062f0a61490c7d6cf86a43394aab3e5
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: aiohttp<3.8.0,>=3.6.0 in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (from discord.py==2.0.0a3786+g3d74da8) (3.7.4.post0)
Requirement already satisfied: async-timeout<4.0,>=3.0 in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py==2.0.0a3786+g3d74da8) (3.0.1)
Requirement already satisfied: typing-extensions>=3.6.5 in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (from
Requirement already satisfied: attrs>=17.3.0 in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py==2.0.0a3786+g3d74da8) (21.4.0)
Requirement already satisfied: multidict<7.0,>=4.5 in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (from aiohttp<3.8.0,>=3.6.0->discord.py==2.0.0a3786+g3d74da8) (5.2.0)
Requirement already satisfied: idna>=2.0 in c:\users\admin\appdata\local\programs\python\python39\lib\site-packages (from yarl<2.0,>=1.0->aiohttp<3.8.0,>=3.6.0->discord.py==2.0.0a3786+g3d74da8) (3.3)
yeah its installed then
They are toxic
but ImportError: cannot import name 'InvalidArgument' from 'discord
I mean you wouldnβt want someone talking about alternate libraries and poaching in your server would you?
the forks are literally just updating 2 - 3 things and uploading it
it's not about USING forks, it's about TALKING about them in the dpy server
its literally stealing
it is about using, talking about them is fine
@slash_command()
async def something(ctx: ApplicationCommandInteraction):
#some stuff here
if ctx.channel.type == "private":
await ctx.send("private_channel")
no its a skin
i think that it should work
the inside is the same
they're gonna ban every fork user in their whole server? Doubt it
yes thats what a skin means
No itβs a fork of discord.py
For sure there are some copy pasted code parts
interaction: ApplicationCommandInteraction
aight im going to discord.py server
the whole __init__ file
outside is different , inside same
.gg/dpy
its literally a fork, of course some shit would be copied
ctx is shorter and they're pretty the same
yea thanks
slash commands don't have ctx
thats what smartphone companies do with android
What is wrong to use discord.py code in a fork when the original owner retired
its not accurate
In pycord they have
Yea it's Danny's Fault
you can use the original_message method after you send a message with interaction then create a context to that message
π
thatβs so messy.
but why LMAO
yeah, it changes 1 - 2 things that were already made but in beta, so it isnt on pypi, then
all they do is upload it and people install it
Dunno you could use a converter and so you need a context xD
Except for the fact that itβs back
well its probably poorly indented in relation to code above
want me to send the code?
also nice pfp. reyna
really need it rn
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
ah yeah
ccs.pop(0)
with open("path", "w") as file:
indented one space too far
also path was a placeholder for the path to whatever you want to open
import discord
from discord.ext import commands
import requests
from read import read
import random
import os
bot = commands.Bot(command_prefix="owo")
bot.remove_command("help")
@bot.event
async def on_ready():
print(f"{bot.user.name} is now ready!")
@bot.command(pass_context=True)
async def help(ctx):
await ctx.send("This is a help command")
@bot.command(pass_context=True)
async def gen(ctx, *, message):
if message == "mc" or message == "MC" or message == "Mc":
accs =[]
file = read(f"database/mc.txt").split()
acc = file[0]
for line in file:
accs.append(line)
ccs.pop(0)
with open("path", "w") as file:
for item in accs:
file.write(item + "\n")
l = requests.post("hastebin.com/documents", data=acc)
link = "https://hastebin.com/" + l.json () ['key']
alias = random.randint(1, 9999999999999)
r = requests.get(f"https://shrinkme.io/api?api=0d63ec4209864d14d8cb170ef1728985476489bd&url=%7Blink%7D&alias=%7Balias%7D%22")
await ctx.send(f"Minecraft Account Generated - (r.json() ['shortenedUrl'])")
bot.run("")```
and I would recommend making this code more readable. and pass_context is legacy iirc
requests is blocking also
i cant fix it
and don't use a txt file as a database...
json?
no
an actual RDBMS like SQLite or Postgres
SQLite is probably best for beginners
its very simple and straightforward
i gtg
ok
https://shrinkme.io/api?api=0d63ec4209864d14d8cb170ef1728985476489bd thanks for api-key
wrong
put commands decoration above slash_command
si
It doesn't matter afaik
well its better easier to read
I kind of disagree
oh ok
slash_command can be used with has_permissions?
tbh myself hvnt used slashed so much i just did a test command kinda
i am not 100% but should work
ok not am not sure if nextcord supports it
dont see it anywhere in the src
disnake supports that tho.
another reason why nextcord is :trashbin:
dosnt he also need to update the bot constrtuction with sync=true
for action to update? or no need?
dont think its required for a check
oh ok
since thats an internal thing unrelated to the API
could be worth a try tho - or simply we can say nextcord is behind
how can I do message.channel.reply?
no there's no ctx, its an event
so is it a message object?
yes
await message.reply("hello")
it is message.channel.send() currently
u dont need channel
oh
lemme try
but send/reply works same
oh well the message could be like "someone boosted server"
!d discord.MessageType
class discord.MessageType```
Specifies the type of [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message"). This is used to denote if a message is to be interpreted as a system message or a regular message.
x == y Checks if two messages are equal.
x != y Checks if two messages are not equal.
I got an error with it earlier console AttributeError: 'TextChannel' object has no attribute 'reply'
so let me try removing the channel now
try the message.reply
np
whats this error
the fuck?
its related to slash commands ig
invite the bot with application commands scope
send full traceback
"scope" is not same as "permissions"
alright
I agree, how did you originally install it?
discord.py installs it as a requirement
Ok
not its not generating url wth
@desert cosmos what are you trying to do?
generating a url
from discord developer portal
its not generating for this specific bot i think because i have generated a few minutes ago and generating for other bots
lmao
@desert cosmos send me a screenshot of the first page you land on in the discord developer portal then I will walk you through on how to properly generate the URL.
wot πββοΈ
alr
your briβish now innit
i mean, english is not even my primary language
@desert cosmos tell me if that works
oh i know that but actually the problem is when i am selecting everything its just not showing the link
What is your primary language python
Ok send me a screen shot of the entire page with the link generator
I think I know whatβs wrong
alright i got it
thanks everyone
hindi π
what does this mean ?


