#discord-bots
1 messages · Page 309 of 1
The Pycord devs banned me from their server just bc they didn't include interaction checks on their Pycord support bot 😂
pycord moment
lmao
Show your code
just send what you tried and error that you get now and someone will help
how to start a thread with button interaction?
I have used this code and didn't work so i guess it is the wrong way
async def finalize_button_callback(interaction: discord.Interaction):
await interaction.channel.create_thread(name="New thread", message="Hello Thread")
this method does not take message param
!d discord.ForumChannel.create_thread
await create_thread(*, name, auto_archive_duration=..., slowmode_delay=None, content=None, tts=False, embed=..., embeds=..., file=..., files=..., stickers=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a thread in this forum.
This thread is a public thread with the initial message given. Currently in order to start a thread in this forum, the user needs [`send_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.send_messages).
You must send at least one of `content`, `embed`, `embeds`, `file`, `files`, or `view` to create a thread in a forum, since forum channels must have a starter message.
you are most likely looking for content
i want to start a channel thread not fourm theard
the documentation shows it takes message param
interaction failed unfortunately
in code error ..
no it didn't show any errors
are you having any error handlers
can you show the code
Share the code
Discord will show that if you don’t respond to an interaction within 3 seconds
sorry but i have crashed my device
one sec
class StartThread():
def __init__(self, client):
self.client = client
@app_commands.command(name="start_thread")
async def start_thread(self, interaction: discord.Interaction):
embed = discord.Embed(title="Thread creation", description="Press Button to start thread")
async def finalize_button_callback(interaction: discord.Interaction):
await interaction.channel.create_thread(name="New thread", message="Hello Thread")
finalize_button = Button(style=discord.ButtonStyle.green,label="Finalize")
finalize_button.callback = finalize_button_callback
view = View()
view.add_item(finalize_button)
await interaction.response.send_message(embed=embed, view=view)
actually that's pep 9001
Whats the error you are facing?
btw, this is a bit of a weird way to approach it. Common way is to actually subclass view, and use the decorators to add the button and register the callback
I have no errors in code it just tells me interaction failed
Then you likely have an error handler that is swallowing it
in the button callback you're not responding to the Interaction
that's why discord shows that error message to the user
yeah when adding await interaction.response.send_message("message") it sent the message but didn't create the thread
put this first and then await interaction.channel.create_thread(...)
it worked thank you
were do i download the python coding for making dicord bots?
from python.org or if you're on windows you can download it off the microsoft store
Nah bro just install from python.org
No there is only one
Python.org since the Ms store one breaks and doesn't work
Sure.
And just to get you started
- Before even attempting to create a discord bot, please learn python (
?tag lp) - To install discord.py, please run
python3 -m pip install discord.py(linux), orpy -3 -m pip install discord.py(windows)
If you wish to use voice functionality, please usediscord.py[voice]instead ofdiscord.py - Take a look at https://github.com/Rapptz/discord.py/blob/master/examples/basic_bot.py Mess around.
- When you start making your bot, use the commands ext: https://discordpy.readthedocs.io/en/latest/ext/commands/commands.html
or if you wanna use slash commands: https://gist.github.com/AbstractUmbra/a9c188797ae194e592efe05fa129c57f - The library documentation is available at https://discordpy.readthedocs.org/en/latest/
If you need help please make a post in our #985299059441025044 Forum if its related to Python and/or Discord.py
If you are migrating from the old version of this library (1.7.x) to version 2.X.X please follow the migrating guide https://discordpy.readthedocs.io/en/latest/migrating.html
Someone has a complex, yikes.
What
Test the Python interpreter and pip installed from the MS store and see if running Cython code works 🤷♀️
Chances are the C headers are not bundled
So you can't do #include <Python.h>
Finished? My point has been more than proven.
Tias
What was the exact discord message you sent?
Or is that from somewhere outside of discord?
no im just trying to filter out characters from a chat response to send it to a tts
Hi there?
sentence = sentence.replace("#", "") something like this.
I have hand on experience in tts and stt.
thank you this may lead to what im looking for
dont need help with tts / stt , i need help with special characters being generated in text lol
got it.
you can replace the special characters of result sentence to "".
understand?
nope
There is a better way
!d discord.Message.clean_content
i was about to ask how can i make this to replace multiple characters instead of just one
A property that returns the content in a “cleaned up” manner. This basically means that mentions are transformed into the way the client shows it. e.g. <#id> will transform into #name.
This will also transform @everyone and @here mentions into non-mentions.
Note
This does not affect markdown. If you want to escape or remove markdown then use utils.escape_markdown() or utils.remove_markdown() respectively, along with this function.
Regex
Gonna have to learn Regex to do that
hmm..
im having an issue with trying to read the custom status of a user
my current command is !activity_task @jaunty wren
@bot.command()
async def activity_task(ctx, member: discord.Member):
print(member.activities)
if member.activities == ():
print("No Activity Found")
else:
for activity in member.activities:
if isinstance(activity, discord.CustomActivity):
print(activity)```
is there a better way to do this?
this is the better way
sentence = sentence.replace("#6972395", "")
u can do this
sentence = "i like grapes"
keywords = ['#', '$', '%', '&']
for keyword in keywords:
if keyword in sentence:
sentence = sentence.replace(keyword, "")
Yeah, if it's multiple you can do something like:
import re
msg = "#123#!231$#"
new_msg, n = re.subn('[#$!]', '', msg) ##add what characters you need to change here. new_msg is the str and n is the number of character changed which you don't need in this case but you have to include it because subn returns an array.
print(new_msg)```
results: `'123231'`
ill give it a try
Replace only replaces 1 character at a time.
yes true
sweet this checks out thank you a lot
@potent light Do you have any idea about this?
For if member.activities == (): you can simply do if not member.activities:
Add prints below your loop:
for activity in member.activities:
print(activity.name, type(activity))
if isinstance(activity, discord.CustomActivity):
print(activity)
and see what you get.
You're welcome.
im going to test this thank you
okay so i ran the command and i got no result
Nothing showing on your CMD?
yeah
regex
problem solved w out regex
doesn't clean_content work for this?
there is a util to clean it out so pings are not effective
im not using discord.py, but i texted here cus ik discord bots have to deal with messages lol
pretty sure Message.clean_content does it
isnt that in a discord package? im not using discord packages
“discord.Message” yea im not using discord packages
ur using plain discord api then? no libraries like discord.py?
How can I add akinator in my bot
- Know how it works. Do some research on how that game works, and prototype an simple python game or hell even play with some friends
- Once you have your prototype and plans, implement it, and test it to make sure it works
- Ask questions or for help on the discord.py server or in #1035199133436354600 if you are stuck on parts or if you want to clarify parts that you are unsure of
My biggest tip is with prototyping, your best friend are quite literally a piece of paper and a writing instrument. In fact, whenever I'm designing features, I always jot my ideas down on somewhere (Case and point, just like the current feature that i'm working on). A game like Akinator are just simple steps for the game loop, and rules that you have to take account in. I would highly recommend not to directly copy the feature, but base it off. Play around with it and add your own quirks to it that make it unique compared to others
If you need help on implementing the discord portion, hop on to the discord.py server and ask questions and folks will be able to help you (I have provided a link if you need it)
!pypi akinator
make sure to use the asynchronous version
that package essentially a web scraper so if you wanted to, you could use it
I would personally do it from scratch
i mean if he could do it from scratch he wouldn't have asked here
it would take somw decent amt of skills to do it from scratch in maths and programming iirc akinator uses bayes theorem
good chance to pick up data structures and algorithms
fair
hi does anyone know how to configure google custom search engine and api? I'm having troubles with my image bot. Anything I ask it to display returns with"No image found"
you would have to get more specific than that with what trouble or error u are encountering exactly
basically for every single query i type, my bot returns with: no results for that query"
import discord
from discord.ext import commands
import os
from googleapiclient.discovery import build
import random
intents = discord.Intents.default()
intents.typing = True
intents.presences = True
bot = commands.Bot(command_prefix="!", intents=intents, help_command=None)
api_key = ""
@bot.event
async def on_ready():
print("!!! Bot Is Online !!!\n")
@bot.command(aliases=["show"])
async def showpic(ctx, *, search):
ran = random.randint(0, 9)
resource = build("customsearch", "v1", developerKey=api_key).cse()
try:
result = resource.list(
q=f"{search}", cx="", searchType="image").execute()
Check if there are any items in the result
if "items" in result:
url = result["items"][ran]["link"]
embed1 = discord.Embed(title=f"Here's Your Image ({search.title()})")
embed1.set_image(url=url)
await ctx.send(embed=embed1)
else:
await ctx.send("No matching images found.")
except KeyError:
await ctx.send("An error occurred while fetching images.")
try:
bot.run("")
except Exception as e:
print(f"An error occurred: {e}")
!code 🫠
can u send output of result also make sure its a valid api key
Thank you for the suggestion
np
i ran a test program and yes my api key is valid
Print result
Tbh in the first place it shouldn't even work as message_content is not enabled
yo do u remember me
how do i do that, my terminal just says that the bot successfully logged in
how do i enable it?
You know Python?
!intents
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.
There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.
Afterwards in your code, 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
# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.
Their lib uses v9 prob 😔
Actually it's because messages containing bot's mention have content available regardless of mc intent
Print is like first thing you learn in python
spoon feed code when
altho tbh google apis are sometimes a pain to work with
Especially if you are beginner
dang haven’t been here long time
only if you're lame
why learn print when discord bot
@client.command()
@commands.has_role(1156220704602194012)
async def dm(ctx, member: disnake.Member, text=None):
reciver = member
embed = disnake.Embed(title="Message", description=f"You have recived a message from <@{ctx.author.id}>.")
embed.add_field(name="Message below", value=text)
await reciver.send(embed=embed)```
So I made this command, It works and all but the text in my dm is only the first word nothing else. Please help
fr
Could you show the output?
Oh
I figured it out its fine
I just had to be like
async def dm(ctx, member: disnake.Member, *,text=None):```
man hit you with the thinking
How do I make a global error handler?
!d discord.on_error
discord.on_error(event, *args, **kwargs)```
Usually when an event raises an uncaught exception, a traceback is logged to stderr and the exception is ignored. If you want to change this behaviour and handle the exception for whatever reason yourself, this event can be overridden. Which, when done, will suppress the default action of printing the traceback.
The information of the exception raised and the exception itself can be retrieved with a standard call to [`sys.exc_info()`](https://docs.python.org/3/library/sys.html#sys.exc_info).
Note
`on_error` will only be dispatched to [`Client.event()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.event).
It will not be received by [`Client.wait_for()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.wait_for), or, if used, [Bots](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#ext-commands-api-bot) listeners such as [`listen()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.listen) or [`listener()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Cog.listener).
Changed in version 2.0: The traceback is now logged rather than printed.
if you're using the commands framework which is looks like you are:
https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.discord.ext.commands.on_command_error
Is there something like button_clicked event?
no
To add into bot.wait_for() not for listener
Does anyone here make money by making discord bots?
Premium subscription for bots?
Services.
So far I've paid for hosting but never earned a penny
Oh I don't think you got what I meant, what I really wanted to say is if anyone freelanced their bot making services to make money from here.
!rule pay
Oh I see.
you dont need to. discord.py already handles button internals like that for you
anything that you want to do when its pressed can be added in its associated callback
!d discord.ui.View.wait
await wait()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits until the view has finished interacting.
A view is considered finished when [`stop()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View.stop) is called or it times out.
im not sure if this is what he wants

he asked earlier if that was such thing called as "button clicked" event that he can use for Bot.wait_for() so hes trying to listen to for when the button is clicked to do something with it. views already do all of that for you as far as listening for button clicks. following execution is done within the buttons callback(which the library will also call for you as well when the button is clicked)
i thought he maybe wanted something similar like wait_for which is can be done by using view.wait() and stop the view when button is clicked dunno why he wants like that though, he can just use the button callback
hmm my bad xd
Let's just say in simple words i have 3 buttons they have alot of functions inside but only 1 function is different so i just thought maybe i could use that listener and use if custom id statement when it comes to that function
the different code for that single button that’s also different from the others would still be executed in the button's callback
!d discord.ui.Button.callback
await callback(interaction)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
The callback associated with this UI item.
This can be overridden by subclasses.
@commands.Cog.listener()
async def on_reaction_add(self, reaction:discord.Reaction, user:discord.Member|discord.User):
if reaction in self.reactions.keys():
# Add roles to user...
I am trying to make a dictionary and then have the keys be the emojis and then the lambda function be the function to get a role object, could someone remind me how to use search for a key in a dictionary and then extract the lambda function as I have forgotten... 🤦♂️
!E ```py
reactions = {"a": lambda x: x+1, "b": lambda x: x+2}
for case in ("a", "b", "c"):
if case in reactions:
print(reactionscase)
else:
print(f"Key {case} not found")
@slate swan :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | 11
002 | 12
003 | Key c not found
^
Can i ask question about telegram bots there?
Idk what they are so you would be better off asking the question in a dedicated community
ok thanks:(
as long as its related to python you can ask in #1035199133436354600 but this channel is especially made for discussions about discord bots
What do i do wrong
you can't access self inside that decorator
Anyone know how I can create a dropdown menu within an embed using discord and discord.ext
Okay, how'd I go about doing that then?
This is passed from another class so the button_one has to go in there
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.
?
Its the full code
and what do i need this for
To show i did it already
i dont see you creating a custom button class
There it is
class TicketMain_One(nc.ui.View) or not?
thats View ?
Its the same in nextcord
what does it has to do with nextcord
nc.ui.View and nc.ui.Button Is equal
oh really how is that
https://github.com/Rapptz/discord.py/blob/master/examples/views/tic_tac_toe.py#L10-L58
thats a custom button class
https://github.com/Rapptz/discord.py/blob/master/examples/views/tic_tac_toe.py#L84
and thats how to add it to View
examples/views/tic_tac_toe.py line 84
self.add_item(TicTacToeButton(x, y))```
Okay and how do i do it if i would like to have 2 Buttons
i guess you add two buttons
!rule 9
What's the max amount of reactions that I can add to a singular message?
wanna help
Pretty happy with my discord transcription bot. Joins whatever server you're in when you summon it and continously outputs a transcript from openai's whisper until its stopped
ah bruh. it pings you everytime it transcribes one of your messages
i’d surpress those ngl
I'd block the bot
Gonna need some code review
Why won't you count yourself
Apparently it's 20
LMFAO
Hello, I have a quick question. How can I make excluded roles for cd? I tried to do it through GPT code, but it didn't work. Maybe you know?
!d discord.ext.commands.dynamic_cooldown
@discord.ext.commands.dynamic_cooldown(cooldown, type)```
A decorator that adds a dynamic cooldown to a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command)
This differs from [`cooldown()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.cooldown) in that it takes a function that accepts a single parameter of type [`Context`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context) and must return a [`Cooldown`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Cooldown) or `None`. If `None` is returned then that cooldown is effectively bypassed.
A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.BucketType).
If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CommandOnCooldown) is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.discord.ext.commands.on_command_error) and the local error handler.
A command can only have a single cooldown.
New in version 2.0.
Oh, sorry, forgot to mention I have a disnake)
!d disnake.ext.commands.dynamic_cooldown
@disnake.ext.commands.dynamic_cooldown(cooldown, type=BucketType.default)```
A decorator that adds a dynamic cooldown to a [`Command`](https://docs.disnake.dev/en/latest/ext/commands/api/prefix_commands.html#disnake.ext.commands.Command)
This differs from [`cooldown()`](https://docs.disnake.dev/en/latest/ext/commands/api/checks.html#disnake.ext.commands.cooldown) in that it takes a function that accepts a single parameter of type [`disnake.Message`](https://docs.disnake.dev/en/latest/api/messages.html#disnake.Message) and must return a [`Cooldown`](https://docs.disnake.dev/en/latest/ext/commands/api/checks.html#disnake.ext.commands.Cooldown) or `None`. If `None` is returned then that cooldown is effectively bypassed.
A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://docs.disnake.dev/en/latest/ext/commands/api/checks.html#disnake.ext.commands.BucketType).
If a cooldown is triggered, then [`CommandOnCooldown`](https://docs.disnake.dev/en/latest/ext/commands/api/exceptions.html#disnake.ext.commands.CommandOnCooldown) is triggered in [`on_command_error()`](https://docs.disnake.dev/en/latest/ext/commands/api/events.html#disnake.ext.commands.on_command_error) and the local error handler.
A command can only have a single cooldown.
New in version 2.0.
@meager orchid
but what pleasure do u get from building bot with gpt 😭
Thank you
It's not that I'm creating a bot via GPT, it's more like I'm trying to find out what I don't know. And when it doesn't work, I go to github or forums for help. And so I try to write a bot myself and study documentation
Try debugging a code made with gpt and you'll see the pleasure
Antipleasure
https://education.github.com/pack#offers
oh my this is too much which is the best host
I got my application denied cause of billing info
Idk what I put there, apparently something idiotic for 0$ purchase
just need to put in ur full irl name there
i got mine approved
still have to wait tho
Guys is azure cloud a good service for hosting discord bot?
no
Henzter is
The major issue with Azure is that it's entirely useless in the scope of a dbot unless you use services that are exclusively tied with Azure (say you need to use MSSQL for instance). This is also same for AWS and GCP. The other major issue is that you are paying huge sums of money. I had $100 free azure credits and within 3 weeks of just running my discord bot on an container instance, I already broke past that $100 free credit range. Once that free credit is over, now azure has you on the hook, and can shut down your service at any moment without notice
We can't use AWS too if we are student
you can't
this is why I strongly recommend purchasing an server from an VPS provider. My pick is Henzter, which is where my production bot is running as of now. Good quality service, strong background checks and good provider
💳
but... if you are a student, then look into the GH student developer pack
They all need a credit card tf
that offers $200 free digitalocean credits for free for 1 year if you are a student
They dumb tbh why would a student have a credit card , lol
Thats just in the context of the openai request, simple change to take it out. On its own openai just writes the nickname of who its transcribing
that is for verification. you dont need an credit card, but a debit card will work
I dont have any sadly
i've traditionally used my debit card and it went through
then GL. Either pay up, self host, or use the student deals available
those are the three options you have
Does it just need a student email?
yes
Awesome thanks
you will also need an valid proof of education
so just send them like a report card or your student id, and it should be fine
Perfect
Most GitHub education features aren't used by students like digital ocean, etc
well the DO deal is there
use it while you can
Wdym by DO?
how to get embed message
DigitalOcean
Thats needs a credit card
then if you dont have it, you are essentially locked out
it's used for verfication purposes
embed message?
Idk why they need credit card even I they don't need it
There are multiple other methods for verification
so you dont create 100 accounts
again, verfication. AWS requires it. Azure also, GCP as well
if you have to verify by card you can only have one account
cause you can have 1 card most likely
as mentioned, it's to prevent mass spam attacks
Azure didn't ask me for credit card
I have bot.wait_for and when the message sent it send it to me but when the message have an embed the bot tell me the message is empty
bc Azure did an SSO so it already knows from your school that you are a valid student
code?
Wdym by sso?
Single Sign On
Oh
message = await bot.wait_for ....
await channel.send(message)
Something like this
Then why can't digital ocean?
they aren't mircosoft and they dont work with the educational system to provide it
and it sends empty message or what
say error
their main consumers are actually not students
mean it cant send an empty message
did you try printing it?
I can't sadly use any benefit of GitHub education then
I will try now and show the resault
then your next best option would be to self host using a raspberry pi or a spare pc that you can turn into a server
and then after that, there is none
I cant find a tut online that works
can someone coach me through buidling a discord bot? Big ask i know aha
jesus christ that was quick
i swear you don't need a third-party tutorial
but im just as confdused when i meet this
example code snippets how to do things
....
- Before even attempting to create a discord bot, please learn python (
?tag lp) - To install discord.py, please run
python3 -m pip install discord.py(linux), orpy -3 -m pip install discord.py(windows)
If you wish to use voice functionality, please usediscord.py[voice]instead ofdiscord.py - Take a look at https://github.com/Rapptz/discord.py/blob/master/examples/basic_bot.py Mess around.
- When you start making your bot, use the commands ext: https://discordpy.readthedocs.io/en/latest/ext/commands/commands.html
or if you wanna use slash commands: https://gist.github.com/AbstractUmbra/a9c188797ae194e592efe05fa129c57f - The library documentation is available at https://discordpy.readthedocs.org/en/latest/
If you need help please make a post in our #985299059441025044 Forum if its related to Python and/or Discord.py
If you are migrating from the old version of this library (1.7.x) to version 2.X.X please follow the migrating guide https://discordpy.readthedocs.io/en/latest/migrating.html
i would recommend checking the basic_bot.py
I know python fine, the whole thing just hurts my brain abt discord bots
then how much do you know?
Enough for basics, on a scale of one to ten, 4 or 5
We can , but what's your experience with python?
that's pretty weak
Have you studied async programming?
thanks 👍
you need topics like async await syntax, OOP and decorators to really understand what you are doing
erm cant say i have particularly
i mean if you understand OOP and async/await syntax you'll probs be fine
ill get learning 🙂
*cries*
- Primitive data types
- Operators
- Data structures
- Importing
- Variables, namespace and scope
- String formatting
- OOP
- Control flow
- Exception handling
- Function definitions
- Classes, objects, attributes and methods
- Console usage, interpreters and environments
- Decorators
Useful to know:
- Asyncio basics
- What is blocking?
- Logging
- knowing how to read docs properly
``` for more details see <https://gist.github.com/scragly/095b5278a354d46e86f02d643fc3d64b#required-knowledge>
Then you should learn and next you are ready to go! Best of luck
here are the concepts you need to know btw
Thankyou all!
Tbh discord bot building is boring
My coding expertise lies in HTML/CSS/(a bit of)JS
you'll also want to include SQL as well
only js from these is actually programming 🤫
😭
Ye lol
it gets that way after the first 3-4 
if you dont have end goal in a bot development never ends
I just need aa basic one that has embeds tbh not epic features
Actually we don't need to build discord bots as mostly bots exist with better features, making for own learning is another topic
surely css is almost coding
<Message id=1159428277644038204 channel=<TextChannel id=1154125126313463889 name='ticket-39-swesra' position=7 nsfw=False news=False category_id=1135214901443432618> type=<MessageType.reply: 19> author=<Member id=1156254486403235850 name='SwesRa' global_name=None bot=True nick=None guild=<Guild id=1130898038639054940 name='SwesRa Host.' shard_id=0 chunked=True member_count=7353>> flags=<MessageFlags value=0>>
thats when I printed the object but when I print the content its print empty raw
the blogs on Google mostly misguide people about discord bots
Especially hosting bot on replit
oh my days
then you have message_content disabled
every tut on google
said replit
dont use replit for hosting a bot 
cuz thats embed
if the message have text it will print it
I left making discord bots after that
embed is not under content
🤣
!d discord.Message.embeds
A list of embeds the message has. If Intents.message_content is not enabled this will always be an empty list unless the bot is mentioned or the message is a direct message.
even the workshop lead in our college classes had us use a web-based IDE and idk why
me and my buddy refused 🥴
Thats fine

this show this
[<discord.embeds.Embed object at 0x0000026F90CAD5A0>]
And?
yes its a list of Embed objects
!d discord.Embed
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
x == y Checks if two embeds are equal.
New in version 2.0...
you can get whatever you want from it
Btw can we have some chat in #ot0-psvm’s-eternal-disapproval ?
its not coding
can you give me example please?
why not 😡
Thats designing:
i don't see any use for them in the context of teaching whatsoever though
but we're getting off-topic probs
I wonder why I can't create an OS using CSS
Ye lol , anyway mostly people don't use replit for what it is meant for
example of what
stop editing inspect element!!!!
jokes aha
You can but only beautiful fruit that is hollow inside
blud knows inspecting elements
😂
how to get the anything from embed
when I get it in wait_for
It's just accessing attributes like any other objects
embed.some_cool_attribute ?
await ctx.send(message.embeds)
I have this
You can log the attributes and see?
how to get the content from this
Get an embed of the list then get something from the embed 🤷
i dont know what you mean embed content but you just access attrubute on embed object
lel i got copilot just so i could ask it this one question and its trolling me so i'll ask here instead. I have
step of process
else
break```
In front of every step (4 steps) of this loop, and because these steps can take considerable time (or waste considerable time if we let any go after it should stop) we have to recheck the condition between each step, since the stop flag could be thrown at any point and we want the loop broken before any more statements execute
If you don't know then learn?
thats why im asking...
Learn and come here, we will surely help you but you should know the basics of async , etc many topics
The last two if statements are useless
If the first one fails, it will break the loop before those two are executed
Unfortunately the code after the first one can take a long time and the flag can change between then (and usually will) so those extra if statements save time
The problem is mainly the asyncio.sleep() separating the code (the 15 seconds to give it time to record a batch of audio, and then 2 seconds to give it processing time after) that we do not want to execute if the flag changes. But if we only check the flag at the beginning of the loop all these sleeps will execute before the final stop is called and the bot leaves, making it feel unresponsive. to get around this i put a check before each step, but it seems ugly and not the best way.
ye i know , sorry i misunderstood,i thought you mean you don't know
i am really sorry for it
I apologize too, i ate some breakfast and it wasnt that big of a deal lol😆. i just was a bit frustrated after trying to explain to copilot why it wasn't fixing anything by making 2 identical loops lol
Im being dumb, this is fine it just shouldnt have the breaks anywhere so that the stop is still called, the sleeps just need to be skipped over if we exit early. it looked bad at first so i felt like i was doing something wrong
better
guys
I'm trying to start my journey learning how to make discord bots, however when I go into the console and type pip install discord, it goes through and tries to download it, but then at the end get's this error.
here, take a look.
it says your error like 4-5 different times
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
People when the extremely new python version doesn’t work perfectly: 😱
Downgrade to 3.11, you don’t need 3.12
aiohttp is just broken with 3.12
People need to downgrade and wait until the lib is updated
how are you sure that 3.12 is the problem?
Because there have been an insane amount of bug reports, and all the people are using 3.12
What does your bot say
Oh yeah
or that
you need to disable the internal help cmd
set help_command to None
when you create your bot object
Discord.py creates a help command automatically
!d discord.ext.commands.Bot.remove_command
remove_command(name, /)```
Remove a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command) from the internal list of commands.
This could also be used as a way to remove aliases.
Changed in version 2.0: `name` parameter is now positional-only.
personally i like to set it to None on startup when you initialize your bot class
You can just set that to None
In the bot's constructor, set help_command to None
its like i dont speak english or sum when i say these things
No harm in clarifying things
not at all.
Have u made discord bots
only on certain days 
did you ever even fix this
by awaiting the ctx.send()
as a tip, saying "its not working" or anything along those lines isnt a very productive phrase. generally, in help channels like this, you want to be as precise as you can.
if you have any errors for example, those should be posted here as well with your issue
fair enough
💀
then practically you didn't ask for help
seriously.. you join an online community full of enthusiastic developers eager to help others on their spare time and your response is this when you're suggested to be more pedantic and precise when asking for help? grow up.
You’re infinitely more likely to get help by describing the issue, than just saying it doesn’t work
This is explicitly listed in the help guide
self.button_one_label = nc.ui.TextInput(label="Button 1 (Blue)", style=nc.TextInputStyle.short, max_length=50, required=True, placeholder="Contact Staff")
self.button_two_label = nc.ui.TextInput(label="Button 2 (Red)", style=nc.TextInputStyle.short, max_length=50, required=False, placeholder="Report Member")
self.button_three_label = nc.ui.TextInput(label="Button 3 (Grey)", style=nc.TextInputStyle.short, max_length=50, required=False, placeholder="Other")
self.add_item(self.header)
self.add_item(self.textbox)
self.add_item(self.button_one_label)
self.add_item(self.button_two_label)
self.add_item(self.button_three_label)
async def callback(self, inter: Interaction):
if not self.button_two_label.value and self.button_three_label.value:
view = TicketMain_One(self.header, self.textbox, self.button_one_label)
if self.button_two_label.value:
if not self.button_three_label.value:
view = TicketMain_Two(self.header, self.textbox, self.button_one_label, self.button_two_label)
else:
view = TicketMain_Three(self.header, self.textbox, self.button_one_label, self.button_two_label, self.button_three_label)
if self.button_three_label.value:
if not self.button_two_label.value:
view = TicketMain_Two(self.header, self.textbox, self.button_one_label, self.button_three_label)
else:
view = TicketMain_Three(self.header, self.textbox, self.button_one_label, self.button_two_label, self.button_three_label)
print(view)
await inter.response.send_message(view=view)```
I dont get a View
File "C:\Users\domin\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ui\modal.py", line 268, in _scheduled_task
await self.callback(interaction)
File "c:\Discord\Maja Projekt\Maja-Beta\modules\ticket_system\view.py", line 46, in callback
print(view)
UnboundLocalError: local variable 'view' referenced before assignment
this means that view never got created
meaning none of the ifs were invoked
!e ```py
if False:
x = 1
print(x)
@slate swan :x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 3, in <module>
003 | print(x)
004 | ^
005 | NameError: name 'x' is not defined
But how? button_one_label is always filled
i dont know its your code. try printing it out and seeing whats here thats how you debug
In this case, the first if would have to take effect, since button_two_label and button_three_label are empty
hello everyone
i want to make a Welcomer command, what can i do ?
my code is here :
@client.event
async def on_join(member):
guild = client.get_guild(1159111020040683560)
channel = guild.get_channel(1159111020040683564)
await channel.send(f"Hi {member.mention}, Welcome to the server!")
the bot is online but don't respond
should i make something like member = ...
ping me if you respond please
!d discord.on_guild_join
discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild) is either created by the [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client) or when the [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client) joins a guild.
This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.guilds) to be enabled.
Wrong event
@client.event
async def on_join(member):
discord.on_guild_join(guild)
guild = client.get_guild(1159111020040683560)
channel = guild.get_channel(1159111020040683564)
await channel.send(f"Hi {member.mention}, Welcome to the server!")```
is the code right, now ? @final iron
discord.on_member_join(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member) joins a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild).
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members) to be enabled.
You either want this event, or on_member_join
idk too
I’d read the docs and look at some examples if you’re still confused
i am a begginer + an idiot
!d discord.Client.event
@event```
A decorator that registers an event to listen to.
You can find more info about the events on the [documentation below](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events).
The events must be a [coroutine](https://docs.python.org/3/library/asyncio-task.html#coroutine), if not, [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError) is raised.
Example
```py
@client.event
async def on_ready():
print('Ready!')
```...
I’d read this
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
how to make that if I restarted the project of the bot the buttons still working
cuz it broke when I restart it
?
def __init__(self):
super().__init__(timeout=None)
self.Value = None
@discord.ui.button(label=" إغلاق التذكرة 🔒.", style=discord.ButtonStyle.danger)
async def close(self, interaction: discord.Interaction, button: discord.ui.button):
Same as my button
How about you actually go through the example
You obviously haven’t
Im not finding any thing diffrent than my way
also I tried to run this code and it gives error lol
you can just tell me the way without this
Literally read the comments
They literally explain it lmfao
Okay sure, where’s your custom ID?
That’s what I thought lol
Read over it carefully
Your code is not the same as the example
You’re missing key parts that the comments in the example explain
class PersistentView(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.button(label='Green', style=discord.ButtonStyle.green, custom_id='persistent_view:green')
async def green(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_message('This is green.', ephemeral=True)
this button is right for you?
custom_id + timeout is None
Considering it’s copied from the example, yes
when I reset the project it broke
Show how you’re adding the view
await ctx.send(view=PersistentView())
So for the third time, read over the example
This is my final time saying this
This is not productive. The GitHub gives you exactly what you need if you actually take 2 seconds to read it over
@commands.command(aliases=['gr','grole'])
@commands.has_permissions(manage_roles=True)
async def addrole(self,ctx, role: str, member: discord.Member):
await member.add_roles(role)
embed = discord.Embed(description = f'{emoji.check} role **{role}** has been `gave` to {member.mention}', color=color.color)
await ctx.reply(embed=embed,mention_author=False)
code and my error is
@final iron
yo
You used watch and you're showing addrole
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role)s.
You must have [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles) to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role)s must appear lower in the list of roles than the highest role of the member.
Also add_roles takes a snowflake and you're passing in a string so that won't work
oi
That's probably the issue
What’s the code
wym like the bot?
File "/home/runner/scare1/.pythonlibs/lib/python3.10/site-packages/discord/member.py", line 1051, in add_roles
await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'str' object has no attribute 'id'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/runner/scare1/.pythonlibs/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 1350, in invoke
await ctx.command.invoke(ctx)
File "/home/runner/scare1/.pythonlibs/lib/python3.10/site-packages/discord/ext/commands/core.py", line 1029, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "/home/runner/scare1/.pythonlibs/lib/python3.10/site-packages/discord/ext/commands/core.py", line 244, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'id'
~```
Share your code
import discord
from discord.ext import commands
from util import color , emoji
import datetime
from discord import app_commands
from discord.utils import get
class role(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command(aliases=['cr','crole'])
@commands.has_permissions(manage_roles=True)
async def createrole(self,ctx,*,name):
guild = ctx.guild
await guild.create_role(name=name)
embed = discord.Embed(title = f'', description = f'{emoji.check} role **{name}** has been `created`', color=color.color)
await ctx.reply(embed=embed,mention_author=False)
@commands.command(aliases=['gr','grole'])
@commands.has_permissions(manage_roles=True)
async def addrole(self,ctx, role, member: discord.Member):
await member.add_roles(role)
embed = discord.Embed(description = f'{emoji.check} role **{role}** has been `gave` to {member.mention}', color=color.color)
await ctx.reply(embed=embed,mention_author=False)
async def setup(client):
await client.add_cog(role(client))
Well this changes nothing
role is still a str
You could typehint it to discord.Role and see if discord.py will automatically convert it
did you sync?
!d discord.app_commands.CommandTree.sync
await sync(*, guild=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Syncs the application commands to Discord.
This also runs the translator to get the translated strings necessary for feeding back into Discord.
This must be called for the application commands to show up.
in a manual sync comamnd
just as a primer:
App commands work differently from message commands, they're handled mostly on Discord's end. Discord just tells your bot when someone successfully triggers a command.
In order to do this, you need to register your commands on the command tree then tell discord they exist by syncing with tree.sync.
Commands can be registered on the tree either as a global command or as a guild-specific command, and must be synced to the same scope they are associated with in the tree.
When you sync, you are telling Discord about the commands you currently have for a particular scope.
To sync global commands: await tree.sync()
To sync guild commands: await tree.sync(guild=guild)
Guilds must be either a Guild object or a discord.Object with the guild's id.
It may help to think of the tree as a dict like this.
{
None: [global, commands],
guild_one: [guild, one, commands],
guild_two: [guild, two, commands]
}
copy_global_to will copy [global, commands] and add them to the commands for the guild you pass.
This is only done locally, you must still sync.
All commands are global by default. There are a few ways to make them guild-specific:
@app_commands.guilds()decorator on anapp_commands.Groupsublcass or@app_commands.command()guild/guildsin@tree.command()guild/guildsinbot.add_cog, only if the cog is aGroupCogguild/guildsintree.add_command, not typically used
A common practice for syncing is to pick a specific guild for testing and run tree.copy_global_to(guild=guild) then tree.sync(guild=guild).
When you're done testing, tree.clear_commands(guild=guild) then tree.sync(guild=guild).
When you're ready to publish your commands, tree.sync().
?tag umbras sync command makes this flow easy using !sync *, !sync ^, and !sync, respectively.
?tag sync - why you shouldn't auto-sync
?tag whensync - when you should sync
?tag umbras sync command - a prebuilt sync command
did you read it and understand how that sync command works?
That comes out as annoying
i'll handle this one
then do you know how to make commands?
you can put it in a cog or where your commands go
Where you want your commands to be synced, preferably not blind automation
in your bot file...
i'd recommend looking at the basic examples on the gh repo in order to figure it out
Put what where? 
in a prefixed command
https://about.abstractumbra.dev/discord.py/2023/01/29/sync-command-example.html you can quite literally copy and paste it into your cog or in your main file where you are running the bot
I curated and created a pretty full-featured command for syncing your CommandTree, you can see it here:
!help for example
the point is that you need to make a prefixed command in order to sync slash commands
You can't sync in slash commands if you've never synced before
Auto Syncing Sucks
you manually sync with a prefixed command using the command that I gave you eariler
The reason why auto syncing sucks is that you send unneeded API requests to discord, as slash commands are handled by discord directly. In order to get those commands to discord, you do something called syncing. And the way you do the syncing is by making a prefixed command in order to sync those, since you can't sync slash commands with a slash command for the first time
i answered this multiple times for you
you will have to swap out discord.Client for commands.Bot instead
commands.Bot subclasses from discord.Client, plus gives you a tree already to work with (can be accessed from commands.Bot.tree)
If it's poorly done, that is
pretty much all that do that are poorly done
There's a reason why Python have if-statements
there is a reason why you dont do it in the first place
And what is it?
dont even auto sync in the first place
That's why you just need to check first
you dont
if you dont do it entirely in the first place, then why need a check?
i fail to understand your argument here
And what's the reason not to do it?
The reason why auto syncing sucks is that you send unneeded API requests to discord, which results in ratelimits being reached quickly
I'd just store previous app commands info in a file and check the current one against it, to see if they're different or not
Sync when you...
- Basic
- Added/Removed a command
- Added/Removed autocomplete (decorator, transformer)
- Added/Removed an argument
- Added/Modified/Removed locale strings
- Converted the global/guild command to a guild/global command
- Modify
- Changed a command's...
- name (
name=kwarg, function name) - description (
description=kwarg, docstring)
- name (
- Changed an argument's...
- name (rename decorator, param name)
- choices (Literal, choices decorator, enum type)
- description (describe decorator, docstring)
- type (
arg: strstr is the type here)
- Changed a command's...
- Permissions
- Added/Modified permissions:
default_permissions(decorator, kwarg)nsfw(kwarg)
- Added/Modified contexts:
guild_only(decorator, kwarg)- Contexts ( https://discord.com/channels/336642139381301249/1107116103429279764 ):
allowed_contexts(kwarg)dm_onlydecorator, kwarg)private_channel_onlydecorator, kwarg)
- Added/Modified permissions:
Do not sync when you...
- Changed anything in the command/autcomplete function's body (after the
async def ():part) - Added/Modified/Removed library side checks:
(@)app_commands.checks...(@)commands...(.check)@app_commands.checks.(dynamic_)cooldown(...)
This is the same for hybrid app commands
here is a list of when you need to sync
All that can be automated
this is the case where it's better to trade off automation with control. With umbras sync command, you gain control on how you sync, and if you screw up (say synced globally and then synced to guild, and now you have duplicate commands), that can be fixed easily with !sync ^
And? I just said ...check the current one against it, to see if they're different or not, if they're different, then sync
bot.command
In what case would you sync to a single guild?
then how are you going to detect those changes in the first place
if you have a bot that you only want commands to show up to on one guild
if-statements 🤷
correct. then you can use @bot.command
then what are the conditions for those if statements?
are you going to store the changes on every single time you start the bot?
Information of the previous - current, I just said it all
class discord.ext.commands.Bot(command_prefix, *, help_command=<default-help-command>, tree_cls=<class 'discord.app_commands.tree.CommandTree'>, description=None, intents, **options)```
Represents a Discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client) and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client) you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.GroupMixin) to provide the functionality to manage commands.
Unlike [`discord.Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client), this class does not require manually setting a [`CommandTree`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CommandTree) and is automatically set upon instantiating the class.
async with x Asynchronously initialises the bot and automatically cleans up.
New in version 2.0.
i fail to see your point here
If they were different, yes? And are you gonna have to call a command to sync everytime you change a single char in a command's description?
yes you would sync manually even there is one char added
you would have to do that anyways
I don't think you've even tried to
i have. I've used Pycord since the v2 beta days, and dpy since the v1 days
i know what it means to auto sync
How is that relevant here?
point is, i know what it means to do both auto and manual sync
And what is wrong with conditional auto syncs?
more bulk than it needs. plus there is no good way to detect the changes. you end up having to store these changes somewhere and spend time trying to detect the changes
That is just a bit more start-up time
yea "a bit" of blocking time
How many commands do you have to think that difference comparison will take that long?
30-75
Who will ever need that many?
have you seen my code? just one of my smaller bots has 30 commands in total
That is still just more start-up time
time it
Sure would
make a bot that has 100 commands, and bring me the statical data
geometric mean included
No one make a bot with that many commands, unless you make a command for every choice instead of using choices
point is, you arguing your position is useless here. as a result, this has proven that you are unworthy of helping others in this field
i've gave my reasoning with evidence to back it up and you are trying to convince me to auto sync
you gave 0 evidence to back yourself up
Evidence of?
why not to auto sync
i presented it all
you presented none
I already told you, conditional auto sync, that doesn't sync every time blindly
tbh I just have an auto-sync in setup hook and quote it out if i don't need it
that's still considered auto syncing
every single time you restart your bot, even with no changes you are still sending wasteful api requests to discord
understood. did not read the last part, which is my mistake
you basically can't convince me unless there is evidence (and proper evidence) that conclude your thesis. statements such as conditional auto syncing are still at the very end, opinions
And what kind of evidence?
i've said enough
you are getting there. it should be @bot.commands()
the ()
the @bot.commands doesn't have () at the end
ok you don't really need message starts with when working with prefixed commands. dpy handles it for you
in your case, the prefix is *
basically like that
what's the command looking like right now?
no you dont need to
bot.command() is a decorator
after that, paste in the command found here. Adjust the code as you need:
from typing import Literal, Optional
import discord
from discord.ext import commands
@bot.command()
@commands.guild_only()
@commands.is_owner()
async def sync(ctx: commands.Context, guilds: commands.Greedy[discord.Object], spec: Optional[Literal["~", "*", "^"]] = None) -> None:
if not guilds:
if spec == "~":
synced = await ctx.bot.tree.sync(guild=ctx.guild)
elif spec == "*":
ctx.bot.tree.copy_global_to(guild=ctx.guild)
synced = await ctx.bot.tree.sync(guild=ctx.guild)
elif spec == "^":
ctx.bot.tree.clear_commands(guild=ctx.guild)
await ctx.bot.tree.sync(guild=ctx.guild)
synced = []
else:
synced = await ctx.bot.tree.sync()
await ctx.send(
f"Synced {len(synced)} commands {'globally' if spec is None else 'to the current guild.'}"
)
return
ret = 0
for guild in guilds:
try:
await ctx.bot.tree.sync(guild=guild)
except discord.HTTPException:
pass
else:
ret += 1
await ctx.send(f"Synced the tree to {ret}/{len(guilds)}.")
dont worry about the content of the command itself
essentially the way you use this command is like this:
*sync - Globally sync (meaning that on every server, the command is visible and usable) to Discord
*sync ~ - Takes all of the commands that your bot has in your server, and then syncs it to that guild
*sync * - Copies the global commands and syncs it into your bot
*sync ^ - Clears out any guild commands and resyncs. This is used if you have duplicate slash commands showing up
*sync 123 - Syncs all of the commands to the given guild id. Replace 123 with the guild id that you want to sync to
i'd start off with *sync 123 (replace 123 with your guild id), and then wait a bit for them to show up
it might take some time
yes i've done it a ton of times
up to 45 seconds or so. i've not timed it so it may take longer or shorter for you
there isn't a set time for that
<@&831776746206265384>
Where did you define tree since you're not using self. prefix
And don't sync commands in on_ready event
Ah yeah and since you're using discord.Client and not discord.ext.commands.Bot - you can't use slash commands
You can still use app commands with discord.Client
!d discord.Client
class discord.Client(*, intents, **options)```
Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.
async with x Asynchronously initialises the client and automatically cleans up.
New in version 2.0.
A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client).
Yeah you can, you just have to create the command tree yourself
With Bot it’s automatically created
Yeah that's why I said where tree is defined if they aren't using self.tree which is not possible on a client
hi. i want to find out the total number of threads in a particular forum channel. i tried using len(forum.threads) but it only returned the open ones. there are a lot of archived threads. how do i count them too?
Don't do these things in on_ready
!d discord.on_ready
discord.on_ready()```
Called when the client is done preparing the data received from Discord. Usually after login is successful and the [`Client.guilds`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.guilds) and co. are filled up.
Warning
This function is not guaranteed to be the first event called. Likewise, this function is **not** guaranteed to only be called once. This library implements reconnection logic and thus will end up calling this event whenever a RESUME request fails.
Read the warning
I guess
Depending on how many it could take a bit to get all the channels
He hit da griddy
No way


Source code
How about that? 🥱
Even if there are 100 commands, it would not take more than a second
is that 2ms?
(I forgot to remove the new_hash return in lines 71 and 76, might need to change those)
» slicing
» sql-fstring
» star-imports
» str-join
» string-formatting
» strip-gotcha
» tools
» traceback
» type-hint
» under
» underscore
» venv
» virtualenv
» voice-verification
» windows-path
/help
does discord delete older threads in forum channels? i’m getting an incorrect count when i use .archived_threads() command
I don't think it does
How do you verify the count
how can we get the id of a webhook?
disnake or dpy?
oh nvm looks like dpy to me :3
actually tbh i have 90+ app commands only takes less than a sec
The webhook’s ID
ty
Best way to learn?
docs and examples
Why I am getting this error, I did install the build tools?
I wanted to install py-cord
Are you using Python 3.12?
yes
That's a well known issue, I believe that they're working on fixing it
How do I install discord_components?
I saw it in a github repo and idk how to install
Why would you need it
PS C:\Users\HP\Desktop\bot> pip install discord-components
ERROR: Could not find a version that satisfies the requirement discord-components (from versions: none)
ERROR: No matching distribution found for discord-components```
To make buttons
but like
dpy already has that
you don’t need third parties anymore.
i honestly don’t know why people also still use forks anymore tbh
You don't need it to make buttons, use libraries like discord.py
I wanna make it button, Its a tickets bot
Again, use discord.py or whatever other library you're using
discord-components is deprecated and should not be used.
ohh alr
and that since December 2021
Not what I said
DM people in a server 
property members```
A list of members that belong to this guild.
No shit
ctx.message.delete()
Deleting a message is very different from what you told me
oh im sorry
You'd need Manage Messages
yeah
Hey anyone wanna work in a joint discord bot project? (I am a beginner with enough information i think)
state the details
Tbh I didn't even decide what I am gonna make
😭
i am thinking of deciding it with my partner
welp that's the first thing you should come up with
and then tell your idea if anyone interested he or she will tell you
oh okay
but i clicked ur OF link, wtf that
idk
okay
tho why u want to make a discord bot?
like your motive to? Is it to test out your knowledge? or something else
just to experience teamwork and to test out my knowledge with working in a team
and maybe put it up on public for extra cash if the project goes successful
and also put it in my porto for future purposes
sorry for late replies, i had to go somewhere
welp for cash purposes you will need to think of something unique
Oh heck monetisation is harder than you think
coming up with something unique is even harder
As for teamwork I can just invite you to bobux bot that's pretty much teamwork
what's bobux bot
☺️
🤨
It's bobux bot
WHAT IS BOBUX BOT
ur bot..?
I am project manager, bot is owned by team
oh
is there any way I can join the team?
Bro why tf does it look like I am promoting bot
seems intetresting but disnake
Yeah sure
I will dm you details if interested
hit me up :D
Yeah disnake ☺️
Best fork
Except we highly altered views and modals implementation
welp i don't know but i feel comfortable with dpy
i dunno why people mostly hate on their parents, talking about in python library cases not irl 
what 🧐
he meant that disnake is a fork of dpy in a sense calling dpy parent of disnake
tho in the end it depends on what you feel comfortable with
no one typically hates on dpy. moreover they more so blame the developer for his past absence from development.
dpy isn’t bad. its certainly better than most of the forks that people made to replace it
tho you hate your parents if they're bad
i mean have you actually reviewed 90% of all the code of the forks?
not really.
So what makes you think that
a lot of how some of them did new implementations. for example novus/nextcord(i think). the interactions implementation they did is very obsolete and generally "bad". for example, dispatching internal events to listen to as far as buttons clicks and select menu selections
nextcord and pycord has already have both already had their fair share of bad code reviews
why dispatching events is a bad thing?
why would i also need to view 90% of the code when 90% is still written by the original developer
you can't even state that since you haven't actually looked at the code
they're forks. the general code base will stay relatively the same from the parent library
most of them weren’t made to change what danny did. moreso to add on and continue what he left
Since I only know Disnake as Fork I will only talk about that, I can assure you that Disnake has changed more than the 50% of the code base
notice how i didn’t mention disnake in my initial statement as well as how i didn’t mention all of the forks but rather most of them
you said forks generally, disnake is a fork, therefore you're also talking about it
not really. what i said is more of a general response to this.
i don’t really hate on disnake
from what i hear it’s an ok alternative to the actual library
however i never really got into it because i stuck with the main library for my own reasons
i totally said not irl
anyone here to help related discord bots
Uh, yeah, this is #discord-bots
dpy has been around for a long time and has developed a significant community.. the number of contributors and the maturity of their present implementation is a no-brainer when compared to dpy forks (most of which were forked while danny was absent)
With?
ok
this might be simple but i am kinda still stuck with it
yk a forum post right
Yes
i am trying to make a slash command that like locks a forum post at a certain time and unlock it at a certain time... i know how to do the lock and unlock. i am comfused on how to input the forum post like a normal text channel
I don't think you can
You can resort to the threads' IDs or make the command lock/unlock the thread it was called in
oh
how do i do the first one?
By threads, I mean the forum posts
yea ik
Make the command accept the thread's ID and work with it as you wish
finally got my github student dev pack
which is the best host in the bundle
digitalocean heroku replit so many choice =.=
Digital ocean is the only host in them
ok thanks!
Heroku isn't made to deploy bots as for replit you know the case
Heroku is for websites
but i need to have a credit card for digital ocean?
Probably
but i dont have one :D
Well for digitalocean verification, you must add a card / paypal and pay then up wither 5$ for a just a basic use case or 12$ (maybe 10$) to use for production use case and for verifying urself
I like how digital ocean making you pay to only verify that you are adult xd
I'd rather got to hetzner
Fr
but the point of me applying for github student dev pack is to get a free host 😭
Welp there is nothing that can help you with discord bot hosting
Use aws ig
i dont think student dev pack comes with this 😭
Needs a card too XD
It comes pretty sure
Well f
Tbh u can use an e wallet I'm pretty sure almost everyone has a sim card
its paypal but i only have touch and go
and my e wallet only has 34 cent in it :D
Yeah u can probably get aws
It comes without it
Oh nvm
Mhm wasn't sure lol
but everyone say free stuff = bad stuff
Its not free for lifetime
Only 1 year trial
It's a hosting service so yeah it's 24/7 as for database you might need to see the details I'm not sure about that
How can I make a command like this in discord.py?
!d discord.Role
class discord.Role```
Represents a Discord role in a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild)...
!d discord.Role.members
property members```
Returns all the members with this role.
iterate over the list of roles in the guild then build a string based on that
There you go
Thank you
aws also needs a cc :D
You said u have e-card or smth
Is discord js better then discord py
Define better
I am in need of discord bot developers
we need to do some work with CodeForces API and some other work
is it fine then DM me
That's not a developer searching server
Use Fiverr and similar for that
Have any one worked with pyrogram framework
never even heard of it
Oh
Why asking?
I am finding someone who can help me with some things
!pip pyrogram
hi there, has someone here ever messed with adding a user to a dm group? (yes it's an oauth2 endpoint)
coz i have few questions
like a bot adding a user to a dm group?
Ya this one
no
if ur smart enough in py no lol
py better?
yes
I think both are good on their own war
They are both different languages
Ya
So on which bases are we gonna compare them
yes, but for more stable code
i feel like js is better
It’s like comparing Japanese and Chinese
And can you tell how it's more stable
And what is the thing in discord.js that you can't do in py
If we talking about em as countries then they are comparable lol
Or in term of ppl
Better ask someone in dpy or disnake
Wont get suitable answers here
Wait nvm not ppl they look the same
Don't start a war man
Why would it start?
My bias says discord.py
I don't know why you would even learn Js if it's not for web dev
Node.js
Your code is as stable as you write it. JS doesn't inherently make your code unsafe
i even asked in the discord dev server and a mod replied initially... ig he doesn't know what's going on now even though the request is correct
However it's eaiser to write unsafe code with JS
I was going to tell you to ask the question in d dev 💀
alr
i mean if it's not a bug then it's a design flaw
also the endpoint is bad documented but I'm not even surprised
Are we still on topic of disnake and dpy?
no i and spooky are talking about the discord api
No? I was telling him to ask someone who is from dpy or disnake support server
It looks fine to me. But maybe that's because I just look at simple stuff
And those took longer than it should to look for
it's not fine 😭
if you look at d.py and forks code base you can see a lot of comments where the API is returning or doing something that is not documented or that it should'nt do
To beginners, yeah. But it's intuitive if you're more experienced and has everything you could need
They weren't intended for beginners
unfortunately that's not true for some endpoints, they're missing some information where without them your request fail
Yeah some of them pretty neat ;-;
this is mostly for oauth2 endpoints
ig noone touch the bad documented endpoints otherwise they would've already fixed / improved them
Yeah ig they are rarely used
Yeah, sometime api returns weird response thats not even documented at all
also in the OpenAPI spec all the oauth2 endpoints are missing
there are only 2 endpoints that are quite useless
They just released the spec so maybe will take some time
If you have a question, ask it so everyone may learn from it and don't ask for DMs, it's weird as well.
` import os
import discord
client = discord.Client(intents=discord.Intents.default())
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startwith('$hello'):
await message.channel.send('Hello!')
client.run(os.getenv('TOKEN')) `
when running this I am given the error "expected a token to be str, received NoneType instead" what do?
