#discord-bots
1 messages · Page 892 of 1
you turned on 0AUTH in the bot options
oh nice
turn it off
alr
Click on the url generator, then click bot, then the url is there
Make sure your clicking url generator
Tell me if you understand that.
brb
yeah
Ok, happy to help 😁

Hello, is there a method to edit interaction response? (interaction.response.edit_message not works, gives me nextcord.errors.InteractionResponded: This interaction has already been responded to before)
yeah you have to edit the original message and not as a response
!d discord.Interaction.edit_original_message
await edit_original_message(*, content=..., embeds=..., embed=..., file=..., files=..., view=..., allowed_mentions=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the original interaction response message.
This is a lower level interface to [`InteractionMessage.edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.InteractionMessage.edit "discord.InteractionMessage.edit") in case you do not want to fetch the message and save an HTTP request.
This method is also the only way to edit the original message if the message sent was ephemeral.
I'm too slow 😔
okay thanks
I can always delete the embed and wait for u to type the wrong command complete 
I-
ash being ash

I hate this emoji now, thanks

anyone tired of coding in spanish
I have tried the vice versa
text-to-speech-to-speech-to-text
text to speech
atleast answer his question
lol
What
i dont do dm help
Thtas a big fuzzing lie
U do help me in DMs all the time
see exposed
@spark cloud-> @slate swan is thebest of thebest when it comesto RPG
he loves making them n will gladly help u

prove it
oui oui but no
Thanks for pointing that out.
I need developper
@maiden fable is the best you can get 
Ash
Hunter
Meh, best from the last
hunters smort
and blocked,
I meant to this, Ash ^^^
I'll have a headache in my stomach, stop lying 
Why ???
why not?
So pls translate "c'est pas gentil d'être méchant ! "

see, I do understand that, but I'll pretend like I forgot french 
they arent
@spark cloudits not nice to randomly just DM peoples asking them to make u a bot.

Never knew u get those by listening to truths
nah, I accept the truth peacefully 
leave
@candid pilotbreaking rules but trolling i guess
I dont have money
calm down im kidding g
no doubt

one ps5 and I'm all yours
u get what u pay for 😄
didnt have to but okay
why even pay for bots if im here
kek
Same
how do i remove all buttons from view after timeout
just make a bot upload to github for all to copy pasta n we can close this channel
go lean how to do it urself
just use carl bot
Idk
its not that hard
fr
Same
@spark cloudno one gonna make u a bot
Lmao
all commands are in the premium plan
lol, just use dyno then ;-; and no, not all
*help
was a joke lol
@spark cloud stop being so Toxic, I don't like blocking people but u forced me 
Allez bye les gars je vais aller jouer a clash royale
we would help if u showed code and was trying to make it urself first and had issues with it. we aint gonna make it from scratch for u.
sure, bye, enjoy
whatever 
xD
from discord.ext import commands
token = '#your token here'
bot = commands.Bot(command_prefix='.')
@bot.event
async def on_ready():
print('ready')
@bot.command()
async def hello(ctx):
await ctx.send("hello")
bot.run(token)```
Tu es trop drôle
here
J'ai déjà sa ptdr
!rule 4
4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.
stop.... 
Toi tait toi
smh
??
Why u making me ping the mods now 😔
means, "you shut up" 😔
!timeout @spark cloud oui oui
lmao what
anyone else having bot issues today? it looks like there's an active incident https://discordstatus.com/incidents/cjdx9txnrv03
I was getting 502, then 503, now 403 errors.
api outage
- listeners
- use only 1 or 2 quotes dont mix them
- useless variables
- no typehints
- be cool and subclass the bot class

the file isnt even supposed to be runned
whats up with the new system on changing bot info
api seems to be up now
!rule 1 - be nice please
1. Follow the Python Discord Code of Conduct.
api was down lol
just look at the discordstatus
I just translated 😔
what did it say?
my client is working fine except for loading images
on mobile lol
sisi is the only person who's pfp i cant see
i canr see a single one
"you shut up" 😔 why would i tell someone to shut up
oh right i didnt catch that
~~maybe if you werent such a rude person i wouldnt of accused you 😩 ~~
Hey does anyone have experience with why my discord bot is offline when I've got my program running
discord is a bit pooped rn
best to give it a breather
abuse the api
https://pastebin.com/GbZUadHn this is my code regarding the bot its to forward telegram msgs to discord but its not working for some reason
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
forwarding from telegram to group to another group is working but to discord isnt
hurts a lot
probavly because discord is literally broken
Nah it wasn’t working yesterday too @manic wing
whelp looks fine to me - what error are you getting?
Can anyone help me, I already installed the package
restart editor, wrong channel
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)

hm
I’m not getting an error but the bot isn’t forwarding anything that’s put in the telegram group and I just can’t figure out why. The bot isn’t coming online either whenever I’m running my program
try again in a couple years hours and see if it works
bots are toasted rn
no error is odd
Ok thanks
oh bruh, thanks anyway
no problem 🤗
that emoji
Hey so uh, how do I clone an emoji kind of?
So it's like /clone_emoji emoji: 
You'd need nitro obviously
bots have nitro
But idk how to actually clone the emoju
Does that mean they can have an animated pfp?
Also I meant the user themselves
who knows who cares
me
Bots can't have animated profile pictures afaik
Ah ok
What about the actual question tho? How do I make it so the bot takes the emoji entered into the option, then add that to the specific server?
!d discord.Emoji.url
property url: str```
Returns the URL of the emoji.
ddos
you mean they removed it
!d discord.PartialEmoji.url
property url: str```
Returns the URL of the emoji, if it is custom.
If this isn’t a custom emoji then an empty string is returned
did yall feel the ddos?
what ddos
hmm
what are you talking about
there has been no ddos
discord was down for an hour
not necessarily a ddos lol
no it can be noobdevs but
I don't think somebody would ddos discord
ye what i ment downtime
maybe you got ddos for statements like this
just trying to meme n u think putin aha! or china! lol
w h a t
??
prob someone on discord dev crew git
wrong code
my client even begged for an update
but no connection lol
TTL=30sec
bad internet
Satellite crashed
elon musk must

Imagine Google went down for more than a few hours
imagine if google was banned
China
is google open for russians?
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
hello?
haven't been ignored more in a while
anyway lets talk discord bots
Is there a way to without downloading them?
copy names too 😄
i dunno dont u need to upload it?
so then u need to download it
or read it*? with request as bytes?
i dunno
website -> read bytes -> discord.File() -> "send" / "upload"
or download as a cached and upload that n remove local file
@modest ploveram drunk i go bed 😄
Hello, does anyone here know of anyone who is good at creating Discord bots?
Someone knows how to create a custom event?
what do you mean by 'custom event'?
nah mate, im here to learn about bungee jumping
Like... A custom event... Lol
😑
One that you create by yourself
I do ! I do !
Yes, everyone here
Yee. Can i trigger it like when a file get updated? Lol
!d discord.on_message_edit you would check for attachments difference in before and after
discord.on_message_edit(before, after)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") receives an update event. If the message is not found in the internal message cache, then these events will not be called. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.
If this occurs increase the [`max_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") parameter or use the [`on_raw_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_message_edit "discord.on_raw_message_edit") event instead.
The following non-exhaustive cases trigger this event...
Nope the file will not be sent, it will be edited by an external script
oh alright
?
I'm looking for someone to make a bot for me and a friend. Please contact me if your interested.
!rule 7
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
8. Do not help with ongoing exams. When helping with homework, help people learn how to do the assignment without doing it for them.
😑
!rule 9
Essentially, i will have a script written in Java that add rows to a database, i need to check when the database get modified so i can run a script to do stuff on discord
And i don't want to use tasks because it needs to get updated when the database get modified
oh when an actual file gets updated lol
thats not really discord-bot related
!ot on ya bike
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
.-.
It is an event that my bot will have
Well fine, i'll read the source code lol
gl
you can make a help channel if you need some help
What's wrong?
async def create_db_pool():
bot.pg_con = await asyncpg.create_pool(database="database", user="user", password="password")
bot.loop.run_until_complete(create_db_pool())
you can't say whats wrong and not say what the issue is
File "/app/.heroku/python/lib/python3.9/asyncio/selector_events.py", line 537, in _sock_connect_cb
2022-03-08T21:40:06.173139+00:00 app[worker.1]: raise OSError(err, f'Connect call failed {address}')
2022-03-08T21:40:06.173139+00:00 app[worker.1]: ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 5432)
dont use heroku
.
And what hosting to use? Free (even if time is limited) and with git binding.
AWS has a free tier on t2.micro instances
Oracle has a free tier
How do I do the joined at timestamp?
).add_field(
name = "Join Date",
value = f"<t:me.joined_at.timestamp():D>"
You need {} around expressions
you aren't actually calling the function there
!e
print(f"5+5 is 5+5")
print(f"5+5 is {5+5}")
@sick birch :white_check_mark: Your eval job has completed with return code 0.
001 | 5+5 is 5+5
002 | 5+5 is 10
Same thing in your case
It isn't..? I get an invalid f-string syntax
How does your code look like with the curly braces?
value = f"{<t:me.joined_at.timestamp():D>}"
Ohhhh ok I get it
In your case you would use the braces around me.joined_at.timestamp()
!f-strings
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
Yes, because it includes decimals
How do I make it like a UNIX Timestamp?
You might want to int() (more accurate) or round() it
Like one of these
Yes, you have to round it or floor it
Idk how I had it before, because I had it, but lost the file
How?
The way I'm thinking it works doesn't work
Like this
value = f"{round(<:{me.joined_at.timestamp()}:D>)}"
round() takes a float
That's what I've got, I thought it might work..? But it doesn't
That's not a float
It'd be easier if you extracted the timestamp into its own variable
timestamp = int(me.joined_at.timestamp())
string = f"something <t:{timestamp}:R> something"
hey why cant i import cooldown from discord.ext
Yep, got it now. Thanks Robin :)
What error are you getting?
nah nvm
it needed to be imported from discord.ext.commands
my bot is not responding my commands, is this a code problem or not?
If you get replit premium or something like that
What hosting can you use? Free (at least limited hours) and with git binding?
Can somebody tell me, why can't I pass that keyword through that class?
Well no free hosts are good
And what are at least?
Show the code for the view not the dropdown
Replit is free

