#discord-bots
1 messages Β· Page 377 of 1
Also, what people have said is mostly right, making a discord bot is definitely not a beginner challenge and it would be much simpler to start with something smaller, like calculators. They seem simple and boring but by getting to know how it works you gain the experience you need for bigger projects
how do i start
tbh personally I was lucky to be able to revise python in high school since they only offered it as a club
ah nice
I almost ended up purely a GDScript and HTML kid not gonna lie
sobs loudly
I have almost a whole discord bot made complete with moderation and profiles and I definitely should not be at this stage
I spent a day trying to figure out why the database wasnt returning in my script, it was because I called the table settings and referenced it as servers
I broke mine up into cogs so i think mine's like 600 or so too?
I made it for a community and therefore I made a command that takes a save file and outputs it with max currency
we kinda wanted a bot like, a year ago, did barely anything with it, and now a year later I picked it up and got wayyy too far in like, a couple weeks
I think it sent again because of the Pin message but i could be wrong
looking at your code it's gonna send every time someone says ANYTHING
your right
no
yes but it still holds
only if bot sends
ant i limit the amount of msg or something
per channel
ngl i dont know
uhhhh
how to make like
it sends to every new channel a msg
so for example i create a random channel then it will send msg in there..
I can help, can you be more specific
every new channel i create i want the bot to send a msg but i want it to have a 3 sec delay with the msg
yes but that not all
can I send you code in dms
no actually send me your code (few lines) I'll add and send
sure thx
kk 1sec
import discord
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print(f'We have logged in as {client.user}')
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('hello'):
await message.channel.send('Hello!')
@client.event
async def on_message(message):
if str(message.author.id) == "790338464385073203":
await message.channel.send('Hello, please explain what ')
client.run('TOKEN HERE')
so basically u want I to
send msg in every channel
ik can u fix
yes every new channel created
Why do you have 2 identical events?
Oh ok
im new and testing stuff


ik
but im trying to add a addon
kinda extra option
uhm
idk

