#discord-bots
1 messages Β· Page 122 of 1
it should do that
endEmbed=nextcord.Embed(title=f"π **{prize}** π",description=f"> **Ends:** <t:{utc_time}:R>\n"
f"> **Hosted By:** {interaction.user.mention}\n"
f"> **Winner:** {winner.mention}")```
you did not just type that
your lol
your actually 
Traceback (most recent call last):
File "/home/deusopus/.local/lib/python3.10/site-packages/discord/ui/view.py", line 425, in _scheduled_task
await item.callback(interaction)
File "/home/deusopus/Desktop/mr_bud.py", line 62, in get_mod
await interaction.user.add_roles(role)
File "/home/deusopus/.local/lib/python3.10/site-packages/discord/member.py", line 1014, in add_roles
await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'NoneType' object has no attribute 'id'
That pf picture :3
you'res
u'rr's
au/ra is a cutie
you shouldn't've'd typed that
use getch as panda told
Should not have head? π³
It should congratulate?
role = guild.get_role(id) or await guild.fetch_role(id)
yes
head
I'm trynna sound British
Screw having head fr
wot
why did you edit that to head
its bri'sh in dat case
I make discord bots what do I need the head for
it should edit the embed to that
appreciation
Any error?
Does it work if you do it short time like 10 seconds?
Where does it stop?
ill check
bro see the next message
πΆββοΈ
Get and fetch it's a method that tries to get it from cache first, if it fails, fetch it.
Could you debug it a bit to see where it stops, the code.
Adding some prints etc
OHH
thanks guys
yes okay
tbh the method should be able simply accept a discord.Object since all it needs is an ID
, but meh discord.py moment
Just make 1 method to rule them all.
let the users make the request payload

@slate swan like this huh?
await interaction.user.add_roles(interaction.user.get_role(985708739392839720))
that would work in python
your error handler is faulty, add an else: raise error at the end of it
not gonna work, scroll up and see the code that i sent for roles variable
lol okay ty
yeah i did
try:
bot.run(...)
except:
pass
so just do interaction.user.add_roles(role) now
okay
no dont π
OH
It was a joke
guild is not defined anywhere
interaction.guild will be the guild
why doesn't this work?
await interaction.user.add_roles(interaction.guild.fetch_role(985708739392839720))
you need to await the fetch_role
!e ```py
a, b = a[b] = {}, 5
print(a, b)
@cloud dawn :white_check_mark: Your 3.11 eval job has completed with return code 0.
{5: ({...}, 5)} 5
cursed
await interaction.user.add_roles((await interaction.guild.fetch_role(985708739392839720)))
that's my kind of code there
But like Sarth said use the getch
now you're messing with me
you didnt add the await
@discord.ui.button(label = "Get OG Status, Now!", style = discord.ButtonStyle.green, custom_id = "role_button")
async def get_mod(self, interaction: discord.Interaction, button: discord.ui.Button):
if interaction.user.get_role(985708739392839720) is None:
await interaction.user.add_roles(await interaction.guild.fetch_role(985708739392839720))
await interaction.response.send_message(f"I have given you {interaction.user.get_role(985708739392839720)}!", ephemeral = True)
else:
if interaction.user.get_role(985708739392839720) is not None:
await interaction.response.send_message(f"You don't need {interaction.user.get_role(985708739392839720)}!", ephemeral = True)
Thanks for fucking up my mind
role = interaction.guild.get(985708739392839720) or await interaction.guild.fetch_role(985708739392839720)
await interaction.user.add_roles([role])
Are you trying to figure it out :D
what is this or business
!or
When checking if something is equal to one thing or another, you might think that this is possible:
# Incorrect...
if favorite_fruit == 'grapefruit' or 'lemon':
print("That's a weird favorite fruit to have.")
While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.
So, if you want to check if something is equal to one thing or another, there are two common ways:
# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
print("That's a weird favorite fruit to have.")
# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
print("That's a weird favorite fruit to have.")
is that the getch part
If I try anymore, I will stop believing in anything and everything
await interaction.response.send_message(f"I have given you {interaction.user.get_role(985708739392839720)}!", ephemeral = True)
this is line 62
Why would you get the role twice?
that is a confirmation message
Yes okay but you re-get the role.
Traceback (most recent call last):
File "/home/deusopus/.local/lib/python3.10/site-packages/discord/ui/view.py", line 425, in _scheduled_task
await item.callback(interaction)
File "/home/deusopus/Desktop/mr_bud.py", line 62, in get_mod
await interaction.user.add_roles(role)
File "/home/deusopus/.local/lib/python3.10/site-packages/discord/member.py", line 1014, in add_roles
await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'NoneType' object has no attribute 'id'
That's because the user isn't in the cache.
hmmm
Honestly this is all base level stuff, since discord.py doesn't have methods for some handy useful things you have to code the beforehand in a custom utils py
That's why every person that helps here always say that he or she is busy coding the bot base lmao.
so i gotta figure out how to reduce the role to the variable level
Your code looks alright it's just in the wrong place and you're doing a lot of the same things again.
thanks
i want to make a lemmings button so people can ban themselves
hahahahahaha
this guys uses nextcord
How to add button components for role assignments to your Python Discord bot with Nextcord.
β€ Subscribe: http://bit.ly/SubscribeDPT
In this video, I will be using the Nextcord fork of Discord.py to make button components that correspond to roles that will be assigned to the user when they click them. This is similar to the old way of doing rea...
whats this
somethng like
betterdiscord
??
its a fork of discord.py
ooo
its how to assign roles with buttons
cool
class button_view(discord.ui.View):
def __init__(self) -> None:
super().__init__(timeout=None)
@discord.ui.button(label="Get OG Status, Now!", style=discord.ButtonStyle.green, custom_id="role_button")
async def _get_mod(self, interaction: discord.Interaction, button: discord.ui.Button) -> None:
role = interaction.guild.get_role(985708739392839720) or await interaction.guild.fetch_role(985708739392839720)
if (ternary := "You don't need" if role in interaction.user.roles else "I have given you") != "I have given you":
await interaction.user.add_roles(role)
await interaction.response.send_message(f"{ternary} {role.mention}!", ephemeral=True)
# Guild specific slash command
@client.tree.command(guild=MY_GUILD, name="get-og-status", description="Get OG status!")
async def launch_button(interaction: discord.Interaction) -> None:
await interaction.response.send_message(view = button_view())
``` I'd make it like this
ayee can u pls tell me
i want to pick the gif (as a link) the user send after a command and want to send that gif later on
That's old news they are developing again.
im using nextcordddd
what is ternary
test = "yes" if True else "no"
print(test)
@cloud dawn :white_check_mark: Your 3.11 eval job has completed with return code 0.
yes
Is it an operator?
that's great man wow
it would be yeah
Hm interesting.
aa hey guyss
pls tell me if u got any solution for my problem
i am trying to make a welcome bot
now in a command i want to pick the gif the user send after the command
and want to send it later on
now how can i pick that gifs link????
!d discord.Attachment.url
The attachment URL. If the message this attachment was attached to is deleted, then this will 404.
Traceback (most recent call last):
File "/home/deusopus/.local/lib/python3.10/site-packages/discord/ui/view.py", line 425, in _scheduled_task
await item.callback(interaction)
File "/home/deusopus/Desktop/mr_bud.py", line 61, in get_mod
role = interaction.guild.get(985708739392839720) or await interaction.guild.fetch_role(985708739392839720)
AttributeError: 'Guild' object has no attribute 'get'
get_role
ah
discord models are pain in da ass, the documentation is so bad
https://discord.com/developers/docs/interactions/message-components#text-inputs...? Looks good to me
there's no description about modals, they just wrote "Creating a modal" in an example with no mention about it's textinput limits or anything
My send link does have text limits etc
textinput limits, like the maximum number of textinputs a modal can have
its 5 and its not documented anywhere there
// this is a modal
{
"title": "My Cool Modal",
"custom_id": "cool_modal",
Text inputs are an interactive component that render on modals. They can be used to collect short-form or long-form text.
all the info about modals is here
you can get faster help if you just mention your issue lol
yea hol u p
in the time i made this noone ever told me this is outdated and now i need help converying to d.py2
yes and also
"Components are a new field on the message object, so you can use them whether you're sending messages or responding to a slash command or other interaction.
The top-level components field is an array of Action Row components."
-=-
"You can have up to 5 Action Rows per message"
Apparently inputs are action rows lmao
Yes
noone told me that using :```py
import discord
@client.event
async def on_ready():``` was bad
One text input per row
Wouldn't have been such a huge deal to implement pagination in the modals... Discord...
It isn't?
apparently its outdated
print('We have logged in as {0.user}'.format(client))
``` this is more cursed.
compared to py @bot.command() async def ping(ctx): await ctx.send("pong")
explain in titanfall2 terms
Could you send the error?
You're comparing apples to oranges
That's actually a pretty big difference-
and apples are better
I prefer strawberries or pears :3
wow...
I believe it's only bad if you're making API calls or changing your bot's presence in on_ready
It's.. okay google it.
π 
so its okay?
how do i add commands then
apparently they conflict
This code should still work.
πΏ lmao thats not it, but yeah they do mention about the 5 textinput limit in the part where they tell how to create a modal interaction lol
it should start reading more, thanks!
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
Robin begs to differ.
itzzz one selectmenu per row 
oh so my ass just got trolle dd AHH
ok so how do i add commands then
My point exactly
you can edit the message after the button is pressed and update the view parameter
hmmm
.
Like this
You have a perfectly working command handler right there
that doesnt work tho
How so?
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix=">")
@bot.command()
async def ping(ctx):
await ctx.send("pong")
bot.run("token")```
you gotta enable message_content intents
in the code as well!
do u mean this
intents = discord.Intents.default()
intents.message_content = True
client = commands.Bot(command_prefix='!', intents=intents)```
!intents instead of members it will be message_content for you
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
correct
'Intents' object attribute 'message_content' is read-only
'Intents' object has no attribute 'message_content'
good these guys are great you got a great community here
i found this
async def button_callback(button_inter: disnake.MessageInteraction):
button1.disabled = True
await button_inter.send(embed=embedname2)
await slash_inter.edit_original_message(view=view)
button1.callback = button_callback
await slash_inter.send(embed=embed1, view=view)
that's disnake
any reason why I shouldn't be using discord.Intents.all()?
i use it
Unnecessary computational strain on the instance
Waste of resources
Fair enough.
hahaha
im all about that unecessary strain
It's convenient in dev but I would suggest remove during prod
my carbon footprint tho
help D:
I see, thanks.
So does anyone know of a way to get the user who invited the bot to a given guild in the on_guild_join event? One that doesn't require 'dangerous' permissions such as view audit log or manage server perms, because the only 2 methods I know of require those permissions.
The gateway doesn't dispatch that unfortunately
If you can view invites that's one way
Audit log does report it
The idea is to be able to DM the user encase the bot doesn't have the permissions it needs. But using the audit log or viewing server integrations to find the user doesn't make sense to me, because those require permissions even more powerful than those actually needed for my bot to work (send messages, embed links etc...).
how do i fix this?
I believe for a user to get your bot to join their server, they need to accept all the permissions right?
!d discord.Integeration.user
No documentation found for the requested symbol.
wait there was a method, ill be right back
There's the check screen where you verify all the permissions
You can un-check those boxes though, I think.
!d discord.Integration check this class it has an attr for that
class discord.Integration```
Represents a guild integration.
New in version 1.4.
And also the bot might get caught up with channel-specific overrides
yeah its discord.Integration.user
it gives you the User that added the integration (bot) to the server
Yeah but the bot needs manage server to view that doesn't it?
yeah that's a limitation

I would just use the has permission decorator on commands that need certain permissions
I was thinking of doing that, then just DM interaction.user if permissions are missing
hey Robin do you know how to disable a button in discord.py after its been used
do you have to define a function?
!d discord.ui.Button.disabled
property disabled```
Whether the button is disabled or not.
okay
Will I have to do this for each command individually or is there an easy way to do it for all of them at once?
For example if every command simply requires external emojis and embed links
!d discord.ext.commands.Bot.add_check
add_check(func, /, *, call_once=False)```
Adds a global check to the bot.
This is the non-decorator interface to [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.check "discord.ext.commands.Bot.check") and [`check_once()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.check_once "discord.ext.commands.Bot.check_once").
Changed in version 2.0: `func` parameter is now positional-only.
See also
The [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") decorator
Thanks.
like this.....?
Surely not all commands require elevated permissions?
how can i mention a new member who joind the server
i am using member.mention under on_member_join
Well they all require the basics such as sending messages, sending embeds etc.
Right, but different commands will require different permissions
So decorate each command (or a cog) with what permissions they need
So users can turn off one permission and still have the rest of the bot work
Yeah that makes sense thank you
how do i set it to true?
make sure the members intent is enabled
yes its
well what did you try so far
amm i was learing discord bots few months ago
And then i was making welcome bot at that time it was mentionting users
but its not doing it now
i am taking a welcome message from a user
with @rich otter(specifies that u have to mention use rname )and store it in a json file
whn user join it i am trying to replace the @rich otter with the new joind member name
i was able to do it few months ago but not now
so earlier the code was working, then it suddenly stops working?
and you didn't change anything?
then show the code
its a bit complicated tbh
the code i mean i am also confused what i made
I cannot help if you don't post the code or any error
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
amm its too big
and many pending things
i will try wait pls
Probably you updated to dpy 2.0 since those months past and your code broke as a result
then fix them first or use cogs
I don't think there are any changes on on_member_join
done i pase it
send the link
it was in aug
the mention code is first
and then its the commands to get the data for welcome message
I don't really like the way you made it, it's messy
yaa thats true
and events are inside a function, just use cogs
oke sir
i will do all that once i made it send succesfull welcome message
thats the aim for now
remove that function first
you want to change the view parameter of the message
so for example to remove the buttons entirely you can do view=None
and you don't need try/except, the library provides you error if bot fails to send
alrightπ₯²
but where
!d discord.Message.edit
await edit(*, content=..., embed=..., embeds=..., attachments=..., suppress=False, delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the message.
The content must be able to be transformed into a string via `str(content)`.
Changed in version 1.3: The `suppress` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited message is returned instead.
Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.11)") instead of `InvalidArgument`.
yaa i today only got to know about it but the code is wheni was learing basics of it
oh
i guss its better to rewrite the whole code
anyway can u guss tell me one thing
i am using json to store the data for the welcome bot
like the welcome message etc
is there any other btter alt
for it
await interaction.message.edit(content = None, view=button_view())
like that i guess?
is that for me??
no im trying to figure out how to edit a message and then disable it and refresh the view
Sqlite
You can also consider mongodb for a JSON like db
i was also thinking to do so
will it be a good idea ??
Sure
you can't "disable" a message, wdym
Just do know to use an async driver, e.g Motor
i gotta disable the button so i gotta run the button snippet twice
once again at the end
mh?
can someone give me an example of discord.ext.commands being used?
this is what im figuring out
await interaction.edit(view=button_view())
aka command()
app_commands
wait what lib are you using?
discord.Interaction
im using a class
class button_view(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
self.value = None
self.timeout = None
discord.Interaction.edit doesn't exist
ok
!d discord.Interaction.edit_original_response
await edit_original_response(*, content=..., embeds=..., embed=..., attachments=..., view=..., allowed_mentions=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the original interaction response message.
This is a lower level interface to [`InteractionMessage.edit()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionMessage.edit "discord.InteractionMessage.edit") in case you do not want to fetch the message and save an HTTP request.
This method is also the only way to edit the original message if the message sent was ephemeral.
what im trying to do is gray out the button once its been pressed
it doesn't work intuitively to me
im figuring it out though
Set disabled property on button to true
Resend view
Easy as that
how do i set the disabled on it
It's a property not a method?
async def get_mod(self, interaction: discord.Interaction, button: discord.ui.Button) -> None:
It's just button.disabled = True
And then await interaction.edit_original_response(view=self)
ig he's defining his button with a decorator so that's his difficulty to set button.disabled = True
It's not really difficult
ik
the decorator callback also takes a button param
if its in some other class they can also do self.<button callback> to access the button obj
You can also check the children of the view, multiple options depending on the use case
the children way is most convenient
π€¨
well ive never done it
check this out
class button_view(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
self.value = None
self.timeout = None
@discord.ui.button(label = "Get OG Status, Now!", style = discord.ButtonStyle.green, custom_id = "role_button")
async def get_mod(self, interaction: discord.Interaction, button: discord.ui.Button) -> None:
if interaction.user.get_role(985708739392839720) is None:
role = interaction.guild.get_role(985708739392839720) or await interaction.guild.fetch_role(985708739392839720)
await interaction.user.add_roles(role)
await interaction.response.send_message(f"I have given you {interaction.guild.get_role(985708739392839720)}!", ephemeral = True)
else:
await interaction.response.send_message(f"You don't need {interaction.guild.get_role(985708739392839720)}!", ephemeral = True)
await button.disabled(True, view=button_view())
@client.tree.command(guild=MY_GUILD, name = 'get-og-status', description='Get OG status!')
async def launch_button(interaction: discord.Interaction):
await interaction.response.send_message(view = button_view())
nah the best way is use the button param of the callback
It's a property not a method?
I presume you just winged it here and guessed?
examples/views/ephemeral.py lines 27 to 36
@discord.ui.button(label='0', style=discord.ButtonStyle.red)
async def count(self, interaction: discord.Interaction, button: discord.ui.Button):
number = int(button.label) if button.label else 0
if number + 1 >= 5:
button.style = discord.ButtonStyle.green
button.disabled = True
button.label = str(number + 1)
# Make sure to update the message with our updated selves
await interaction.response.edit_message(view=self)```
plus you guys helped a lot
Sorry that was a pointless question
np
i am somewhat slow to this
i admit
i think i am a differnt kind of learner than most
im very right brained for sure
Right so yes a property is defined as a function, which is their point. Properties are like attributes, but instead of only storing one value you can define code which should be executed when the attribute is either accessed or set.
I don't think disabled is a property though
How does this code work btw? There hasn't been any response sent yet here?
it is a property of Button / ui.Button class
!d discord.ui.Button.disabled
property disabled```
Whether the button is disabled or not.
thats what
I doubt it's your learning speed, How much experience do you have with python and the OOP paradigms? Discord.py depends on many paradigms and can be overwhelming
Hi! discord.Member object have property id which is int. Anyway in discord, you can set id that starts with 0, but in python, you cannot assign int value that starts with 0. How is it possible?
Well then, i would recommend not being hard on yourself when dealing with issues these types of implementing issues
Can you define what a property is and how disabled isnt a property?
!e print(0o12)
wait this is not it, just a minute
I think what you'll be looking to do is first disable the button, exactly like others showed. Then we'll need to edit the original message which it doesn't look like you keep around but it should be available through the interaction:
self.get_mod.disabled = False
await interaction.message.edit(view=self)
@minor totem Was your point about, how documentation is misleading due to the fact that Button.disabled is an attribute and not an actual property?
I forgot that the discord.ui is a bit special, and wraps an underlying button.
The underlying button's disabled is just any ol' regular attribute:
https://github.com/Rapptz/discord.py/blob/master/discord/components.py#L187
discord/components.py line 187
self.disabled: bool = data.get('disabled', False)```
well the ids that discord sends and receives in payload is actually a snowflake object ( which acts like an string even tho it has an integer value ) so they can begin with a 0, possible way of defining a number with leading zeros would be 0o0<int> but it will just print ( or any operation) the <int> when you try to perform it
Yep, you would be correct
I don't think there's snowflakes starting with 0. If you want to add 0s at the start, you'd do so during the int to string conversion
you mean True?
but 0o prefix makes value octal int
Yes sorry!
i said 0o0 , not 0o
!e ```py
value = 0o01
print(value)
@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.
1
But if someone's tag is 0123?
but what's your usecase tho?
im just wondering how it works
i don't think that possible, did you confirm in the api server?
GOD BLESS YOUR MAMAS
it worked
lass button_view(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
self.value = None
self.timeout = None
@discord.ui.button(label = "Get OG Status, Now!", style = discord.ButtonStyle.green, custom_id = "role_button")
async def get_mod(self, interaction: discord.Interaction, button: discord.ui.Button) -> None:
if interaction.user.get_role(985708739392839720) is None:
role = interaction.guild.get_role(985708739392839720) or await interaction.guild.fetch_role(985708739392839720)
await interaction.user.add_roles(role)
await interaction.response.send_message(f"I have given you {interaction.guild.get_role(985708739392839720)}!", ephemeral = True)
else:
await interaction.response.send_message(f"You don't need {interaction.guild.get_role(985708739392839720)}!", ephemeral = True)
self.get_mod.disabled = True
await interaction.message.edit(view=self)
@client.tree.command(guild=MY_GUILD, name = 'get-og-status', description='Get OG status!')
async def launch_button(interaction: discord.Interaction):
await interaction.response.send_message(view = button_view())
!e Oh? I really don't think this is what they were looking for at all
print(0o0000418673016093016066)
@minor totem :x: Your 3.11 eval job has completed with return code 1.
001 | File "<string>", line 1
002 | print(0o0000418673016093016066)
003 | ^
004 | SyntaxError: invalid digit '8' in octal literal
there she be
π hm i think that won't work here then
i just used it once for an tinyint
well using a string is always an option
here
!e
I'll reiterate here. Integers do not have leading 0s, because they are pointless. The leading 0 that you may or may not see in some cases are only added during "rendering" when the integer is turned into a string.
You could do this by using rjust: ```python
snowflake = 418673016093016066
print(str(snowflake).rjust(22, "0"))
@minor totem :white_check_mark: Your 3.11 eval job has completed with return code 0.
0000418673016093016066
Someone's tag is the discriminator, it is stored as a string in the API.
also returned as a string into the payload
You could store it as an int locally, and turn it into a string and use rjust(4, "0") similar to what I did above
so thats my giveaway command and when i end the giveaway its not changing to the end embed
Well, you have an if-statement there, are you sure it works?
like
it is sending the embed that a winner is mentioned and the giveaway ended but does nothing w the giveaway command
how do i make a button
can someone help me how to see how many servers my bot is on? you mean a command or something?
!d discord.ext.commands.Bot.guilds
property guilds```
The guilds that the connected client is a member of.
len(bot.guilds)
so i have to make a new view class for each button?
hi guys does someone know why im getting an error. Im new and dont really understand
you gotta put quotes around the key and you have to renew it now since you share dit
renw the token yes? and thanks man legend
you can have multiple components per view
once again does i dont know why its giving me an error
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
...
question, what imports did you use for that?
what exactly needs sorted out? what is the issue
its not posting the button
thats all of them?
btw i need this for myself because i cant figure out how to make a button
What even is self.interaction
thx ill try again
hahaha
class button_view(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
self.value = None
self.timeout = None
@discord.ui.button(label = "Get OG Status, Now!", style = discord.ButtonStyle.green, custom_id = "role_button")
async def get_mod(self, interaction: discord.Interaction, button: discord.ui.Button) -> None:
if interaction.user.get_role(985708739392839720) is None:
role = interaction.guild.get_role(985708739392839720) or await interaction.guild.fetch_role(985708739392839720)
await interaction.user.add_roles(role)
await interaction.response.send_message(f"I have given you {interaction.guild.get_role(985708739392839720)}!", ephemeral = True)
else:
await interaction.response.send_message(f"You already have {interaction.guild.get_role(985708739392839720)} or HIGHER!", ephemeral = True)
self.get_mod.disabled = True
await interaction.message.edit(view=self)
@client.tree.command(guild=MY_GUILD, name = 'get-og-status', description='Get OG status!')
async def launch_button(interaction: discord.Interaction):
await interaction.response.send_message(view = button_view())
this works
so i was trying to cull from that
now i have this for the second button im working on separate slash command
@discord.ui.button(label = "What is Cannacoin?", style = discord.ButtonStyle.green, custom_id = "about_us")
async def aboutus(self, interaction: discord.Interaction, button: discord.ui.Button, embed: discord.Embed) -> None:
embed = discord.Embed(title="About us", url="https://wiki.cannacoin.org")
embed.add_field(name="Q: What is Cannacoin?")
embed.add_field(value="Cannacoin is a ...")
await self.ctx(embed=embed)
aboutus.disabled = True
await self.ctx(view=self)
what is self.ctx ?
idk what ur doing.
yeaa
you should learn the basics or at least read the docs
Traceback (most recent call last):
File "/home/deusopus/.local/lib/python3.10/site-packages/discord/app_commands/commands.py", line 851, in _do_call
return await self._callback(interaction, **params) # type: ignore
File "/home/deusopus/Desktop/mr_bud.py", line 87, in launch_button
await self.ctx(view = button_view())
AttributeError: 'Interaction' object has no attribute 'ctx'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/deusopus/.local/lib/python3.10/site-packages/discord/app_commands/tree.py", line 1240, in _call
await command._invoke_with_namespace(interaction, namespace)
File "/home/deusopus/.local/lib/python3.10/site-packages/discord/app_commands/commands.py", line 876, in _invoke_with_namespace
return await self._do_call(interaction, transformed_values)
File "/home/deusopus/.local/lib/python3.10/site-packages/discord/app_commands/commands.py", line 869, in _do_call
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'about-us' raised an exception: AttributeError: 'Interaction' object has no attribute 'ctx'
i read it on stack
there is no ctx
for interaction object
that means i need to put something instead of ctx
i think its message
try that
i mean partially yea also button interactions are MessageInteractions
nah
oh
his entire logic is wrong and he is just copying code from online
thats something i would do
yea then come here and ask us to fix it lol
im trying to do neural networks rn so maybe later
also what does ctx do
is it some old thing?
i know it means context but what does it do
im not copying code from online okay
quit accusing me of stuff
im following the tutorials and im watching for watch vscode lights up with
i have a techniques i dont understand manuals
the tutorial did not say to do self.ctx inside of an interaction
well i was just doing trial and error
becaue i have never had a teacher
im not copying and bringing it here for you to fix it
a teacher has nothing to do with you actually taking the time to learn
dude i am learning i learn this way
nm
im gonna go
im sorry that i bothered you sir
someone answer
good luck man this is a touchy crowd at lunchtime
well the class name (Context) already explains pretty much
it stores information about how & where the command was invoked
!d discord.ext.commands.Context
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.
This class contains a lot of meta data to help you understand more about the invocation context. This class is not created manually and is instead passed around to commands as the first parameter.
This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
oh thanks
A lot of things you read online may not work anymore (specifically for interaction based events) since discord.py didn't update to include those until recently. Your best resource will be the documents and python basics. One thing that really helped me with the basics is a book called Python Crash Course A Hands-On, Project-Based Introduction to Programming
im sorry jay was right im getting a little dependent i need to step away and think for a minute for myself
i think i figured it out too
!d discord.ui.Button
class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.
New in version 2.0.
!d discord.ui.button
@discord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.
The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View "discord.ui.View"), the [`discord.Interaction`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction "discord.Interaction") you receive and the [`discord.ui.Button`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Button "discord.ui.Button") being pressed.
Note
Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Button "discord.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
!d discord.Interaction
class discord.Interaction```
Represents a Discord interaction.
An interaction happens when a user does an action that needs to be notified. Current examples are slash commands and components.
New in version 2.0.
@south coyote
thx
np
!d discord.Message
class discord.Message```
Represents a message from Discord.
x == y Checks if two messages are equal.
x != y Checks if two messages are not equal.
hash(x) Returns the messageβs hash.
help
@discord.ui.button(label="button", style=discord.ButtonStyle.green)
async def buttons(self, interaction: discord.Interaction, button: discord.ui.Button):
# what do i put here?
yup
?
example?
depends on the type of buton
ugh
Donβt follow tutorials. They all suck and are outdated.
@slate swan start here...
import discord
from discord import app_commands
MY_GUILD = discord.Object(id=0)
class MyBot(discord.Client):
def __init__(self, *, intents: discord.Intents):
super().__init__(intents=intents)
self.tree = app_commands.CommandTree(self)
async def setup_hook(self):
self.tree.copy_global_to(guild=MY_GUILD)
await self.tree.sync(guild=MY_GUILD)
intents = discord.Intents.default()
client = MyBot(intents=intents)
@client.event
async def on_ready():
print(f'Logged in as {client.user} (ID: {client.user.id})')
print('------')
then look for tutorials on youtube for discord.py and buttons within the last three months or so
its okay to watch tutorials
ill check it out later
gtg for now
Noβ¦ itβs not
Theyβre completely outdated, simply learn how to read documents
Much easier and actually in date
You also get the experience for future projects outside of d.py.
Any decent developer will say to never use tutorials. You donβt learn anything, instead, you just copy it and complain that it doesnβt work 
not true. I know quite a bit and started by watching a playlist of someone making a bot in dpy. itβs really just how that person learns
that's opinion man
its better not to use them yes, but sometimes its fine as long as its a good tutorial
Truly experienced developers will frankly tell you to do whatever you want to do as long as it works for you
No objectivity about it
You're right - however when it comes to discord bots, tutorials are just frankly not a good idea
However much you like the youtube video format, I just can't recommend people learn misinformation and build bad habits
I mean sure it's true a lot of people stumble into outdated videos but I've come across decent up to date versions
Personally tutorials got me into discord bots in the first place and I just kept the docs alongside to cross check
i prefer text tutorials over videos, they are easily maintainable so they don't get outdated so easily
whats the correct way to make a command (not slash command)
i use
@client.event
async def on_message(message):
if message.content.startswith("-command"):
await message.reply("command")
i know there are other ways, but what way is the best
also
intents=discord.Intents.all()
client = discord.Client(intents=intents)
``` is what client is
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot("prefix", intents= intents)
@bot.command(name="name", description="command description")
async def name(ctx: commands.Context):
...
bot.run()
``` this is a basic structure for a bot with commands
the pros of using this is that you won't have to parse arguments manually and will avoid sphagetti code
!d intents
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
@bot.command(name="name", description="command description")
async def name(ctx: commands.Context):
...
is this for slash commands?
also can i call the bot variable client
well you explicitly mentioned "not slash command" so what do you think 
will you name your dog "kat"
if yes, go for it
thank u
apologies if this is a dumb question but...
what exactly am I meant to pass into app_commands.Cooldown.reset() to make it reset my cooldown? it does not state anything in the docs, and does not give any console errors nor reset my cooldown if I leave it empty.
class ErrorHandler(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
bot.tree.on_error = self.cog_app_command_error
async def cog_app_command_error(self, interaction: discord.Interaction, error: app_commands.AppCommandError):
if isinstance(error, app_commands.BotMissingPermissions):
app_commands.Cooldown.reset()
await interaction.user.send(embed=missing_perms_embed)
(I still get a cooldown upon using the command even if BotMissingPermissions is raised which is why I wanna reset it here)
well .reset isnt a static method
wouldnt make any sense anyways
you have to create a instance of Cooldown
something like my_cooldown = app_commands.Cooldown()
if you then call .reset on my_cooldown it'll work
.reset is rn expecting the self argument
bcs it wasnt instantiated
if u get what im saying?
im bad at explaining stuff
are you using the @app_commands.cooldown() decorator? they dont provide an easy way to access the actual Cooldown object for you to reset() it
though i dont understand how you'd get a "cooldown" if BotMissingPermissions was raised
I kinda understand.
This is how my decorator looks
@app_commands.command(name='weekly', description='Claim your weekly GamBot $ reward!')
@app_commands.checks.bot_has_permissions(send_messages=True)
@app_commands.checks.cooldown(1, 604800)
ah so you mean after the missing permissions fails, the user goes on cooldown afterwards
as a tip, checks run from bottom to top
if you put your cooldown at the top, the checks below it will run first
and then the command stops early if one of them fails
Wow, I swapped them round and it seems to have done the trick. That makes no sense to me as to why they'd run from the bottom, but thanks for letting me know.
it matches how decorators are applied in python
writing this: py @foo @bar def baz(): ... is equivalent to writing this: py def baz(): ... baz = foo(bar(baz)) bar receives baz first, and foo comes second
(to clarify, the library could have chosen to order the checks differently, but they decided to make it familiar with python's semantics)
Of course. I didn't realise this before but it makes sense now. Guess that makes me still a Python noob.
Thanks!
How would I go about mentioning all users from a list not knowing the size of the list
!d str.join
str.join(iterable)```
Return a string which is the concatenation of the strings in *iterable*. A [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") will be raised if there are any non-string values in *iterable*, including [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") objects. The separator between elements is the string providing this method.
or a for loop if you want to send multiple messages
I was trying a for loop with a single message and it wasn't working out for me lol
use str.join
await ctx.send(f"Hello {', '.join([member.mention for member in members])}")
actually wait
await ctx.send(f"Hello {', '.join([user.mention for user in users])}")
makes more sense
users a list of the users you want to ping
we first use a for loop to get all the mentions
[user.mention for user in users]
this will return smth like:
['@alpine cove', '@alpine cove']
so i guess you cant create and embedded message from a button click
and using .join we put the , in between of all of the mentions
im so done
this will return smth like:
@alpine cove, @alpine cove
wdym?
ofc u can
You can
Lol
sexist
nah
lol
anyways lets get back to dc bots
mods dont like us chatting in here
@hushed galleon why can you not add emojis to messages in #discord-bots
is that a bug?
you can
i cant
He means reactions
oh wait in here
yea
i thought you meant bots
i dont know why, but helpers can
bruh
no reaction perms 
I was wondering the same thing a couple days ago
can you go to a million on an emoji
But we can add reactions in the general chats
should I open like a support ticket?
there's a bot for that
I thought you might be able to change perms
there's a bot for that on my server
Imo yes because it would be beneficial to be able to add an up arrow on the bottom of a message to indicate you agree with said message
ok one sec
Also thanks for this, flawless.
np
done

lets see how long it'll take
Alright anyways, yes you can send an embed after using a button
Same way you would send an embed normally, just put it inside the button block of code
@south coyote 
I made a blackjack game and 95% of the code is inside the button blocks and not the command itself lol
so yes you can do lots things with buttons that you can regular commands
I'd say buttons allow you to do much more
for example: Modals
I saw your blackjack game I believe and it's pretty slick. I have 1300 lines of code in one of my bots and approximately half of that is inside an on_message 
Maybe not half, but a large amount nonetheless
I haven't really explored Modals at all yet. What are they used for?
1300, sheesh
its like a form you can fill but in discord
And thanks I'm very proud of the game :-)
bruh

I want to do something with modals but I don't really have a use yet. And yea 1300 and it's not 100% done yet 
HwAt
I see
its pretty dope
Can we start a petition
how?
What sort of features does your bot have?
You can DM me it if you'd like
It's much easier than typing it out again
unlikely
same here
I don't think the mods will let you
Sentx2
idk
Really wish I could plug it more places. I need feedback lol
send it to me too
thanks for all your help over the past few days guys you are great thanks
i want to thank you
I appreciate the help I've gotten here as well
all i gotta do is change the view when i show one button and the other
i gotta figure that out how to have multiple views
You only receive dms from friends
Make another view the same way but with a different name then use it with view=secondview
i'm making a higher or lower game next which is gonna need a crap top of code involving buttons so wish me luck lol
I feel pretty confident with buttons since I started making my level bot. Put that on pause since it's at a solid point and started a giveaway bot with better features like role filtering and channel specificity
I have never created a complete discord bot, I prefer to throw myself into the internals of disnake πΆβπ«οΈ
lmfao
the game alone would be quite hard to do in discord I think , but imagine trying to make an ai bot player for the user to play against (unless you wanna make it multi-player)
I like making discord bots. Also helps that I have a goal of reducing the number of bots in my main server. The owner will not pay premium bot fees so he has a bunch that accomplish one or two things to cover what the others lack. That was what started me on the level bot

Did the owner commission you to make them a bot?
Nah he's a very good friend of mine and I'm also an admin of the server. Took it upon myself with his input
that's nice
i'd like to start taking commissions when i'm skilled enough with dpy but I think i'm a fair ways away from that point yet
most of the commissioned discord bots are not done very well so it's ok ahaha
I've noticed there's a lot of them that are like half done
Making sure mine aren't falling into that category
yeah i'm doing my best to make sure I don't leave any loose ends or anything wrong with the bot i'm working on rn
Making a bot isn't a huge problem, but making a bot with a unique feature is very hard
This is true
ye
that is the aim with my bot...a fun unique bot that plays a bunch of different games such as blackjack, poker, slots, roulette etc.... as well as many other types of casino-style (and other) games
it has it's own currency system and I started working on stuff like achievements and xp ranks to go alongside all that, but they need polishing
There's only one other split leveling system that I know of and it's got a subscription fee so
that's my uniqueness lol
The rest I've made have been done before but imo mines better
make a whole new class?
Yea for a new view
you can disable individual buttons (which greys them out but they are still there) in a given view but.. I do not think you can make 1 button entirely disappear without making all the other buttons in that view disappear
You can make them disappear
!d discord.ui.View.remove_item
remove_item(item)```
Removes an item from the view.
This function returns the class instance to allow for fluent-style chaining.
Just thought he was going for another view
to remove a single button
oh my bad, didn't know about this
ur good
lass button_view(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
self.value = None
self.timeout = None
class second_view(discord.ui.View):
def _init_children(self) -> List[Item[Self]]:
return super()._init_children()
Why isn't discord.ui.View an ABC internally? Logically it seems like you'd want ui.View to be an ABC that users of the library can provide concrete impls for
good question
I can't think of a scenario where you wouldn't want to inherit from discord.ui.View
maybe it's just for like link components? being able to initialize it directly
mh
The meaning of abstract class is a class which has "abstract" methods bound to it
But for the case of View there is also concrete implementations internally so it wouldn't be an ABC
The only thing "abstract" would be user defined callbacks
make a pull request
mh yea true
lol
ur prob right
I'm simple-minded
Honestly I mostly avoid ABCs I usually just use Protocols if I need something like that
But I generally only write abstract classes one in a blue moon
Random thoughts after I've already laid in bed - is there a way to pull up a list of emojis in a slash command similar to how discord.Member pulls up a list of members? Or do I just need to accept it as string
emojis not buttons my bad
"In a slash command" - you mean the response to a slash command?
Like the autocorrect bs of a slash command. Where you hit / and click the command you want, then select a subcommand emoji and it let's you scroll emojis
You'll probably need to accept it as a string then do some parsing
Because the discord API wrapper itself (not discord.py) has no Emoji type for command options
But I don't know if discord.py has made a converter for it
Is there a character limit on the description of a slash command?
Yes, 1-100 characters
Alright. Because I tried a handful of things earlier with no luck then gave up and changed it to str lol
You could try discord.Emoji as the converter but I don't think it'll work
It doesn't
yo , does anyone got any good docs on how to learn mysql? i only know mongodb atm but wanna learn mysql
I forget the error but .Emoji gives an error. I didn't try partial
Do you want to learn MySQL itself (RBDMS) or SQL the actual language
Yea I would try partial it could work ig, there is a converter for it
uhh, mysql ?
not exatly sure what ya mean, ive never understood dbs i just know how to use it lol
I'll give it a try tomorrow and if it doesn't work probably just accept defeat and continue to lurk around watching for someone else to have that question and get an answer lol
MySQL would be teaching you like, what data types MySQL supports, how to setup the DB
SQL is the actual language you use to query the database
It's sorta useless to have a SQL database without knowing SQL
ahh ya ya sql then
SQLBolt provides a set of interactive lessons and exercises to help you learn SQL
i know the the basics to it but not complete
You should check out the pins in #databases there is more resources there
oh yeah i know all this
i just need to learn mysql then
or better sqlite, tried before but couldnt find any py docs for it
π
Also you should be using an async driver for sqlite3 or mysql for discord.py as if you use the regular drivers you will be blocking your event loop
does it automaticly make the file?
I don't know about sqlite nor MySQL I've only used PostgreSQL
how do i do this? i kknow i got this for my mongo setup but being honest i just copy the block of code in all my projects since it makes 0 sense to me then just use self.bot.database.collection.etc..
ahh kk, thanks for helping tho !
ya
class MongoConnection:
def init(self, bot, config):
def generate_url():
credentials = config["database"]
global url
url = "mongodb://{username}:{password}@{host}:{port}/{database}".format(
username=credentials["mongoUsername"],
password=credentials["mongoPassword"],
host=credentials["mongoHost"],
port=credentials["mongoPort"],
database=credentials["mongoDatabase"],
)
url += "?authSource=admin"
return url
self.bot = bot
debug = False
self.client = AsyncIOMotorClient(
generate_url()
) # Mongo connection client
self.db = self.client[
config["database"]["mongoDatabase"]
]
self.botinfo = self.db.botinfo # Mongo levels collection
self.tickets = self.db.tickets # Mongo tickets collection
self.suggestions = self.db.suggestions # Mongo suggestions collection
self.botdata = self.db.botdata # Mongo botdata collection
i only made half of this my bf made the other half since i was confused af
then to access i just await interaction.client.database.suggestions.find_one
or self.bot
collection.find_one(...) -> regular driver
await collection.find_one(...) -> async driver
``` you want to find an async driver for sqlite or MySQL since discord.py is using an asynchronous environment
You have aiosqlite or aiomysql
so im guessing i gotta do something like this to connect bu tinstead of self.collection i just do self.database = the mysql cursor
idk ill mess around with it, tyy
u leaked your token 
This isn't even python
thats javascript mate
yea
lmao
Glad everyone else was typing when I exited the image to type lmao
Make sure your package.json is configured to have "type": "module" or something similar
this isnt a channel for helping you w discord.js bots its for bots written with python discord api libraries
Oh Sorry Bro
where do i change it?
package.json but fr go to a diff. server intended for javascript lmao
I like the immediate unanimous response of "wtf is that"
it happens every once in a while
a wayward javascript user finds themselves in a python server
Gets gently bullied back to the hole they crawled out of
a new one at that, it seems
We prefer to gently re-direct them :P
We've all gotta start somewhere eh
When your language can add numbers and strings together
I'm stuck in my old ways of gently bullying so I try to stay out of the redirects lol
when your language can add any 2 datatypes together
Chaos.
Indeed
js?
for the win
cap
I really could not find the option that you tell me Robin
You have to add it yourself
Where are?
Just add it anywhere inside of your package.json, as long as it's within the {}
"type": "module"
TS when your type system is turing complete
I believe rust is too
Yea it should be
So as long as you have recursion it should be turing complete
I also know hindley milner system is turing complete
Traceback (most recent call last):
File "/home/deusopus/.local/lib/python3.10/site-packages/discord/client.py", line 409, in _run_event
await coro(*args, **kwargs)
TypeError: on_ready() missing 1 required positional argument: 'self'
hi
on_ready has self in it
why dont worked
did u do commands.Bot.on_ready or smth?
smth
Show your code
YES I DONT HAVE SOLVE
@client.event
async def on_ready(self):
print(f'Logged in as {client.user} (ID: {client.user.id})')
print('------')
self.add_view = (aboutus())
Why do you have self here
read the full error
because the error said there was one positional argument msising
it should say something about c++ build tools
i read
Traceback (most recent call last):
File "/home/deusopus/.local/lib/python3.10/site-packages/discord/client.py", line 409, in _run_event
await coro(*args, **kwargs)
TypeError: on_ready() missing 1 required positional argument: 'self'
How many times do you want me to tell you
It says in the error
You need Microsoft C++ build tools
no i get it
I go to google and I see no solution
because it says exactly what to do inside the error
ok i install
put args and kwargs
???
Do you even know what self is for
And why are you doing this in on ready
Why do I keep having to tell you don't do shit in on_ready
it said that it was missing in on ready
how do you even open a console to script in
Bro
not really
Go learn python, dpy isn't for beginners
@upbeat gust you should re-read our code of conduct
this attitude is not acceptable for our community
What do you suggest?
in terms of how to act in this situation
I don't see any better way to respond to this guy
then don't
can you just tell me so we can all move on
Tell you what..? I've told you what the problem is, why it's happening, and what to do instead
"van installation package is missing or damaged"
my balls hurt
I did last time, with nearly the exact same issue, and here you are again
wow
!mute 891101494445764638 2d You've been told to cut that out
:incoming_envelope: :ok_hand: applied mute to @polar hazel until <t:1667788411:f> (2 days).
Does that apply to telling people to learn python first?
this is where i learn man
@upbeat gust ^
thanks mods
yeah, this isn't like Discord.py's server.
neither are we
I have told you everything you need to know but ok
In the meantime, maybe have a look at oop basics
https://realpython.com/python3-object-oriented-programming/
ok
ill show you something that i made
on my own
import random
print("Play until you win!")
print("Rock, Paper, or Scissors?")
class GameEngine:
def __init__(self, computer):
self.computer = computer
starter = GameEngine(random.choice([-4,-2,-1]))
class Player:
def __init__ (self, options):
self.options = options
play = Player({"rock":4,"paper":2,"scissors":1})
class ScoreBoard:
def __init__(self, score, loss):
self.score = score
self.loss = loss
while True:
match = ScoreBoard(play.options[input("Choose: ")]+starter.computer,[0,-1,-2,3])
if match.score in match.loss:
starter.computer = 0
else:
print("You win!")
break
this is when i figured out OOP
Cool
Have you look on the 4 most important principles it depends on? I've seen plenty of users that use OOP but dont know about them and i do recommend you check them out
and uh this doesn't really seem like something you'd even use classes for anyway
im just wondering if you aren't here to commit to the community standards why are you here
don't you have something better to do
i believe inheritance is one
im writing down poly and abstact
im sorry i forgot what you told me chrispy
this is getting weird i think i should go
im in desperate need of assistance right now can someone please help me with my bot
on it xD
This code works only when I run it on Replit, it doesnt send anything if i run it in my pc.
It is supposed to send 2 images in the same embed. I have the same libraries installed (discord 2.0.0, discord.py 2.0.1)
what happens
does anything work? does anything get printed to console?
how to make a condition to a message which is sent by someone
like if the person(ID) sends (something) then do (this)
like this
message.author
https://paste.pythondiscord.com/fekihoxata
thats my giveaway code and when i do the end command its sending a winner but in the create command it does nothing it doesnt edit the message to py endEmbed=nextcord.Embed(title=f"π **{prize}** π",description=f"> **Ends:** <t:{utc_time}:R>\n" f"> **Hosted By:** {interaction.user.mention}\n" f"> **Winner:** {winner.mention}")
bc its just sending a winner but does nothing w the real giveaway
why are u sleeping inside the create function?
oh no
i see
does anything work at all after your sleep function?
wdym sleep
yes, it doesn't
I really need help I checked the relevant discord.py, but I still cant figure out how I can get the task arguments to read the set datetime.time
try doing time=time
not work, it always shows loop() takes 0 positional arguments but 1 was given
I can't understand why and how to fix
prob bcs of the time arg passed
and taks.loop doesnt accept a positional arg
ahhh help
How do i fix it?
Since I read about discord.ext.tasks it says Read-only list for the exact times this loop runs at, after that I looked at the related datetime list..
tbh idk
!d discord.ext.tasks.loop
@discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/latest/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
I'm not at home rn so I cant check
time (Union[datetime.time, Sequence[datetime.time]]) β
The exact times to run this loop at. Either a non-empty list or a single value of datetime.time should be passed. Timezones are supported. If no timezone is given for the times, it is assumed to represent UTC time.
This cannot be used in conjunction with the relative time parameters.
and it's a keyword-only argument
There is now a special extension for just creating background loops:
from discord.ext import tasks
@tasks.loop(seconds=5)
async def my_loop():
print('Hello World')
my_loop.start()```
The time until which the above loop will run is dependent upon human psychology, laws of energy and cosmos.
That is:
β’ You get bored of it
β’ The power goes down and your script stops working
β’ The universe explodes
Read more about it here: https://discordpy.readthedocs.io/en/latest/ext/tasks/
prob something like that
so @task loop () this parameters should be put my timezone?
https://paste.pythondiscord.com/fekihoxata
thats my giveaway code and when i do the end command its sending a winner but in the create command it does nothing it doesnt edit the message to py endEmbed=nextcord.Embed(title=f"π **{prize}** π",description=f"> **Ends:** <t:{utc_time}:R>\n" f"> **Hosted By:** {interaction.user.mention}\n" f"> **Winner:** {winner.mention}")
bc its just sending a winner but does nothing w the real giveaway
I'm not familiar with that library buy the problem may be the format of your description
okay ill try
I would put them all in 1 set of parentheses on 1 line
That shouldn't be the problem
Hi people ! I'm trying to write the following function pep8 friendly:
response = await bot.wait_for('message', check=lambda message: head(await filter_user(ctx,bot, message) for _ in '_'))
I tried this but I'm not convinced and i don't really know what channel is most suited for this question:
response = await bot.wait_for('message',
check=lambda message:
head(await filter_user(ctx,
bot,
message) for _ in
1 min
hiiii sarth <3
yo this is what black ( #black-formatter ) suggests ```py
response = await bot.wait_for(
"message", check=lambda message: head(await filter_user(ctx, bot, message) for _ in "_")
)
btw you don't need to pass bot there in the function explicit
doesnt work
just use ctx.bot, it will give you the bot
do u know whats the problem
#------------------Width counter (72 chars)-----------------------------
response = await bot.wait_for(
"message", check=lambda message: head(await filter_user(ctx, bot, message) for _ in "_")
)
See this is the problem, I'd like to follow pep-8 rule that says width of code shouldn't exceed 72 chars
well that pep is a bit outdated relative to nowadays screens which are bigger in width
response = await bot.wait_for(
"message",
check=lambda message: head(
await filter_user(ctx, bot, message) for _ in "_"
),
)
``` for 72 chars^