However it’s underpowered and you get the problem of rate limits
If you want a good host, I’m not the person to ask
What about hosting?
U asked about it
why can i not use bot when making slash commands?
For discord.py v2?
wdym
can i use bot?
DropdownView is StoredownView
You need to use tree and bot
Ur showing the code for a select. I need to code for StoreDropdownView
No I'm not? Aghh
Did u sync? If u did it take an hour if u didn’t specify the guild
Ur are showing the code for StoreDropdown not StoreDropdownView
Did u sync?
whats that\
My bad,
await tree.sync() in on ready
oh
like this
Yeah but I think if u want them to come instantly u would have to specify the guild like how u do in the tree command decorator
ok
await tree.sync(813472094657445929) so this?
oh wait nvm
i found it in the docs
guild=discord.Object(id=some_id_here)
got it
IMO using discord.py right now makes no sense
Traceback (most recent call last):
File "C:\Users\nikit\PycharmProjects\dpamong\discord\client.py", line 384, in _run_event
await coro(*args, **kwargs)
File "C:\Users\nikit\PycharmProjects\dpamong\docs\main.py", line 30, in on_ready
await tree.sync(guild=discord.Object(id=699577686795747349))
File "C:\Users\nikit\PycharmProjects\dpamong\discord\app_commands\tree.py", line 655, in sync
data = await self._http.bulk_upsert_guild_commands(self.client.application_id, guild.id, payload=payload)
File "C:\Users\nikit\PycharmProjects\dpamong\discord\http.py", line 501, in request
raise Forbidden(response, data)
discord.errors.Forbidden: 403 FORBIDDEN (error code: 50001): Missing Access```
what
Yeah hopefully it will get a bit better in some time
Uhh idk why that would happen
Unless it’s getting the wrong application id
is it something to do with permissions?
Oh do u have the app commands Scope for the server?
Yeah
ok it works
how do u invite a bot from discord devealpor portal
because now i finding it hard
pls dm me if u know how to do it
Variables should be in snake_case, not mixedCase
Oh I see your issue
I don't know what that means
message_delete() is not a function of commands.Context
And unban() is a function, not an attribute
Can I see the code for the other command that it works for?
Yeah, assuming you didn't create a custom context by subclassing it
await ctx.guild.unban
.unban() is a function (a coroutine to be exact), not an attribute
Add ()
Right now you're just using it as a first-class function
You need to actually call it
can anyone fix my bot
If you provide code + error we can help you fix it
ok
Well yeah, how is it supposed to know who to unban
anyone know if discord is having issues, my bot is literally not doing anything upon typing commands
no error just nothing
Yeah, major API outage earlier today
It should be resolved by now though, check to see if your bot has message intents enabled
py bot.run(token, bot = True)
i legit made a simple ping bot and reset its token
It says exactly what the problem is, go to your dashboard and enable the privileged intents
to check if it was my code
Code please?
its still doing nothing rn
on discord develpor
It's either you're missing message intents or the API still hasn't recovered fully
Yes, from the dev portal
where is it
Where are you providing ID?
my code was running perfect and bam nothing now so i think its api but to double check what do you mean message intents
!d discord.Guild.unban
await unban(user, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Unbans a user from the guild.
The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to do this.
nvm found it
Sure, but you need to specify in the code
Right now you're just telling it "unban from guild"
The little check box on the dev portal that actually sends messages to your bot
alright cheers sorry about that
Without it, your bot doesn't know when someone sends a message, so obviously, none of the commands will work
i just enable it why is this happening
It's a new "feature" meant to motivate people to switch to slash commands
Can you send a screenshot of the enabled intents on the dev portal?
I know, you need to pass in a snowflake object to discord.Guild.unban()
You can create your own snowflake object like so:
my_snowflake = discord.Object(...)
!d discord.abc.Snowflake
class discord.abc.Snowflake```
An ABC that details the common operations on a Discord model.
Almost all [Discord models](https://discordpy.readthedocs.io/en/master/api.html#discord-api-models) meet this abstract base class.
If you want to create a snowflake on your own, consider using [`Object`](https://discordpy.readthedocs.io/en/master/api.html#discord.Object "discord.Object").
No prob, new feature not everyone knows about it yet
Ok, ping me if you need further assistance
assuming upon enabling i dont need to do anything else just re run my bot
Well, make sure your intents within your code is set up properly as well
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
what a stupid change lmao
For testing discord.Intents.all() works but in production it's best to limit the intents to what you only use to reduce computational strain on the machine
ahh it off i turn it on and run it
they want people to use slash commands ¯_(ツ)_/¯
my bot has raw_reaction_add and i set it so when i reacted to a certain message with an emoji, it would give me a role. But i only reacted one and unreacted then, and it sent me THESE many messages!
no, i don't have the bot running on parallel
Code?
@commands.Cog.listener()
async def on_raw_reaction_add(self, payload):
data = reacting.get((payload.guild_id, payload.message_id))
if type(data) == tuple:
pass
else:
return
if str(payload.emoji) == data[1]:
guild = await bot.fetch_guild(payload.guild_id)
member = await guild.fetch_member(payload.user_id)
role = guild.get_role(data[0])
await member.add_roles(role)
try:
await member.send(f'You got the **{role.name}** role in **{guild.name}** for reacting!')
except (discord.HTTPException, discord.errors.HTTPException, discord.ext.commands.errors.CommandInvokeError,
commands.CommandInvokeError, commands.CommandError, AttributeError, discord.Forbidden):
print(f'Cannot direct message {str(member)}')```
i tried restarting it on heroku but to no avail
light mode 🤦♂️
How about the part where it removes the role?
@commands.Cog.listener()
async def on_raw_reaction_remove(self, payload):
data = reacting.get((payload.guild_id, payload.message_id))
if type(data) == tuple:
pass
else:
return
if str(payload.emoji) == data[1]:
guild = await bot.fetch_guild(payload.guild_id)
member = await guild.fetch_member(payload.user_id)
role = guild.get_role(data[0])
await member.remove_roles(role)
try:
await member.send(f'You lost the **{role.name}** role in **{guild.name}** for unreacting!')
except (discord.HTTPException, discord.errors.HTTPException, discord.ext.commands.errors.CommandInvokeError,
commands.CommandInvokeError, commands.CommandError, AttributeError, discord.Forbidden):
print(f'Cannot direct message {str(member)}')```
Let's not derail the conversation, please
ight
reacting_data is a dict like {(guild_id, message_id): (role_id, emoji)}
I see
when i run it locally it doesn't happen
weird question, but i install pycord since i was gonna move over to that instead of discordpy, could that be the issue maybe
No, this is a discord thing. Also why move from discord.py?
That's odd, try printing at the top of the event to see if it prints multiple times
well i was thinking since all the issues of it being discontinued etc
okay
That way we can trace it down to a code issue vs something on discord
It's not discontinued
Well at least not anymore
thats what i mean
No, I mean, it was back as of yesterday
he could just dip again if you know what i mean
Oh I see
Yeah fair reason, I don't know about pycord though. I'm not gonna tell you which fork to use or which not to use, but regardless, your fork of choice is not the issue
This is something discord implemented
i think its a discord issue tho i literally just tested
import discord
from discord.ext import commands
from discord import Intents
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix=".", intents=intents)
@bot.command()
async def ping(ctx):
await ctx.send("pong")
bot.run('token')
Bots under 75 guilds need to explicitly enable message intents on the dashboard or the events won't be dispatched to your client
i made a new file and this didnt even work either so i think its just a api issues for me rn
You need intents.message_content = True
now my bot should print added when on_raw_reaction_add is run and removed when on_raw_reaction_remove is run
let me start it up
And hopefully it doesn't spam "removed"
oh 🤦♂️
Cross your fingers and run it
(still underage tho)
class discord.Object(id)```
Represents a generic Discord object.
The purpose of this class is to allow you to create ‘miniature’ versions of data classes if you want to pass in just an ID. Most functions that take in a specific data class with an ID can also take in this class as a substitute instead. Note that even though this is the case, not all objects (if any) actually inherit from this class.
There are also some cases where some websocket events are received in [strange order](https://github.com/Rapptz/discord.py/issues/21) and when such events happened you would receive this class rather than the actual data class. These cases are extremely rare.
x == y Checks if two objects are equal.
x != y Checks if two objects are not equal.
hash(x) Returns the object’s hash.
Pass the ID from your command to the snowflake
Or just typehint to snowflake and pass it in directly (easier method)
@bot.command()
async def someCommand(..., snowflake: discord.abc.Snowflake, ...):
...
await ctx.guild.unban(snowflake)
...
Yikes uh
could it be because im getting good ping?
Doubt
17 ms
mixedCase 🗿
alr
too much javascript oopsies
You still need to specify which member to unban
Also why does your command take in both a user and an ID
All it needs to take in is a snowflake
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
@sick birch i appreciate that man i was pissedddd trying to understand what was up
Why do you need both a snowflake and an ID...
the snowflake is the ID
wait hold on let me check the docs to see if you can actually typehint to snowflake
oops guess you can't
@bot.command()
async def someCommand(..., user_id: int, ...):
...
snowflake = discord.Object(user_id)
await ctx.guild.unban(snowflake)
...
Then take a user param that's type hinted to discord.User?
That would work too
await unban(user, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Unbans a user from the guild.
The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to do this.
except only the ID would realistically work
if the user was banned (they would be if you're unbanning them) then you can't mention them, and the bot won't be able to see their name and discrim
Sure but almost everyone uses an id to ban/unban anyway
Again, you don't need snowflake
You only need the ID
Yes
async def unban(ctx, user_id: int):
...
The icons?
!d discord.Guild.icon
property icon```
Returns the guild’s icon asset, if available.
hey i fixed it
turns out in the cog i needed to do @commands.Cog.listener("event_name_here")
thanks @sick birch
Thanks discord
very cool
imagine
message is a str it must be a Message obj
which you forgot the positional argument for the Context obj
how do i fix
you add ctx in params and you do
await ctx.message.delete()
like that?
its a positional argument it must be first as its the context of the invoked command
so what would the message be
ctx needs to be the first argument
and argument naming lol
ctx.send
icon = ctx.guild.icon_url
embed.set_thumbnail(url=icon)
await ctx.send(embed=embed)
ctx, member: discord.Member, *, message
:))
no?
is there a reason im not getting the attribute icon_url when using that?
!d discord.Guild.icon
property icon```
Returns the guild’s icon asset, if available.
not sure if icon_url is a method
That's before 2.0. Remember, the asset object was added in 2.0?
i could have swore i had it working earlier
so i need to use the class discord.asset?
ah
it just puts erros
what would i use then
this?
where
i fixed it nvm
how would you change buttons when a button is pressed
You change the buttons label, style, disabled etc and then edit the message with the view
So just have a new view?
Hi can someone help me set up to check the users age and like saving it on deta am using deta
!d discord.User.created_at
property created_at```
Returns the user’s creation time in UTC.
This is when the user’s Discord account was created.
no not that
Oh then what?
do you want the users actual age?
That’s not accessible
https://paste.pythondiscord.com/irumuposeb check this
Yeah I don’t even know if a user can check their own age
how would you edit a view instance?
Man i should of not put button aside for learning later fuck
okay thanks for the help
okay i think i know how to change the view inside a button but ive still got no clue about changing components inside the view
can you give like an example on how to change components inside the view
examples/views/ephemeral.py lines 28 to 34
if number + 1 >= 5:
button.style = discord.ButtonStyle.green
button.disabled = True
button.label = str(number + 1)
# Make sure to update the message with our updated selves
await interaction.response.edit_message(view=self)```
View has a property children which are all the components in a view
i want to make it so that when a paerson uses a commdn, the bot will send a message and react with an emoji, then if the user reacts with the same emoji it will edit the message. how should i do this?
wait_for() would be good for handling the user's reaction
just use buttons and wait_for
i dont know how buttons work, could you send me a tutorial?
lib?
depends on the buttons implementation you have
i dont know how anything related to buttons works
^
what do you mean lib?
what library are you using
the dpy master branch has support for message components (buttons)
if you havent installed it but you're willing to make changes to your bot, you can read the migration guide here https://discordpy.readthedocs.io/en/master/migrating.html and run pip install git+https://github.com/Rapptz/discord.py
!code
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.
Code its to big for discord :(
use hastebin
!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.
@hushed galleon im following a tutorial for buttons and it says to put from discord.ui import Button, View but i keep getting an error saying that discord.ui isnt a thing
you need 2.0
.
huh?
if you havent installed it but you're willing to make changes to your bot, you can read the migration guide here https://discordpy.readthedocs.io/en/master/migrating.html and run pip install git+https://github.com/Rapptz/discord.py
examples are good as well
yeah the examples on the github demonstrate how to use buttons pretty well
i dont know my way around github
they can be better
never used it before, where do i go?
why does this dont work? it has no error it just doesn't kick or ban the person who creates roles
https://github.com/Rapptz/discord.py/blob/master/examples/views/confirm.py#L24 they check the value with if statements when an interaction can send msgs
examples/views/confirm.py line 24
self.value = None```
.
they do use the interaction to respond to the user, the value is just there to demonstrate how it can be combined with commands for reusable code
thats just useless
your exception is eating the error
showing how to get the user's response with buttons in a command is useless?
not what i ment
so do I remove except:
or what do you mean by that?
why do you even have a try and except
checking a value of an instance variable to respond on a button press yikes
i mean in the examples its just to print what has been pressed but thats just useless tbh you can just do it on callback
implementing a callback would be more complex/messy than just checking a boolean, which i see no problem with
how is implementing a callback complex?
the try: on the start of the event?
yes why do you have them
then checking the value of the variable with multiple buttons yikes
hmm i dont know, didn't realise that until you told me
also what about except: pass do I remove that too?
yes
yes since you're also removing try
if you remove try you should automatically remove except
well there's two ways you can program that callback, either you code it inside the View itself which means losing reusability or at least having to subclass Confirm every time, or you pass the callback as an argument to Confirm which means defining an inner function in your command
4 hours downtime 
what happend
Russia do be DDOSing Discord
thats a f
"Last night" depends on timezone 💀
either way the code is no longer straight-forward, you have to jump around when you're reading it to figure out what it does
8 hours ago
I was sleeping that time
double indentation 
subclassing View isnt really hard and is easy and better as you can do anything on the callback like send ephemeral msgs, so you wont need to to check booleans all the time
you didn't unindent it correctly
the edits always make me look akward 💀
you just removed try and except and hoped it worked
and if you want to use the confirm for a dozen different commands, you're fine creating a dozen different subclasses? also you can just store the interaction as an attribute and access it from the command itself
yeah i should not be in discord helping people while im doing my science quiz
how to make it so bot detects when a user adds a specific reaction
confirm by?
to delete the message
the confirmation view
@slate swan remember that person Surgy who was becoming a pain last night?
wait_for() if you're doing this inside a command
wait_for(what here?)
💀
lets you do a one-time listener for a certain event and also add a check for it
!d discord.Client.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.10)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.10)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
yes
if you open that documentation there's an example on using it to listen for a reaction
Lmaoo was gonna report him to @novel apex but by chance, at the fricking exact time, Discord API went boom boom lmao
one time?
doesnt it dispatch many times until an event meets the requirement?
But wait_for will return ONLY once
yeah but i ment on like getting dispatched lol
yeah that happens
I still remember when I thought @bot.event() was what wait_for message was doing 💀
I put a bot.event inside a command
same
ye that happens a fair amount
Haha basically that's what it's doing
its not working, but i gtg in like 5 minutes so ill probably just do without for today
oh and if you wanted to avoid checking a boolean you'd need two callbacks for both responses, even more work compared to the if-statement
you would still need 2 callbacks to change the boolean
i got 32/33
but at least you wouldnt have to modify them for every command
just have one single Confirm class that handles getting yes/no from the user, and let the commands do what it pleases with that response
if its a class that will be used for many commands then just check boolean but thats not quite what theyre showing
they're combining the send_message with checking inside a command, but i think it's still understandable while serving two purposes
though thats just our opinions now
yes but theyre using booleans to just print strings when you can do it on the call back and its not quite a good example as on each interaction youll need to stop the view from listening to an interaction so its not really showing how to use buttons that are reuseable
the class is reusable, i could use that exact confirm class in an entirely different command and have no issues with it
oh sure
yes its a confirm class but idk if that should be the way of showing the example idk
i.e the value variable is kinda useless as you can print the strings in the callback
¯_(ツ)_/¯
@slate swan what the sus is going on
the design shows that you dont need to hardcode your prints or other complex code into the class itself
yeah but efficiency lol
i mean, im speechless now so you have a point
but yes presenting wise you are correct but i like my performance
this quote from Raymond Hettinger i still remember in reference to using keyword arguments: "it slows down your code a bit, but really what are you trying to save, microseconds, or hours of programming time?"
👉 hours of programming time