He's new, explaining it that way doesn't help.
i do
i explained....
π₯Ά
i want this could not make a good pic but should work
ja
ja will gwn iets voor ticket en probeer beetje te leren π€·ββοΈ
ik
heb all ticket bot
What are you trying to do? A ticket system?
how do i use modules in @bot.command()? like, i want async def variable(ctx) to be on another file, is that even possible?
so when new ticket get created it sends a msg in ticket
They have to be set up in a class defined as a cog too
and then you load the file as an extension
can i add more than one functions in cog file?
yes
enlighten me please
And what is the problem?
@bot.command()
async def hello(ctx):
await ctx.send('Hello!')```
let's say i want to make this line to work with another file `response`
idk how to make it
as long as all commands are in the class in the cog file and are @commands.command instead of @bot.command, and use self as a parameter
yesss
theres more I can't remember
What library do you use? Discord.py?
i think
Can you show me your pip list?
Hmmmm, you could use an embed message and have it have a button that opens the ticket
i can do .db files with sqlite3, it worked, but i can't go further as i haven't fully read the API, and i still need to know how to fetch userid, channelid and stuff
i dont want to advanced
i want something simple
like this
I can help with any sqlite3 things, my bot uses it more than enough
Don't use sqlite3 because it is not async
that's why modules, i think
ohh
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild).
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User).
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User) instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User) instances too.
hash(x) Returns the memberβs hash.
str(x) Returns the memberβs handle (e.g. `name` or `name#discriminator`).
really? i think you can help me with my bot then, but i need more help than you imagine with setting up the main file code so i can just link main to other files
yeah the API is really helpful
ehhh Just hit me w what you need and if I can't do it, oh well
Use aiosqlite
so, my plan is to make the main file short by making it work with user commands, and which it send data to other py file, that can use conditions
let me add this to my to do list
nvm if you use a different library than sqlite3 I probably can't help lmao
unless there isn't much difference
It's the same LOL only it's async
oh nice
sqlite3 is easy btw, so i will set up my bot with it first
ohhh
ohh
so, what's the difference between @bot.command() and @client.event()??
hey guys connected to the gateway and becoming events from the websocket, rly nice
a command is ran by the user and an event is something that just happens like message sending or deleting
which one should i use??
how should I make the event handler or how should I handle any events that I receive through the websocket?
any ideas?
i just started learning, maybe someone else used websockets here
ok
so, if i do !somethin, bot have to go in @bot.command() and search for async def somethin(ctx), right?
anyone in here using websockets for your bots?
self isn't needed if it isn't commands.command right?
and, i have to do @bot.command() again and again to to define new async class
let me change my code from ctx to self
ohh, you mean i do ctx for main file and self if i link to other?
ok, got it
You can do this:
@bot.command(name="hello")
And you can change the name of the function
so, it is just working as if else statement, right?
how do i make it work like a switch statement so it does not have to look for ever @bot.commands()
yea, i do, in fact discord.py uses websockets to connect to the gateway
What is discord.py? I am using discord API to make a bot and I am receiving events
it's a discord API wrapper written in python
ok nice. How would I handle the incoming events that I am receiving?
let me give you an example, i want to use cogs
lets say user send a message and i save the message without prefix in a variable, let's say x for now
and then the @bot.command works, and it sends the x value to other file where it perform cirtain things and send back the data
wait wait
well, if you're using this without discord.py, that's pretty complicated, what are you trying to do with those events?
message is coming with prefix, !anything and user can do anything here, and i store message anything in x and run it in @bot.command
and then it sends x to other file
yes
elif events["t"] == "MESSAGE_CREATE":
message_obj = events
if message_obj["d"]["author"]["id"] != BOT_ID:
if message_obj["d"]["content"] == ">ping":
requests.post(url=f"{API_BASE_URL}/channels/{message_obj["d"]["channel_id"]}/messages",
json={"content": "pong!"}, headers=header)
damn you're really writing this in raw websocket payload handling
can you give me example?
kekw, if it works it works moment
i recommend just using discord.py, it has command handling exactly what you're looking for
ok need to look on that, if it is good
Use some library lol
sry I thought this is the way to make a bot in discord with discord api
thanks
I see, but it's better if you use a library because it handles everything for you.
Ok. Good to know
yea the lore goes pretty deep if you were to do it raw
Can you explain to me what you want to do?
if message_obj["d"]["content"] == ">create_channel":
channel = {"name": "Channel Test"} # More information if needed
requests.post(url=f"{API_BASE_URL}/guilds/{GUILD_ID}/channels", headers=header, json=channel)
print("CHANNEL CREATED")
I need to type hint the content to str
well by default command arguments are set to str
yes but for my editor the type of message_obj["d"]["content"] is string but to get the methods
yes
so, i want my main file to be short, user send message as !message where message can be anything, and i used bot = commands.Bot(command_prefix='!', intents=intents) and @bot.command() async def hello(ctx): await ctx.send('Hello!') basically, so, here i want my class to work automatically and send the message to another response.py file where it does if else thing basically, and returns values to main file
main file will send the message to discord
something like this if you can understand
{'t': 'MESSAGE_CREATE', ............ socket is now running
i want to replace @bot.command() async def hello(ctx): await ctx.send('Hello!') with something useful
receiving events from websocket and change core with rest api
if events["t"] == "READY":
print("Bot has started.....")
I didn't understand, do you want to save the message and send it from another file?
save as in variable only
and yes
You can use a dictionary if you don't need the information to be persistent.
Allows managing multiple servers and users
for now, help me just sending hello from other file
would you guys make a try except or a if statemet if response is 200 or should I let it like this ?
It's very simple, you just have to save the message in a variable and then you can create a function that gets the message
It's basic Python
let me try π
Bro, use a library, I don't think anyone uses the API that way

bot = commands.Bot(command_prefix='!', intents=intents)
should i change this line?
In what way is the api used, if I may ask
It is the bot instance, you should not delete it
it just sits around without any function
Use a library like discord.py you can find information on Google
To make a discord bot you need to know Python very well
thats why I am making one so I know python
to learn
Yes, it is a good way to learn, but you will have many questions and problems
this is printing <discord.ext.commands.bot.Bot object at 0x00000171BAEE1F70> and i don't understand what it means
i did print(f'{bot}') lol
I use libraries like json requests websockets
Why are you printing the bot object
that is indeed the repr of a Bot object
repr
just trying to understand why i used it
all i know is that it is used for @bot.command
is a thunder method and used to present it as a string
You can see examples in the discord.py repository
Boo do you know what @ is in python?
no
im searching already
is it essential to know what it means
Please learn the basics of Python before creating a bot
if you dont know what that is you dont understand your code
but as a developer you need to understand every line you write and what it makes
that's why im here :)
Python was my first programming language but I did a calculator or a todo app or a guessing game
Do exercises and improve your Python skills. If you make a Discord bot without knowing the basics you will only have problems.
says that guy who tells me I should use a library despite discord has a well documented api
judging someone's python skills in the python server..
help them or not lol
i know basics, how to make classes, private variables etc
I am not judging anyone I am judging myself that I need to improve
So why does everyone use a library? lol
Discord API is well documented, I love it.
dont judge me for using websocket
you don't have to use a library/wrapper if you can do it yourself like handling ratelimits etc
it's a personal preference if they want to use a library or not
Most discord api wrappers handle rate limits themselves
If you want to handle everything yourself, that's fine.
bro uses all the blocking libraries πΏ
that's required no?
Well yeah ig
hehehh I dont want to actual make a bot , I want to understand and improve my skills
guys dont judge me like this
I think you guys judge me and hate on me
I mean π If youre so free in life sure
If you wanna do it from scratch it's just reinventing the wheel
Can I improve my python skills or not with the discord api
you will improve your python skills with anything you code as long as you're learning new concepts and gaining experience
It is just a regular api with requests but indeed you need websocket and this I learned with threading
I learned about websockets and the threading module
yall hating on me for no reason despite i want to learn and improve
instead of reviewing my code I wrote
you ain't getting nowhere using the requests module
You'll need to use the async version of anything that's possible
says it on discord api : POST/channels/{channel.id}/messages POST is used for HTTP along with PATCH DELETE PUT
Guys, I give up and use the library it is better
Ok wtf π
Do you know OOP? If not, using the library will help you learn aswell
you guys hate on me and dont want me to improve
ofc I know OOP
Yeah, were super bad π
I am crying rn
To be honest, making it from scratch just helps you understand how it all works under the hood
I go crying in a dark room and be there myself
Ok.
yes that is very true
Ok π
But wrapping such a large API like discord by yourself is close to impossible
I dont want to make a wrapper I want to do stuff and experiment
How so?
Ok then do it
what's stopping you?
and the best part to learn. You said before asyncio so tell me
Asyncio is for asynchronous programming so the code is not line by line
most of the stuff if not everything is documented on the discord developer portal, making it is just a matter of time
Just imagine the time you'll have to put into it and that will only result in messy code and endless bugs if you try to do it alone
If you just want to learn you can do it that way. But if you want to make a real Discord bot you will only have a lot of problems if you use the API that way.
if you have the time, go for it
Yeah that's the point ^^
nobody says you have to do it alone though
you have friends? π
Instead of explaining async and how that it is better Ash is just writing but I am here to learn
I thought so ray is the only one that understands it
If you get going and keep making the wrapper, there are no downsides of that option in my opinion
ray, can you explain when asyncio should be in my code and why
can I send you some code and you can explain me?
sure I can try
where is asyncio included @slate swan
you could use aiohttp instead of requests to gain the async effect
async with aiohttp.ClientSession() as session:
await session.post(url, headers=headers, json=json)
ok aiohttp
and if it is possible you can also add some async stuff to the receive_data method, I assume it is related to responses so you could do something there
Also, while loops are blocking
why is the async better, is it better if an error occurs and the code goes on and dont stuck that the bot doesnt crash?
I dont know what blocking ios
!blocking
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.
What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:
import discord
# Bunch of bot code
async def ping(ctx):
await ctx.send("Pong!")
What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.
async libraries
- The standard async library -
asyncio - Asynchronous web requests -
aiohttp - Talking to PostgreSQL asynchronously -
asyncpg - MongoDB interactions asynchronously -
motor - Check out this list for even more!
@slate swan
..
It has to do with the way you do error handling not with async
ok now we getting somewhere, I need to lookup asyncio, aiohttp and blocking
Im asking iN here and not a help channel as It will prob be deleted when I come back from school but I installed Jishaku and when I tested It out in my server by doing !jsk py 1+1 It didnt do anything i have no idea what the error Is I made sure I loaded it correctly please help.
Alright
@bot.event
async def on_ready():
print(f'{bot.user} is now running!')
await bot.tree.sync()
print("Loading Jishaku...")
await bot.load_extension('jishaku')
print("Jishaku loaded.")
await bot.change_presence(status=discord.Status.online,
activity=discord.Activity(
type=discord.ActivityType.playing,
name="PixelPulse"))```
Thats my on_ready
Nope, Nothing.
I think there could be a few possible reasons
- the invoker is not the owner
- the bot doesn't have message content intent
I have a whole bot set up and I and It can send messages and Im the owner of the server.
message content intent is not whether it can send messages
where did you put your intents?
intents.message_content = True
intents.members = True
bot = commands.Bot(command_prefix='!', intents=intents)```
there is probably some way to check if a module is loaded, let me check
Need all my code? I have a pretty big bot
you can print(bot.cogs) to see if jsk is loaded ig
if not that it could be something with bot ownership
I own everything.
The bot and server
then better wait for someone else to answer
It said It loaded
you just leaked ur token
reset it
it might be because you have overridden on_message
oops
Done
Speaking of that no...
So how do I fix It?
^
Tha tells me how to do It w commands...
Its a import with no bot.events
just do it
do what the link says
jsk is just the same as your normal cog
await bot.process_commands(message) at the end of your on_message
First time using this stuff no Idea what ur yapping about
On every single bot.command that Is (message)
I want to add reaction role can some1 gimme example code or smthing (I'm new so can u make it simple?)
Ping or dm plz
π
Just doing that will fix it all?
probably
Ping or dm π
And nothings fixed..
outside the if
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
my mind is slipping, what makes async super useful
Guys how to edit an embed such that the local image file should be inside the embed instead of outside. I have tried using the attachements kwarg in message.edit but that always sends the image outside of the embed
Can someone help me with this? https://discord.com/channels/267624335836053506/1258450101400113184
how to reload persistent views discord.py
what do you meant reload?
i want the bot to use the newer updated code
without restarting
you can try reloading the module that the view is in
you mean cog?
Traceback (most recent call last):
File "/path/to/venv/lib/python3.11/site-packages/jishaku/features/python.py", line 190, in jsk_python
async for send, result in AsyncSender(executor): # type: ignore
File "/path/to/venv/lib/python3.11/site-packages/jishaku/functools.py", line 124, in _internal
value = await base.asend(self.send_value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/venv/lib/python3.11/site-packages/jishaku/repl/compilation.py", line 210, in traverse
async for send, result in AsyncSender(func_g(*self.args)): # type: ignore
File "/path/to/venv/lib/python3.11/site-packages/jishaku/functools.py", line 124, in _internal
value = await base.asend(self.send_value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<repl>", line 3, in _repl_coroutine
importlib.reload(ticket)
File "/usr/lib/python3.11/importlib/__init__.py", line 148, in reload
raise ImportError(msg.format(name), name=name)
ImportError: module cogs.ticket not in sys.modules```
I get this
you can try that but I meant the file in which the view was in
^
I see you can load sys modules using the above link not local
if it's a cog then you can use then in-built dpy reload_extension function that should work
it didn't get reloaded
idk why i still get those errors
Hello guys
the same error? using reload_extension?
One question, I have implemented a cache based on dictionary filling after each command by user is received, would like running a background task to be cleaning the old entries (timestamp conditioon) after a certain time
I used jsk reload cogs.ticket
I have tried create_task with asyncio and I have a print inside
obv bot
ok let me do
but I just see the print in the beginning as I got the suggestion of initialzing the taskk inside on_ready function thet triggers once in the beginning
I haven't used jsk so don't know how that works
which lib are you using?
discord not discord.py?
discord.py yeah
ok so your task only runs once?
I want the task to run in the background
in a loop
maybe I am messing with on_ready
butI though I just create task and already have the freq running
can you show how you are running it?
yeah sure
async def clean_cache(interval, cache, max_age):
log_Helius_Ifz("Checking cache to be cleaned . . .")
while True:
current_time = time.time()
to_remove = []
for key, value in cache.items():
if current_time - value['timestamp'] > max_age:
to_remove.append(key)
for key in to_remove:
del cache[key]
await asyncio.sleep(interval) ```
this the function
async def on_ready():
log(f"Logged in as : {client.user.name}")
asyncio.create_task( clean_cache(30, wallet_cache, 60))
asyncio.create_task( clean_cache(60, wallet_transactions_count_cache, 60)) ```
and how are you starting it?
this the call
on-ready why I think is only initialization, so as first parameter is the sleep freq I guess would work triggering after that time is expired
but it does not
Why not use inbuilt task module?
That's fairly easier
Hmmm
easiest approach I want yeah
not really used to discord lib
how could be that one used/implemented?
from discord.ext import tasks
@task.loop(seconds=5)
async def my_loop():
print(1)
# to start the loop use
my_loop.start()
And I'll suggest using setup_hook instead of on_ready in discord.py
For suck stuff or use a command to run such task
Idk who told you on_ready triggers only once but that's a big lie
nobody just silly enough myself to imagine that
I have print message with logging time
Well then your imagination was wrong
only execurting once as I dont see that command more than once I run the bot for the first time
could I open you dm?
Well I'd rather stay here since someone more experienced pops up
I didn't get what you mean is the task still executing only once?
this message only shows when I run the bot
not after so that's why it only executes once
Ah that this can happen frequently incase of reconnects which can occur during long runs
doesn't make any difference
0|bot | future: <Task finished name='discord-ui-view-dispatch-31983369248b71f4ab4df97b531' coro=<View._scheduled_task() done, defined at /path/to/venv/lib/python3.11/site-packages/discord/ui/view.py:416> exception=AttributeError("'...' object has no attribute 'id'")>
0|bot | Traceback (most recent call last):
0|bot | File "/path/to/venv/lib/python3.11/site-packages/discord/ui/view.py", line 429, in _scheduled_task
0|bot | return await self.on_error(interaction, e, item)
0|bot | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0|bot | File "/root/cogs/ticket.py", line 95, in on_error
0|bot | raise error
0|bot | File "/path/to/venv/lib/python3.11/site-packages/discord/ui/view.py", line 427, in _scheduled_task
0|bot | await item.callback(interaction)
0|bot | File "/root/cogs/ticket.py", line 100, in close_ticket
0|bot | # if interaction.channel.permissions_for(interaction.guild.me).manage_channels is False:
0|bot | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0|bot | File "/path/to/venv/lib/python3.11/site-packages/discord/abc.py", line 587, in overwrites_for
0|bot | if overwrite.id == obj.id:
0|bot | ^^^^^^
0|bot | AttributeError: '...' object has no attribute 'id'```
π
Well your attribute which is '...' idk if you changed to this, is either none or does not have any attribute id
That's what above error says
but brother
the line is commented π
i changed the bot's class name
can you show your code?
yes
class View(discord.ui.View):
def __init__(self, bot):
self.bot = bot
super().__init__(timeout=None)
async def on_error(self, interaction: discord.Interaction, error: Exception, item: Item[Any]):
raise error
@discord.ui.button(label="Close")
async def close_ticket(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.defer()
# if interaction.channel.permissions_for(interaction.guild.me).manage_channels is False:
# return await interaction.followup.send("...")```
i changed it
it does not seem to work
Can you show what you did?
what exactly dosent work
if not clean_cache_transactions.is_running():
clean_cache_transactions.start(wallet_cache, 20)
if not clean_cache.is_running():
clean_cache.start(wallet_cache, 20) ```
async def clean_cache(cache, max_age):
log_Helius_Ifz("Checking cache to be cleaned . . .")
while True:
current_time = time.time()
to_remove = []
for key, value in cache.items():
if current_time - value['timestamp'] > max_age:
to_remove.append(key)
for key in to_remove:
del cache[key]
@tasks.loop(seconds=10)
async def clean_cache_transactions(cache, max_age):
log_Helius_Ifz("Checking cache Txs to be cleaned . . .")
while True:
current_time = time.time()
to_remove = []
for key, value in cache.items():
if current_time - value['timestamp'] > max_age:
to_remove.append(key)
for key in to_remove:
del cache[key] ```
so different caches and implemented two identical tasks but just for testing
only getting this message
And both are not repeating or even starting?
anybody?
That's weird
yeah it is
even first approach should work
it shouldnt be that difficult to implementing back task for cleaning
Wait you aren't breaking out of while loop
I dont
just start in on_ready
getting this too but I have honestly ignored unitl now
Yeah it's due to you not quitting the while loop
oh wait
U need to break out of the while loop in your function
my bad
To consider it complete
didnt remove that from first approach
You aren't breaking out of both in both tasks
Yeah since the while loop made it stuck in a single continuation that's why the task wasn't restarting
yeah makes absolutely
was doing too fastdidint even realize
I would like to check few aspects about bot but too long I guess to type here
mostly related with not using builtin commands but scrapping them from message from user
also the warning I pasted previously
im trynna make my bot have a member pfp as an icon url but i dont really know how, tried this but doesnt work
First of all turn off the light it attracts bugs
how
What's ctx.server?
its ctx.guild
And what you did is all wrong
You can get the user who ran the command using ctx.author
Then for the pfp you can do
ctx.author.avatar.url
if i want a specific member of the server
and after i do .avatar.url?
Just use that url where you want in embed
anyone?
All on all in your code just change server to guild and avatar_url to avatar.url
Since servers are called guilds in documentation
like dis?
how do i reload the cogs.ticket file?
I don't wanna reload the init.py
it is empty
Yeah should work tho you can just type Getpfp= bot.get_member(int(MaksimTarasov001))
everything attribute starting with get_ takes id
gonna loose my fucking mind fr
show code
Your member is returning nothing
brother send the code, not screenshot
async def MaksimTarasov(ctx):
Getpfp = bot.get_user(int(MaksimTarasov001))
pfp = Getpfp.avatar.url
embedVar = discord.Embed(title=Maksim_Tarasov["Name"], description="Team - Compton Chaos", color=Maksim_Tarasov["TeamColor"])
embedVar.add_field(name="Position", value=Maksim_Tarasov["Position"], inline=False)
embedVar.add_field(name="Archetype", value=Maksim_Tarasov["Archetype"], inline=False)
embedVar.add_field(name="Height", value=Maksim_Tarasov["Height"], inline=False)
embedVar.add_field(name="Weight", value=Maksim_Tarasov["Weight"], inline=False)
embedVar.set_thumbnail(url=Maksim_Tarasov["TeamLogo"])
embedVar.set_footer(text=Maksim_Tarasov["Userid"], icon_url=pfp)
await ctx.send(embed=embedVar)```
^
i have it its stored in MaskimTarasov001
Prolly your id is invalid or the user is not in guild, or the member isn't in cache
directly put the id
As an integer...
Try using await bot.fetch_user(int(id))
print(Getpfp)
He's wrapping it in int
Ah ok
await bot.fetch_user
gotta learn some python
!d discord.User.avatar
property avatar```
Returns an [`Asset`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Asset) for the avatar the user has.
If the user has not uploaded a global avatar, `None` is returned. If you want the avatar that a user has displayed, consider [`display_avatar`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.display_avatar).
Wild
i recommend using bot.get_user and not fetch_user
with the await in front?
as it fetches from API and does useless requests causing ratelimits
It's a cache issue that's why get isn't working
fetch_user is await and get_user is not
File "C:\Program Files\Python312\Lib\site-packages\aiohttp\connector.py", line 1027, in _wrap_create_connection
raise ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)')]
any1 could help to fix this
should be cached if they are in mututals
DISCORD_BOT_TOKEN=TOKEN The =TOKEN I will replace with my real token But Im using a DOTENV and when I run It i get a error about how It thinks Its a str so It read NoneType
your network sucked
Sometimes takes times
bro im usind rdp its 1gbps speed internet
wait are you using any proxy
Dont think so.
https://paste.pythondiscord.com/AO7A
this is the error when i run the bot im tryn to make the bot online with a vps
Can you show how you fetching it
nvm i got confused between you guys
Just use fetch for now
do you share mutual with the bot
and does the bot have member intents enabled
how do i test it then π
https://paste.pythondiscord.com/AO7A
any1 can help to fix this error when i run the bot on my vps? it work on my pc but vps nah
yuh
good question
Like u in same guild with bot
import random
import os
from discord.ext import commands
from discord.ui import Select, View
import subprocess
import requests
import logging
from dotenv import load_dotenv
# Bot setup
load_dotenv()
logging.basicConfig(level=logging.INFO)``` And then to run It I have this after trying to debug ```try:
bot.run(os.getenv('DISCORD_BOT_TOKEN'))
except discord.errors.LoginFailure as e:
print(f"Error logging in: {e}")
except TypeError as e:
print(f"Type Error: {e}")```
yuh else how would i test it
print(discord.http.Route.BASE) before running bot
give me a muint to test
brother
you need to do python main.py and not python ticket.py
Doesn't appear to be any issue
are you sure you have defiened the discord bot token correctly in .env?
Yh but It prints Token Expected str NoneType
DISCORD_BOT_TOKEN=TOKEN =TOKEN I replace with my real token
ah use fetch_user until you are ratelimited
Linter issue not code
https://paste.pythondiscord.com/QUCQ
my python file name is ticket.py
and even if i change it it will give same error
delete this
i added the print thing that u told me and i got same error
Just leaked ur Token please delete It.
DONT SSHOW UR TOKEN
Renew you token
i mean what is your main file
np its not full token π
It's almost full
Still not good lol
is that file in any directory?
nah in the main folder
Can you tell which module u have installed for dotenv
i was run it on my pc with python ticket.py and everything was good i uploaded the folders to rdp to make it 24/7 up and started get this error
I never rlly usd Dotenv but this Is the format as I was told
your rdp is bad
Well you need to install a module before you use .env i believe
i paid for it lol how i can fix xd
What one?
do you have firewalls?
yup i opened 443 tcp
for lavalink?
!pip dotenv-python
ah no
i didnt understand
Not this one
why 443 is opened
I pip installed that. I already have It
!pip python-dotenv
Use this one
what happen if i get rate limited
Wait for a few hours
i am not sure then, but i can say your code is okay and you have issue with RDP
the bot wont work?
Yes
a
Tho i doubt you will get rate limited if that's a small bot
Still nothing.
You uninstalled old one?
Oops no
pip uninstall dotenv-python
Done and I pip installed the new one and still nothing
how do i do that?
fr idk
interaction.client do not have owner am i missing something? how can i check client owner? found myself
@turbid condor can u help me with a bunch of stuff?
i need:
a basic mute cmd (the one i have atm is half done and super difficult)
to finish this reply cmd with the parameters i want
probs a bunch of other stuff but im focusing on this atm
Fuck discord its the worst platform fuck this shit
Goggle meet> discord
is it against discord tos to send messages in a specific server via my bot? for example, if i were to make it so that whatever i input to the console it sends to a channel in the server
If a bot has Access to a channel it Can send messages, but kinf of weird to randomly send a message in different server
im in the server myself, but i just wanted to make sure it isnt against the rules to do so
I mean, don't think so but its weird
its a personal server, so just as a gimmick
I would speak with the owner so they dont remove the bot.
But I dont think thats breaking tos
d! ctx.role.id
Do you have ffmpeg as an .exe there to use it in hosting env? (Just curious)
Bud your entire token is in the pastelink! Refresh your token and delete that message..
sry was busy at that time and can you explain what you trying to do a bit more
Hello does anyone has atleast some Python coding skill and would like to make a bot with me?
from on_error how will i get the interaction paramter which user passed?
It's first parameter is the interaction itself
that will return obj i dont know the property or method what it is used to get
it returns the object if u print it
i want to know is there any method or property to get the paramter which application_command used at the time of invocation
Jiggly Balls
Weird...
Just read the docs and find what attribute you're trying to find
Go to the docs and search for discord.Interaction and look at the list of attributes under it
Are you trying the get the name of the command in the view from which the error came?
parameter which that command have
i did that not found thats why i asked here
You're trying to access the commands parameters inside the view's on_error right?
on command tree yes
You'll have to just pass in the commands parameters to the view's __init__ method and access it from there then
i doubt its the right way
Why
i remember earlier when there was just text command they have some property which tells that
There isn't any built in method of function for every little thing in dpy
You'll have to apply general python knowledge also
its there they need to request to endpoint to register
i am not saying it will not work but its not the right and efficient way
Tbh this way is more efficient
Even if any method like that exist, getting data from memory is much faster than from a request to an endpoint
i think u dont understand d.py concept it raises error only if there will be error and then error handler will triggered
Yes, I know
using property doesnt ping the api again all are injected in __init__ already and there are propeties defined to access it
You can bind it to the class instance and access it in the on_error
class Test(discord.ui.View):
def __init__(self, param_name, *args):
self.param_name = param_name
async def on_error(self, interaction: discord.Interaction, error: Exception, item: discord.Item):
print(self.param_name)
I think you can do interaction.command.parameters, not sure if that's what ure looking for though
Not really, that's a View
@finite salmon @quick gust this is what i was looking for https://discordpy.readthedocs.io/en/stable/interactions/api.html?highlight=namespace#discord.app_commands.Namespace
<Namespace player_tag='2ppppppp'> this is how u get the name and value of parameter
Nice ππΌ
lf for people to help me code like a team.
- making any bot that we can think to come to mind
Make various hybrid commands
One which is /reply
And it could be:
/reply <message ID to reply to> <what to reply with> <do you want to have reply mention true or false>
Alr
can anyone help me
https://discord.com/channels/267624335836053506/1258733384327499857
When using hybrid commands, is there any way to detect which way the command was used? I have a command that needs a file uploaded to work but since you cant upload files AND use slash commands, I need a way to detect if the slash command is being used and alert the user
wdym you can't upload files while using slash
there is a whole type attachments: annotate a param with discord.Attachment and discord will show a neat ui where users can upload a file
and ext.commands will also fill it in when a file is passed with the message
hello how the lists on the embed called, i mean the new funtion that you click and a list that you choose a selection appears
selector
You mean select menus?
example: https://github.com/Rapptz/discord.py/blob/master/examples/views/dropdown.py
guide: https://fallendeity.github.io/discord.py-masterclass/views/#select-menus
An API wrapper for Discord written in Python. Contribute to Rapptz/discord.py development by creating an account on GitHub.
A hands-on guide to Discord.py
possible to make a bot copy paste images?
such that, if the original gets deleted, the copied one remains.
so not like copy pasting the url/image link
You can save the image sent somewhere in your bots directory or just save the binary data of the image in a db or smt
no way around that :/
can i have some help with this? π
if u want context just see the replies to stuff
if any1 wants to help me just ping me ill be here
I think message deletion is an event, so when u retrieve the content and theres an image, I wondered if its possible to simply send that image to another channel directly
make multiple choices inside the command
I mean multiple inputs
Yeah the attachment will be present and to access it you'll have to use the proxy_url attribute https://discordpy.readthedocs.io/en/stable/api.html?highlight=message#discord.Attachment.proxy_url
And you'll have to save the image in some form and then send it to the respective channel, this url will only be valid for a few minutes before it becomes invalid
And after saving and sending to the channel you can delete it from you database or however you save the image
how does one do that?
ive only used choices.
but its like discord.utils I think
its so common theres prob an inf tutorials on it
alr
Do you have any prior experience with creating commands?
uuh
a bit - ive made some stuff
# SAY COMMAND
@commands.has_permissions(manage_messages=True)
@bot.hybrid_command()
async def say(ctx, message=None):
""" Makes the bot speak """
await ctx.send(message)
@say.error
async def say_error(ctx, error):
if isinstance(error,commands.CheckFailure):
await ctx.send('You do not have permission to use this command!')
else:
raise error
made this
Ok good now this will be a hybrid command too i assume?
Ok now what you need to do first of all create the arguments in a function
namely
- message_id : int
- reply: str
- flag : bool
You getting it?
Ok so tell me how the function decleration will look?
so would that be the async def bit
Yes
@commands.has_permissions(manage_messages=True)
@bot.hybrid_command()
async def reply(ctx, replymessage=None, message_id, flag):
""" Makes the bot reply to a message """
this probs has like 15,000 errors
It's ok but you need to typehint
!d type hint
An annotation that specifies the expected type for a variable, a class attribute, or a function parameter or return value.
Type hints are optional and are not enforced by Python but they are useful to static type checkers. They can also aid IDEs with code completion and refactoring.
Type hints of global variables, class attributes, and functions, but not local variables, can be accessed using typing.get_type_hints().
alr had to check what it was
so i gotta import typing
then what does one need to do?
Well in this case u might
welp its not defined anywhere else
Ok I'll show you an example of what typehint looks like
async def reply(ctx:command.Context, id:int, message: str , flag: Literal["True","False"] = "True")```
This typehinting
ahhk

got this so far
# REPLY COMMAND - IN PROGRESS!!
import typing
@commands.has_permissions(manage_messages=True)
@bot.hybrid_command()
async def reply(ctx:command.Context, id:int, message: str , flag: Literal["True","False"] = "True"):
""" Makes the bot reply to a message """
await ctx.reply(message)
@reply.error
async def reply_error(ctx, error):
if isinstance(error,commands.CheckFailure):
await ctx.send('You do not have permission to use this command!')
else:
raise error
Now first thing you need to do is get the guild object of where the command is used
so would that be guild id or channel id or smth else
Then use get_message on that guild object using the id arg
No you can extract guild from ctx
what is guild object just before we continue
class discord.Guild```
Represents a Discord guild.
This is referred to as a βserverβ in the official Discord UI.
x == y Checks if two guilds are equal.
x != y Checks if two guilds are not equal.
hash(x) Returns the guildβs hash.
str(x) Returns the guildβs name.
ahhk
so get_message <id> finds the message to reply to
you shouldn't name your argument id, see how it highlights as yellow in discord? id is already a thing in python and you shouldnt be assigning it any value like that
you can't get or fetch messages from guilds, only channels
Yeah mb just checked the docs
ahh ok
new goal: find out how tf i do this
do what?
Just rename id to messag_id or something
can the user make the bot reply to ANY message in any channel? or only the channel the command is ran in
so now it'd be this then?
async def reply(ctx:command.Context, message_id:int, message: str , flag: Literal["True","False"] = "True"):
uuh probs the latter
actually
the first one
alright so you'll also need the channel id then, or the ID of the member who sent the message you want to reply to
member who sent the messagee you want to reply to
is there like a way to get the message author from the message ID
lets say if you want to reply to this message, you will either need 493344822900424714 (which is my ID) or 343944376055103488 (whcih is this channel's ID)
so if i want to reply to any message in any channel i need to get the authors id
the author of the message that you are replying to
not the person who ran the command
ok so how do i get that
ask for it in the command arguments
ik i didnt mean that
and how do i do that π
add another argument channel_id or author_id whatever u want
what does it say?
async def reply(ctx:command.Context, message_id:int, message: str , flag: Literal["True","False"] = "True", author_id:int):
You have optional arguments before
conventionally before message_id
Ok so now that you have the author id
btw theres this too
commands.Context
- fetch the member using
member = ctx.guild.fetch_member(author_id) - fetch their message using
msg = member.fetch_message(message_id) - reply to the msg
also make sure to check if the ID is valid (member/msg will raise NotFound if its invalid)
Uhh just a question wouldn't asking for a member object be more convenient then the id?
Actually true
@boreal sigil dont do the first part
hahah ok
change your argument to author instead of author_id and typehint it to discord.Member
ok
Wouldn't need to use get_member and is easier to mention the user then actually getting their id and then using that
have this so far
i meant remove the whole line...
message = author.fetch_message(int(message_id))just use this
oh rip
also await it
k
await might be a good idea as well
!d discord.Member.fetch_message
await fetch_message(id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message) from the destination.
Yeah a coro so await
im stupid so i know this is not what yall meant but my brain cant handle tryna figure out what yall did mean
After equal sign
How much of python/async do you know in the first place
it's probably a good idea to learn python first
some
this my first time using it for discord bots tho
discord.py is not made for people who only know some of python and async
It's made for people with advanced knowledge
I mean even someone with some knowledge would know how to await a coroutine
I have a feeling this is ur first time doing async
Learn in more detail how Python and async work before making a Discord bot
There's a list somewhere which shows what you should know before jumping in
nope, it's made so then I can try running it with 4.0.0 of aiohttp and then bitch to aiohttp devs that they need to special case ws and wss urls to make discord.py work and gives someone to blame. π
Is it possible to get the person who deleted a message? If they aren't the message author ofc
check audit logs?
I haven't used em in a minute cant remember if it logs who deleted a message
this is my code for it - its the most basic there is
its #ed out cuz i dont use it
If they aren't the message author ofc
Yeah, I think I read somewhere that the information isn't provided at all with discord.py but I wanted to know if there was a simpler workaround
alrighty
ive learnt more about async and also fixed my mistake - am i able to continue now?
Do you know how to edit original message from View? I'm making pagination
some minimal code:```py
class Pagination(ui.View):
def init(self: "Pagination", msgs: list[str], page: int) -> None:
super().init()
self.msgs = msgs
self.page = page
self.last_page = len(msgs)
@ui.button(label="Next", custom_id="pagination_next", style=ButtonStyle.blurple)
async def next(self: Self, interaction: Interaction, button: ui.Button) -> None:
self.page += 1
await interaction.edit_original_response(content=self.msgs[self.page], view=self)
and it called from slash command like that:```py
await interaction.response.send_message(msgs[page], view=Pagination(msgs=msgs, page=page), ephemeral=True, suppress_embeds=True)
This code currently can only send first message, but on button press it looks like show error from timeout
I've also tried```py
await interaction.message.edit(content=self.msgs[self.page], view=self)
try using interaction.response.edit_message()
!d discord.InteractionResponse.edit_message
await edit_message(*, content=..., embed=..., embeds=..., attachments=..., view=..., allowed_mentions=..., delete_after=None, suppress_embeds=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Responds to this interaction by editing the original message of a component or modal interaction.
yeh, seems like it is what I need, thanks
well the reason for error is that you are trying to edit a response that should be sent while using the button whereas you are not sending any response on button press hence getting an error
what should i use to host my discord bot!?!?!?!?
idk if there are any free hosting things
but i kinda need that cuz im broke
Search Daki bot hosting on Google they offer free bot hosting and I host my bot on it too!
ooooh nice
thx dude!!
Np
Do anyone have a source code of discord bot (Python) I kinda need it you can give me any bot like moderator, fun or any category
I'm actually working on one right now, when i get a few basic commands done i can send you the gitlab repo
Ok Thanks dude!
Hey, I'm working on a bot discord, however, I don't know how to display a json image url through my bot, like for example: "imageUrl": "my_image_path.jpg".
Any idea ?
My script Isnt working and idk why I try to load cogs but it dont work the cogs folder has my files with my stuff.
Aka that part of the bot
Im making diff files for other parts
Like fun ect
Please help
Code? Behavior?
Alright can we maybe take It too DMs?
I don't help in dm's personally
Alright
So
I have a cogs folder iwth my shift commands
Shift commands Is that link
!paste
!paste
Then thats my main bot.py but when I do any of the commands iN the first link It says they dont exist.
bot.add_cog(Shift(bot))
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Failed to load cog: Extension 'cogs.shift' raised an error: TypeError: object NoneType can't be used in 'await' expression``` And thats the error I get when It prints error.
Adding cogs is async in dpy 2.0+ (and forks of it)
whfsfjfs

Not done this for awhile
If your existing code/knowledge was on a 1.x version and you are now on a 2.x version, there is a migration guide in the docs
Im reading the error. It tells me to add await and then It tells me you cant add await
- Make sure the setup func is async
- await add_cog
- await load_extension β
try:
await add_cog('cogs.shift')
await bot.load_extension('cogs.shift') # Load your cog(s) here
print('Cog loaded successfully')
except Exception as e:
print(f'Failed to load cog: {e}')
cogs iS the folder Its iN
that's not what you pass into add_cog
do you know the difference between a cog and an extension?
Fluff no
The two sections in the docs for each explain it well
but a lot of people use the term "cog" erroneously to refer to extensions
Anyone here have made money by bot development? Dm me I got few questions
Hey, I'm working on a bot discord, however, I don't know how to display a json image url through my bot, like for example: "imageUrl": "my_image_path.jpg".
Any idea ?
Hello! I am making a Discord bot, and I am trying to make it where it gets a list from a JSON file and loops through it for specific keywords that have a specific "theme". I store the words into a list and basically sort through them. However, for some freaking reason, the list gets cleared when it is done getting sorted (inside of a for loop), and I end up getting an IndexError. Can anyone help out? Thank you!!!
Code
What a "word" looks like
{
"content": "example",
"theme": "randomtheme",
"level": 5
}
For loop
def return_new_word(selected_theme: str) -> str:
words: list = []
sus_words: list = loads(open('data/dict/sus_words.json').read())
for word in sus_words:
if word['theme'] == selected_theme and not word['theme'] == 'target':
words.append(word['content'])
elif word['theme'] == 'target':
for guild in client.guilds:
for member in guild.members:
words.append(member.name)
break
return choice(words) # This is where the error occurs
In that, you need to do async def setup, then await the bot add_cog
What's the error and traceback?
IndexError?
Hi! Sorry, but I already fixed it, but thank you for asking about it! :D
Oh, okay
What was it? I'm curious
Fixed thanks!! I fixed this ages ago and over the past few hours i've added like 4-5 other files with fun and moderation commands but only the commands from shift.py work I've made sure to laod them all.
For one you know it's a bot for second you don't know
Then if the self.bot has permissions it can mess up your server real good since user acc has different rate limits then bots
but bots still can mess up ur server
dm on rate limits I made a bot that can bypass this bot called "security bot" for testing purposes
it took the bot 2 seconds to ban it while it took my bot 1.86 to delete the channels and ban 95/150 people.
theoretically
Weird flex but ok
mainly to see if I can make something better
over the past few hours i've added like 4-5 other files with fun and moderation commands but only the commands from shift.py work I've made sure to laod them all.
Yo
Code?
Do somoene know what video can help me to create an dashboard on discord.py?
Do somoene know what video can help me to create an dashboard on discord.py?Do somoene know what video can help me to create an dashboard on discord.py?Do somoene know what video can help me to create an dashboard on discord.py?Do somoene know what video can help me to create an dashboard on discord.py?Do somoene know what video can help me to create an dashboard on discord.py?Do somoene know what video can help me to create an dashboard on discord.py?Do somoene know what video can help me to create an dashboard on discord.py?Do somoene know what video can help me to create an dashboard on discord.py?Do somoene know what video can help me to create an dashboard on discord.py?Do somoene know what video can help me to create an dashboard on discord.py?Do somoene know what video can help me to create an dashboard on discord.py?Do somoene know what video can help me to create an dashboard on discord.py?
Spamming won't help anyone!
You also should not be looking for videos to teach you non visual concepts. There's a lot at play here, you will want to read articles to know how to do these things individually then tie them together rather than solely looking for one thing that tells you how to do this exact combination of them. Those "tutorials" more often than not are extremely low quality and just throw bad code at you without teaching you anything about the choices being made
And you won't learn anything by watching a video. You aren't a visual learner, regardless of what you say.
hey so I made some code for a command that sends a button menu kinda thing but the colours arent working.
class Menu(discord.ui.View):
def _init_(self):
super()._init_()
self.value = None
class SimpleView(discord.ui.View):
def __init__(self):
super().__init__(timeout=30) # times out after 30 seconds
rulesbutton = discord.ui.Button(label='Read the Rules', style=discord.ButtonStyle.url, url='https://discord.com/channels/1237815910887194624/1239284848057651391', emoji='β', color=0xff0000)
self.add_item(rulesbutton)
rolesbutton = discord.ui.Button(label='Self Roles', style=discord.ButtonStyle.url, url='https://discord.com/channels/1237815910887194624/1237826995941806231', emoji='π»', color=0x00b6ff)
self.add_item(rolesbutton)
colorbutton = discord.ui.Button(label='Name Colour', style=discord.ButtonStyle.url, url='https://discord.com/channels/1237815910887194624/1237827021137248287', emoji='π', color=0xf100ff)
self.add_item(colorbutton)
ticketbutton = discord.ui.Button(label='Help and Support', style=discord.ButtonStyle.url, url='https://discord.com/channels/1237815910887194624/1237874844595654707', emoji='π«', color=0xfff700)
self.add_item(ticketbutton)
infobutton = discord.ui.Button(label='General Info', style=discord.ButtonStyle.url, url='https://discord.com/channels/1237815910887194624/1246832229003558932', emoji='π', color=0x00ff59)
self.add_item(infobutton)
@bot.command()
async def button(ctx):
welcome = discord.Embed(title = f"Heya, {ctx.author.display_name}, welcome to The Pikachu Crew!", description = f"Welcome to The Pikachu Crew. I hope you enjoy your time here! Please use the buttons below to navigate to useful channels.")
await ctx.send(embed=welcome, view=SimpleView())
ik the bot.command bit doesnt make sense but im just putting it as a bot command before i make it into a welcome message
oh
how can i make buttons that take you to a certain channel, have an emoji and have a color
You can't have a url button in that way it can only contain text and emoji everything else but the style is fixed meaning you can't change color
oh
is there an alternative to a url button that still can take you to a channel?
You can use hyperlinks
ooo
Yes
would I change style=discord.ButtonStyle.url to style=discord.ButtonStyle.text
No that won't work on buttons
It's just text
As in content of a message
so do i keep style=discord.ButtonStyle.url as it is?
so i keep style=discord.ButtonStyle.url?
Yes.
ok
Why are these buttons anyways
thanks it wasnt very clear lol
Discord renders urls and stuff
Fair
and also learning curve
so its now going to be smth like this?
rulesbutton = discord.ui.Button(label='[Read the Rules](https://discord.com/channels/1237815910887194624/1239284848057651391)', style=discord.ButtonStyle.url, emoji='β', color=0xff0000)
self.add_item(rulesbutton)
No
Look in here how to make buttons
You must use the url= kwarg if the style is set to url
You cannot use markdown on the label
so its now going to be smth like this?
rulesbutton = discord.ui.Button(url='[Read the Rules](https://discord.com/channels/1237815910887194624/1239284848057651391)', style=discord.ButtonStyle.url, emoji='β', color=0xff0000)
self.add_item(rulesbutton)
^ you want label="read the rules" and url="the url here"
WITH the style and optional emoji
Oh and you cannot change the color of the button lol
Neither can you set a custom color
wait so even with markdown i cant change the colour?
URL buttons have a consistent ui
someone knows how to make the presence intent thingy for when someone updates / has a specific status they will receive a role and an embed messages in dms?
i need it for a server im working on and idk how to do it
Vanity roles?
yes yes
that thing, idk to set it up so I decided I should ask someone in here
tut video or something
You should not look for videos, they are notoriously bad and not a good medium for conveying this information.
That said, there is an event for on_presence_update, though you should be careful about dming people especially if they have no opted into it
Does anyone have a good example about slash command in cog?
I want to update my old command to slash command
Is it convenient to make my bot's bot.py in a class?
https://about.abstractumbra.dev/dpy look it up in here
My site for random things and stuff. Including a custom pip index and walkthroughs, both for discord.py!
I was just browsing here
but ty for help
lol
well this is the up to date stuff and has good explaination
guys, for my next project I want to make a discord bot, do yall know any cheap and good hosting ?
I mean, think I have lot of time for that, but I was just wondering
/sauce
-> Select between 2 choices:
- with index
- without index
If "with index" is selected -> input index (int) required.
Else (if "without index" is selected) -> index defaults to 0.
I'd like to implement this type of slash command, could you give me some advice??
Hostinger