its in this pycon if you're wondering https://youtu.be/OSGv2VnC0go
maybe a bit off topic now 
lol
#Our Package
from email import message
from functools import _Descriptor
from turtle import color
import discord
#Client
client= discord.Client()
@client.event
async def on_ready():
#Do Stuff
general_channel=client.get_channel(844067710152605719)
await general_channel.send("We make you fun")
@client.event
async def on_message(message):
if message.content ==">version":
general_channel=client.get_channel(844067710152605719)
myEmbed=discord.Embed(title="Current version",description="The bot is in beta 0.1", color=0x00ff00)
myEmbed.add_field(name="Version code",value="beta0.1",inline=False )
myEmbed.add_field(name="Date released/New Update Time:",value="9 March 2022 ", inline=False)
myEmbed.set_footer(text="This is a sample footer")
myEmbed.set_author(name="Float Water")
await general_channel.send(embed=myEmbed)
await client.process_commands(message)```
File "c:\Users\HP\Desktop\My music,and game\python test\Energy_bot.py", line 3, in <module>
from functools import _Descriptor
ImportError: cannot import name '_Descriptor' from 'functools' (C:\Users\HP\AppData\Local\Programs\Python\Python310\lib\functools.py)
Any error?
you cant import it lol and dont make a request on ready and use the command ext
And don't use mixedCase for variable names. They should be named with the snake_case convention
I would highly suggest you ditch whatever tutorial you're watching
It's very, very bad
I have a problem
button = Button(label="Click rn ", style=nextcord.ButtonStyle.green, emoji="🤣")
async def button_callback(interaction):
await interaction.response.vc.stop
await interaction.response.send_message("hey guys never gonna give you up!")
button.callback = button_callback
view = View()
view.add_item(button)
await ctx.reply(embed=embed, view=view)
this is a button
so i wanted it so that when the button is clicked, the music would stop playing
but
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\nextcord\ui\view.py", line 359, in _scheduled_task
await item.callback(interaction)
File "c:\Users\Admin\Downloads\test\main.py", line 47, in button_callback
await interaction.response.vc.stop
AttributeError: 'InteractionResponse' object has no attribute 'vc'
@maiden fable
@worldly bane
sory for pings just need an answer
inter.response.vc isnt a thing
ignore if you wanted the answer from them
wdym?
@cosmic agate ^ basically the error
ikt
it does not exist
but i need a button where on button click it should vc.stop
that whole line gave me a stroke
inter.guild.voice_client.stop()
is a thing iirc
so if i add that will that work?
cant solve that by asking, try it

I like how that emoji's name is "dog3"

i changed inter to interaction and it works!
what......
this

it doesnt matter its just argument naming bruh
i got error
undefined
thats why i change
ig he used interaction, but that says inter, so he just shared 

smh
yeah thats was my situation
just change it to interaction
i did
yes you can use t for pause and resume, just change the methods
role = message.guild.get_role(943243423446605834)
buyers = len(role.members)
print(buyers)
y this code returning 0?
because it doesnt return anything
how would i get the number of users with a role then?
like that lol
but i have over like 30 members with the role, y isnt it working then
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
thank you so much

so how did this message got pinned #discord-bots message 
welchannel = client.get_channel(950922040729288756)
await client.edit_channel(welchannel, "WORKS!")
y does this code error?
im using a on message event to fire this
so it only runs if fired unde certain args
show error
hey so i just switched over to hikari and im trying to make a message to send when a member joins the server. i run the code shown but i get an attribute error for respond.
async def memberJoin(ctx):
await ctx.respond(f'Thank goodness {users.User} has joined {guilds.GatewayGuild}')
@client.listen(hikari.MemberDeleteEvent)
async def memberRemove(ctx):
await ctx.respond(f'Thank goodness {users.User} has left {guilds.GatewayGuild}')```
@quick gust ```py
Ignoring exception in on_message
Traceback (most recent call last):
File "/home/runner/AutoPurchaseHandler/venv/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 41, in on_message
await client.edit_channel(welchannel, "WORKS!")
AttributeError: 'Client' object has no attribute 'edit_channel
context has no respond attribute. Make sure it exists
it can
huhhh
ask sift 
!d discord.TextChannel.edit use this method on a TextChannel object to edit a channel
await edit(*, reason=None, **options)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the channel.
You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.
Changed in version 1.3: The `overwrites` keyword-only parameter was added.
Changed in version 1.4: The `type` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead...
no
this man really said no to himself
exactly 
also ashley that method could only be used on non-bot accounts which discord doesn't allow anymore
keyle tht doesnt rlly help me, i cant figure out how to change the channel name
which the ClientUser.edit iirc
no
which of all
every method which is considered self-botting
name them all
- get an instance of a channnel
- edit the channel instance using the
edit()method
No. You can find them yourself just go on d.py's 1.7.x docs
Ignoring exception in on_message
Traceback (most recent call last):
File "/home/runner/AutoPurchaseHandler/venv/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 40, in on_message
welchannel = bot.get_channel(950922040729288756)
NameError: name 'bot' is not defined
i get this error now
welchannel = bot.get_channel(950922040729288756)
await bot.edit_channel(welchannel, "WORKS!")
heres the code
well is bot and instance of the Bot class?
Its using a in message event
you havent quite answered my question
Would u like me to send the repl link thats hosting the bot?
No.
Yes the actual age saved into the db and that age would be revealed in the profile embed
And btw if i am putting a embed field would my value be Age?

intents = Intents.default()
intents.members = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print("Ready! and logged in as {0.user}".format(client)
@slate swan this is the sttartup code im using
format 
bot isnt defined, as bot isnt an instance of the client and you got old code
then how would ichange the channel name if i cant use client then?
you're supposed to edit by doing ```py
welchannel = ...
await welchannel.edit(name=..., ...)
ooh
@boreal ravine now i get this errror ```py
TypeError: edit() takes 1 positional argument but 3 were given
80
Ignoring exception in on_message
Traceback (most recent call last):
File "/home/runner/AutoPurchaseHandler/venv/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 41, in on_message
await welchannel.edit(welchannel, "WORKS!")
TypeError: edit() takes 1 positional argument but 3 were given
welchannel = client.get_channel(950922040729288756)
await welchannel.edit(welchannel, "WORKS!")
theres the code
well you gaved it 3 positional arguments
^
This makes no sense to me
thaw do i put as the reason variable?
my smal; ass brain cant take this
- remove welchannel and the string
- insert a kwarg into the method ```py
def func(*, name):
...
func(name='discord-bots')
MY GOD
NOW I GET INVALID SYNTAX
welchannel = client.get_channel(950922040729288756)
await welchannel.edit(*, "WORKS!")
its nut a function cuz im using a on message event
https://replit.com/@MageGaming/AutoPurchaseHandler#main.py heres the repl code
you don't need *
even when i remove it, it doesnt work
do name='WORKS!'
yea because the method doesn't take any postional arguments, it only takes keyword arguments
does this mean that bots won't be able to reply anymore to commands if they're in 100+ servers or?
Can someone help me save the users age like this ?
if theyre verified and dont have the intent they cant see the message's content so it cant find the prefix but can respond to mentions but discord doesnt allow it so only slash commands would be good if you dont have the intent
- use a database, save the data
- query the database to find the user, get his/her data
yeah that lol
deta.sh?
But i dont really know how to set it it up to where it actually knows the users age
and stuff

- to setup deta in your application you can use this as reference: https://www.deta.sh/ (scroll down)
- to 'knows the users age' you gotta save the data first, then get the data
and i'm pretty sure bots can't get a users age IRL
its a age they input probably lol
yea
Use MongoDb, simply setup..
sql better
deta isnt hard to setup either, in fact its easier to use than mongo
pg sqlite etc so much to pick
wrong channel 😔

try ./requirements.txt
nah it doesnt work
weird
the file is literally in the same folder
idk why it doesnt work
try discord.py/requirements.txt
IS there docs for tha?
here right?
Ayeee it worked
but i got a second error
Path not found..
just restart your vsc and use ./requirements.txt
what would restarting do
thats a wrapper for mongo and they should use motor rather than pymongo because pymongo is synchronous
it would literally do nothing
also kayle the init file is in discord folder
alright then, why you even here if you dont wanna listen ;-;
I tried it already
it will not do anything if i reset
fine
and kayles one worked
ok
discord.py/__init__.py
ah yes i caught on to that
it did this then
now should discord.py v 2 work?
thats a warning lol
oh
try it and see I guess
try python -m setup.py .. or whatever the thing is
I dont understand this
can someone help me
Google is sooo bigg, try yourself..
Hi ya? Sorry I was in school
is it possible to use multiple tokens for different bot accounts in one py file
?
I mean if you use different names for the bot instance
Maybe?

yeah it is, just run an asyncio task

though its not recommended
sending requests from one ip, getting the ip ratelimited, resulting in downtime of all the bots
welp
Indeed
That's why replit sucks
@slate swan I always feel like yr pfp is a character from the movie Avatar istg

Seems like it hurted

Anyone know how I can make this into roles
Instead of channels
huh?
What do I change the channel.id to to make it roles
can someone help me im still learning how to make databases
im making a levelling system and i want it to delete the user information if they leave the server im using aiosqlite
message.author.roles will return a list of Role objects of the author
Instead of channels
Ok
Hi, Can someone point me to a wiki to handle exception in Slash commands?
Exception handling works fine but it fails in Slash commands
!d disnake.ext.commands.Bot.on_slash_command_error
await on_slash_command_error(interaction, exception)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The default slash command error handler provided by the bot.
By default this prints to [`sys.stderr`](https://docs.python.org/3/library/sys.html#sys.stderr "(in Python v3.10)") however it could be overridden to have a different implementation.
This only fires if you do not specify any listeners for slash command error.







