#discord-bots

1 messages Β· Page 122 of 1

slate swan
#

great!

#

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}")```
cold sonnet
#

you did not just type that

cloud dawn
#

your lol

slate swan
#

your actually ASscary

south coyote
#
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'
cloud dawn
cold sonnet
#

you'res

vale wing
#

u'rr's

slate swan
cold sonnet
#

you shouldn't've'd typed that

vale wing
slate swan
#
role = guild.get_role(id) or await guild.fetch_role(id)
cold sonnet
cloud dawn
#

head

cold sonnet
#

I'm trynna sound British

vale wing
#

Screw having head fr

cloud dawn
#

wot

cold sonnet
#

why did you edit that to head

slate swan
vale wing
#

I make discord bots what do I need the head for

slate swan
cold sonnet
cloud dawn
slate swan
#

cuz its not connected even though i made a class

cloud dawn
#

Where does it stop?

south coyote
#

now im confused

#

getch?

slate swan
#

bro see the next message

slate swan
cloud dawn
# south coyote getch?

Get and fetch it's a method that tries to get it from cache first, if it fails, fetch it.

cloud dawn
cloud dawn
#

Adding some prints etc

slate swan
#

OHH

south coyote
#

thanks guys

slate swan
#

yes okay

#

tbh the method should be able simply accept a discord.Object since all it needs is an ID weirdsip , but meh discord.py moment

cloud dawn
#

Just make 1 method to rule them all.

slate swan
#

loooli let the users make the request payload

cloud dawn
slate swan
#

yep its not reading the end class

south coyote
#

@slate swan like this huh?

await interaction.user.add_roles(interaction.user.get_role(985708739392839720))
#

that would work in python

slate swan
# slate swan

your error handler is faulty, add an else: raise error at the end of it

slate swan
south coyote
#

yeah i did

cloud dawn
#
try:
  bot.run(...)
except:
  pass
slate swan
slate swan
cloud dawn
#

no dont πŸ˜‚

slate swan
#

OH

cloud dawn
#

It was a joke

slate swan
#

oh lol

#

running the bot with an ellipse yeah Yeah

south coyote
#

guild is not defined anywhere

slate swan
#

interaction.guild will be the guild

south coyote
#

why doesn't this work?

await interaction.user.add_roles(interaction.guild.fetch_role(985708739392839720))
slate swan
#

you need to await the fetch_role

cloud dawn
unkempt canyonBOT
#

@cloud dawn :white_check_mark: Your 3.11 eval job has completed with return code 0.

{5: ({...}, 5)} 5
slate swan
#

cursed

south coyote
#

omg this is getting too confusing

#

im so sorry

cloud dawn
south coyote
#

that's my kind of code there

cloud dawn
#

But like Sarth said use the getch

south coyote
#

now you're messing with me

slate swan
south coyote
#
@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)
maiden fable
cloud dawn
cloud dawn
south coyote
#

what is this or business

cloud dawn
#

!or

unkempt canyonBOT
#

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.")
south coyote
#

is that the getch part

maiden fable
south coyote
#
await interaction.response.send_message(f"I have given you {interaction.user.get_role(985708739392839720)}!", ephemeral = True)
#

this is line 62

cloud dawn
#

Why would you get the role twice?

south coyote
#

that is a confirmation message

cloud dawn
#

Yes okay but you re-get the role.

south coyote
#
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'
cloud dawn
#

That's because the user isn't in the cache.

south coyote
#

hmmm

cloud dawn
#

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

south coyote
#

i know right i would have been done hours ago

#

by myself

cloud dawn
#

That's why every person that helps here always say that he or she is busy coding the bot base lmao.

south coyote
#

so i gotta figure out how to reduce the role to the variable level

cloud dawn
#

Your code looks alright it's just in the wrong place and you're doing a lot of the same things again.

south coyote
#

thanks

#

i want to make a lemmings button so people can ban themselves

#

hahahahahaha

lofty lance
#

hey

#

i wana pick the gif link the user send after a command

south coyote
#

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...

β–Ά Play video
lofty lance
#

somethng like
betterdiscord

#

??

south coyote
lofty lance
#

ooo

south coyote
#

its how to assign roles with buttons

lofty lance
#

cool

south coyote
#

i can't believe they dropped it

lofty lance
#

-_-

#

wooo

cloud dawn
# south coyote i know right i would have been done hours ago
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
lofty lance
#

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

cloud dawn
slate swan
south coyote
#

what is ternary

shrewd apex
#

ternary operator

#

do_this if something else do_something_else

cloud dawn
unkempt canyonBOT
#

@cloud dawn :white_check_mark: Your 3.11 eval job has completed with return code 0.

yes
cloud dawn
south coyote
#

that's great man wow

shrewd apex
#

it would be yeah

cloud dawn
#

Hm interesting.

lofty lance
#

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????

slate swan
#

!d discord.Attachment.url

unkempt canyonBOT
#

The attachment URL. If the message this attachment was attached to is deleted, then this will 404.

south coyote
#
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'

cloud dawn
#

get_role

south coyote
#

ah

slate swan
#

discord models are pain in da ass, the documentation is so bad

slate swan
cloud dawn
#

My send link does have text limits etc

slate swan
#

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

verbal monolith
#

RAGHHHH

#

helpy

slate swan
#

you can get faster help if you just mention your issue lol

verbal monolith
#

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

slate swan
#

*want

verbal monolith
#

yes and also

cloud dawn
# slate swan its 5 and its not documented anywhere there

"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

sick birch
#

Yes

verbal monolith
#

noone told me that using :```py
import discord

@client.event
async def on_ready():``` was bad

sick birch
#

One text input per row

cloud dawn
verbal monolith
#

apparently its outdated

cloud dawn
#
print('We have logged in as {0.user}'.format(client))
``` this is more cursed.
verbal monolith
#

compared to py @bot.command() async def ping(ctx): await ctx.send("pong")

verbal monolith
cloud dawn
#

Could you send the error?

sick birch
#

You're comparing apples to oranges

verbal monolith
#

there isnt an error per se

#

but i wanna add commands

cloud dawn
verbal monolith
cloud dawn
#

I prefer strawberries or pears :3

verbal monolith
#

wow...

south coyote
#

how do you get the button to disappear after use

#

ill google it

slate swan
cloud dawn
verbal monolith
#

how do i add commands then

#

apparently they conflict

cloud dawn
#

This code should still work.

slate swan
cloud dawn
slate swan
#

itzzz one selectmenu per row CL_dance

verbal monolith
#

ok so how do i add commands then

sick birch
slate swan
south coyote
#

hmmm

verbal monolith
verbal monolith
#

how to convert/

#

i dont understant the noted D:

sick birch
#

You have a perfectly working command handler right there

verbal monolith
#

that doesnt work tho

sick birch
#

How so?

verbal monolith
#
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")```
slate swan
#

you gotta enable message_content intents

verbal monolith
#

oh so

#

no i did ?

slate swan
#

in the code as well!

verbal monolith
#

do u mean this

#
intents = discord.Intents.default()
intents.message_content = True
client = commands.Bot(command_prefix='!', intents=intents)```
slate swan
#

!intents instead of members it will be message_content for you

unkempt canyonBOT
#

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.

south coyote
#

hey Robin!

#

happy to see you

verbal monolith
#

'Intents' object attribute 'message_content' is read-only

#

'Intents' object has no attribute 'message_content'

sick birch
#

howdydo

south coyote
#

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

slate swan
#

any reason why I shouldn't be using discord.Intents.all()?

south coyote
#

i use it

sick birch
#

Waste of resources

slate swan
#

Fair enough.

south coyote
#

see

#

i toldyou i use it

sick birch
#

hahaha

south coyote
#

im all about that unecessary strain

sick birch
#

It's convenient in dev but I would suggest remove during prod

south coyote
#

my carbon footprint tho

slate swan
sick birch
#

If you can view invites that's one way

cloud dawn
#

Audit log does report it

slate swan
#

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...).

verbal monolith
sick birch
unkempt canyonBOT
#
Not gonna happen.

No documentation found for the requested symbol.

slate swan
#

wait there was a method, ill be right back

sick birch
#

There's the check screen where you verify all the permissions

slate swan
#

You can un-check those boxes though, I think.

sick birch
#

Ah can you

#

Yeah that sure is an issue

slate swan
#

!d discord.Integration check this class it has an attr for that

unkempt canyonBOT
#

class discord.Integration```
Represents a guild integration.

New in version 1.4.
slate swan
#

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

sick birch
slate swan
#

I was thinking of doing that, then just DM interaction.user if permissions are missing

south coyote
#

hey Robin do you know how to disable a button in discord.py after its been used

#

do you have to define a function?

unkempt canyonBOT
sick birch
#

Set this property to true

#

Then resend the view

south coyote
#

okay

slate swan
#

For example if every command simply requires external emojis and embed links

slate swan
unkempt canyonBOT
#

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
slate swan
#

Thanks.

south coyote
#

like this.....?

sick birch
lofty lance
#

how can i mention a new member who joind the server

#

i am using member.mention under on_member_join

slate swan
sick birch
#

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

slate swan
#

Yeah that makes sense thank you

south coyote
#

how do i set it to true?

slate swan
lofty lance
slate swan
#

well what did you try so far

lofty lance
#

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

honest shoal
#

so earlier the code was working, then it suddenly stops working?

#

and you didn't change anything?

lofty lance
#

yaaa

#

like that

honest shoal
#

then show the code

lofty lance
honest shoal
#

I cannot help if you don't post the code or any error

lofty lance
#

pls ignore the channel error

honest shoal
#

if it's big then paste here πŸ‘‡

unkempt canyonBOT
#

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.

lofty lance
#

and many pending things

#

i will try wait pls

slate swan
#

Probably you updated to dpy 2.0 since those months past and your code broke as a result

honest shoal
honest shoal
lofty lance
honest shoal
#

send the link

lofty lance
honest shoal
#

I don't really like the way you made it, it's messy

lofty lance
honest shoal
#

and events are inside a function, just use cogs

lofty lance
#

oke sir

#

i will do all that once i made it send succesfull welcome message

#

thats the aim for now

south coyote
#

im supposed to edit a message and change the view

#

i have now clue

#

ho hum

honest shoal
slate swan
honest shoal
#

and you don't need try/except, the library provides you error if bot fails to send

lofty lance
south coyote
#

but where

naive briar
#

!d discord.Message.edit

unkempt canyonBOT
#

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`.
lofty lance
south coyote
#

oh

lofty lance
#

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

south coyote
#

await interaction.message.edit(content = None, view=button_view())

#

like that i guess?

lofty lance
south coyote
#

no im trying to figure out how to edit a message and then disable it and refresh the view

primal token
#

You can also consider mongodb for a JSON like db

lofty lance
primal token
#

Sure

glad cradle
primal token
south coyote
#

i gotta disable the button so i gotta run the button snippet twice

#

once again at the end

glad cradle
#

mh?

south coyote
#

so i guess i use the message id right

#

or the button id

glad cradle
#

Not necessarily

#

you can use the Interaction object

verbal monolith
#

can someone give me an example of discord.ext.commands being used?

south coyote
#

this is what im figuring out

await interaction.edit(view=button_view())
verbal monolith
#

aka command()

south coyote
#

app_commands

south coyote
#

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
glad cradle
#

discord.Interaction.edit doesn't exist

south coyote
#

ok

glad cradle
#

!d discord.Interaction.edit_original_response

unkempt canyonBOT
#

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.
south coyote
#

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

sick birch
#

Resend view

#

Easy as that

south coyote
#

how do i set the disabled on it

sick birch
#

button.disabled = True

#

Where button is the button instance

south coyote
#

hmmm

#

await button.disabled(True, view=button_view())

primal token
#

It's a property not a method?

south coyote
#

async def get_mod(self, interaction: discord.Interaction, button: discord.ui.Button) -> None:

sick birch
#

And then await interaction.edit_original_response(view=self)

glad cradle
#

ig he's defining his button with a decorator so that's his difficulty to set button.disabled = True

primal token
#

It's not really difficult

glad cradle
#

ik

slate swan
#

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

primal token
#

You can also check the children of the view, multiple options depending on the use case

slate swan
#

the children way is most convenient

primal token
#

🀨

south coyote
#

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())
glad cradle
#

nah the best way is use the button param of the callback

primal token
minor totem
south coyote
#

not really

#

i got some hints from googling around and watching videos

unkempt canyonBOT
#

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)```
south coyote
#

plus you guys helped a lot

minor totem
#

Sorry that was a pointless question

south coyote
#

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

minor totem
# primal token > It's a property not a method?

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

minor totem
slate swan
#

!d discord.ui.Button.disabled

unkempt canyonBOT
south coyote
#

thats what

primal token
# south coyote i admit

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

south coyote
#

about a month

#

i really only started getting classes within the last month or so

vague moon
#

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?

primal token
primal token
slate swan
#

wait this is not it, just a minute

minor totem
# south coyote i am somewhat slow to this

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)
primal token
minor totem
unkempt canyonBOT
#

discord/components.py line 187

self.disabled: bool = data.get('disabled', False)```
slate swan
minor totem
vague moon
minor totem
slate swan
#

!e ```py
value = 0o01
print(value)

unkempt canyonBOT
#

@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.

1
vague moon
slate swan
#

but what's your usecase tho?

vague moon
#

im just wondering how it works

slate swan
south coyote
#

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())
minor totem
unkempt canyonBOT
#

@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
south coyote
#

there she be

slate swan
#

i just used it once for an tinyint

#

well using a string is always an option

slate swan
minor totem
unkempt canyonBOT
#

@minor totem :white_check_mark: Your 3.11 eval job has completed with return code 0.

0000418673016093016066
minor totem
slate swan
#

also returned as a string into the payload

minor totem
#

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

slate swan
#

so thats my giveaway command and when i end the giveaway its not changing to the end embed

minor totem
#

Well, you have an if-statement there, are you sure it works?

slate swan
#

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

topaz helm
#

can someone help me how to see how many servers my bot is on? you mean a command or something?

glad cradle
#

!d discord.ext.commands.Bot.guilds

unkempt canyonBOT
glad cradle
#

len(bot.guilds)

south coyote
#

so i have to make a new view class for each button?

hoary canyon
#

hi guys does someone know why im getting an error. Im new and dont really understand

south coyote
#

you gotta put quotes around the key and you have to renew it now since you share dit

hoary canyon
glad cradle
hoary canyon
#

once again does i dont know why its giving me an error

unkempt canyonBOT
#

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.

shrewd apex
#

...

south coyote
#

holy moly

#

its pretty jumbled huh

#

i think i figured it out actualy

slate swan
#

question, what imports did you use for that?

south coyote
#

let me see

#

import discord
from discord import app_commands

slate swan
#

what exactly needs sorted out? what is the issue

south coyote
#

its not posting the button

slate swan
south coyote
#

it's giving me errro cant

#

hold on

#

yeah that's all

naive briar
#

What even is self.interaction

slate swan
south coyote
#

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)
slate swan
#

what is self.ctx ?

south coyote
#

its a variable

#

it was on the web

#

on stack

slate swan
#

idk what ur doing.

alpine cove
#

yeaa

slate swan
#

you should learn the basics or at least read the docs

south coyote
#
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

slate swan
#

look at what ur error says

#

its giving u the answer

south coyote
#

there is no ctx

#

for interaction object

#

that means i need to put something instead of ctx

slate swan
#

i think its message

#

try that

#

i mean partially yea also button interactions are MessageInteractions

slate swan
slate swan
#

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

slate swan
south coyote
#

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

slate swan
#

the tutorial did not say to do self.ctx inside of an interaction

south coyote
#

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

slate swan
#

a teacher has nothing to do with you actually taking the time to learn

south coyote
#

dude i am learning i learn this way

#

nm

#

im gonna go

#

im sorry that i bothered you sir

south coyote
#

good luck man this is a touchy crowd at lunchtime

slate swan
# slate swan someone answer

well the class name (Context) already explains pretty much
it stores information about how & where the command was invoked

glad cradle
#

!d discord.ext.commands.Context

unkempt canyonBOT
#
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.
slate swan
mighty pilot
# south coyote on stack

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

south coyote
#

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

slate swan
#

!d discord.ui.Button

unkempt canyonBOT
#

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.
slate swan
#

!d discord.ui.button

unkempt canyonBOT
#

@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.
slate swan
#

!d discord.Interaction

unkempt canyonBOT
#

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.
slate swan
#

@south coyote

south coyote
#

thx

slate swan
#

np

south coyote
#

!d discord.Message

unkempt canyonBOT
#

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.
slate swan
#
@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?
south coyote
#

yup

slate swan
south coyote
#

anything you want

#

kinda

slate swan
#

example?

south coyote
#

depends on the type of buton

slate swan
#

ugh

south coyote
slate swan
#

aaaa nothing works

#

everything works you just don't use them properly

hollow agate
#

Don’t follow tutorials. They all suck and are outdated.

south coyote
#

@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

slate swan
#

gtg for now

hollow agate
#

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 blobgrimacing

slate swan
south coyote
#

that's opinion man

slate swan
hollow agate
#

90% of devs will say to not use tutorials

winged coral
#

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

sick birch
#

However much you like the youtube video format, I just can't recommend people learn misinformation and build bad habits

winged coral
#

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

slate swan
#

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

unkempt canyonBOT
#

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.

slate swan
#

thx

#

ah

#

i see

slate swan
#

also can i call the bot variable client

#

well you explicitly mentioned "not slash command" so what do you think aaaa_stress

slate swan
#

if yes, go for it

slate swan
#

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)

alpine cove
#

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

hushed galleon
#

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

slate swan
slate swan
hushed galleon
#

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

slate swan
hushed galleon
#

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)

slate swan
#

Of course. I didn't realise this before but it makes sense now. Guess that makes me still a Python noob.
Thanks!

mighty pilot
#

How would I go about mentioning all users from a list not knowing the size of the list

unkempt canyonBOT
#

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.
alpine cove
#

or a for loop if you want to send multiple messages

mighty pilot
#

I was trying a for loop with a single message and it wasn't working out for me lol

alpine cove
#

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']

south coyote
#

so i guess you cant create and embedded message from a button click

alpine cove
#

and using .join we put the , in between of all of the mentions

south coyote
#

im so done

alpine cove
#

this will return smth like:
@alpine cove, @alpine cove

south coyote
#

dude

#

dont tell me that

mighty pilot
#

Lol

alpine cove
south coyote
#

nah

alpine cove
#

don't assume genders in 2022 lol

#

just googled it lmfao

south coyote
#

lol

alpine cove
#

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?

south coyote
#

you can

alpine cove
#

i cant

mighty pilot
#

He means reactions

south coyote
#

oh wait in here

alpine cove
south coyote
#

i thought you meant bots

hushed galleon
alpine cove
slate swan
#

no reaction perms why_crying

mighty pilot
#

I was wondering the same thing a couple days ago

south coyote
#

can you go to a million on an emoji

mighty pilot
#

But we can add reactions in the general chats

alpine cove
south coyote
#

there's a bot for that

alpine cove
#

I thought you might be able to change perms

south coyote
#

there's a bot for that on my server

mighty pilot
mighty pilot
alpine cove
#

np

mighty pilot
alpine cove
#

lets see how long it'll take

mighty pilot
#

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 thisvulpix

slate swan
#

so yes you can do lots things with buttons that you can regular commands

alpine cove
#

for example: Modals

mighty pilot
#

Maybe not half, but a large amount nonetheless

slate swan
alpine cove
slate swan
#

And thanks I'm very proud of the game :-)

slate swan
mighty pilot
#

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 PikaF

#

HwAt

slate swan
alpine cove
mighty pilot
#

Can we start a petition

alpine cove
slate swan
mighty pilot
#

Am I allowed to send a link to my bots top.gg here?

slate swan
#

You can DM me it if you'd like

mighty pilot
#

It's much easier than typing it out again

alpine cove
slate swan
#

I don't think the mods will let you

alpine cove
#

just dm it to us

#

actually

mighty pilot
#

Sentx2

alpine cove
#

idk

mighty pilot
#

Really wish I could plug it more places. I need feedback lol

south coyote
#

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

slate swan
#

I appreciate the help I've gotten here as well

south coyote
#

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

mighty pilot
mighty pilot
slate swan
#

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

mighty pilot
#

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

slate swan
#

nice best of luck with the new bot

#

i should make monopoly bot πŸ₯Ά

mighty pilot
#

A MONOPOLY BOT

#

I don't even want to play that let alone code it

glad cradle
#

I have never created a complete discord bot, I prefer to throw myself into the internals of disnake πŸ˜Άβ€πŸŒ«οΈ

slate swan
mighty pilot
#

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

slate swan
mighty pilot
#

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

slate swan
#

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

glad cradle
#

most of the commissioned discord bots are not done very well so it's ok ahaha

mighty pilot
#

I've noticed there's a lot of them that are like half done

#

Making sure mine aren't falling into that category

slate swan
#

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

pliant gulch
#

Making a bot isn't a huge problem, but making a bot with a unique feature is very hard

mighty pilot
#

This is true

slate swan
#

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

mighty pilot
#

There's only one other split leveling system that I know of and it's got a subscription fee so flexpoli that's my uniqueness lol

#

The rest I've made have been done before but imo mines better

mighty pilot
#

Yea for a new view

slate swan
#

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

mighty pilot
#

You can make them disappear

alpine cove
unkempt canyonBOT
#

remove_item(item)```
Removes an item from the view.

This function returns the class instance to allow for fluent-style chaining.
mighty pilot
alpine cove
slate swan
#

oh my bad, didn't know about this

alpine cove
#

ur good

south coyote
#
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()
sick birch
#

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

alpine cove
#

I can't think of a scenario where you wouldn't want to inherit from discord.ui.View

sick birch
#

maybe it's just for like link components? being able to initialize it directly

alpine cove
#

mh

pliant gulch
#

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

south coyote
#

make a pull request

south coyote
#

lol

alpine cove
#

I'm simple-minded

pliant gulch
#

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

mighty pilot
#

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

sick birch
#

"In a slash command" - you mean the response to a slash command?

mighty pilot
#

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

pliant gulch
#

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

slate swan
#

Is there a character limit on the description of a slash command?

pliant gulch
#

Yes, 1-100 characters

mighty pilot
#

Alright. Because I tried a handful of things earlier with no luck then gave up and changed it to str lol

pliant gulch
#

You could try discord.Emoji as the converter but I don't think it'll work

mighty pilot
#

It doesn't

pliant gulch
#

But it might so, give it a try ig

#

What about discord.PartialEmoji?

indigo pilot
#

yo , does anyone got any good docs on how to learn mysql? i only know mongodb atm but wanna learn mysql

mighty pilot
#

I forget the error but .Emoji gives an error. I didn't try partial

pliant gulch
pliant gulch
indigo pilot
mighty pilot
#

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

pliant gulch
#

SQL is the actual language you use to query the database

#

It's sorta useless to have a SQL database without knowing SQL

indigo pilot
#

ahh ya ya sql then

pliant gulch
indigo pilot
#

i know the the basics to it but not complete

pliant gulch
#

You should check out the pins in #databases there is more resources there

indigo pilot
#

i just need to learn mysql then

#

or better sqlite, tried before but couldnt find any py docs for it

pliant gulch
#

πŸ‘€

#

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

indigo pilot
#

does it automaticly make the file?

pliant gulch
#

I don't know about sqlite nor MySQL I've only used PostgreSQL

indigo pilot
indigo pilot
pliant gulch
#

Well did you await your mongo db queries?

#

like await collection.find_one

indigo pilot
#

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

pliant gulch
#
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

indigo pilot
#

oo

#

ty!

indigo pilot
#

idk ill mess around with it, tyy

#

u leaked your token pepeLauth

dim bloom
#

sorry

#

hahaha

#

i need help with this SyntaxError i am new in the programation

wary crystal
#

This isn't even python

idle fable
alpine cove
#

yea

indigo pilot
#

lmao

mighty pilot
#

Glad everyone else was typing when I exited the image to type lmao

sick birch
idle fable
dim bloom
#

Oh Sorry Bro

sick birch
#

You're currently probably using CommonJS

#

but aye wrong server

dim bloom
#

where do i change it?

sick birch
#

In your package.json

#

I suggest further questions be directed to an off topic

idle fable
mighty pilot
#

I like the immediate unanimous response of "wtf is that"

sick birch
#

it happens every once in a while

#

a wayward javascript user finds themselves in a python server

mighty pilot
#

Gets gently bullied back to the hole they crawled out of

idle fable
sick birch
#

We prefer to gently re-direct them :P

sick birch
wary crystal
#

When your language can add numbers and strings together

mighty pilot
#

I'm stuck in my old ways of gently bullying so I try to stay out of the redirects lol

sick birch
#

when your language can add any 2 datatypes together

mighty pilot
#

Chaos.

sick birch
#

Indeed

sick birch
#

typescript for the win

dim bloom
#

I really could not find the option that you tell me Robin

sick birch
#

You have to add it yourself

dim bloom
#

Where are?

sick birch
#

Just add it anywhere inside of your package.json, as long as it's within the {}

#

"type": "module"

wary crystal
sick birch
#

I believe rust is too

wary crystal
#

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

south coyote
#
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'

slate swan
#

hi

south coyote
#

on_ready has self in it

slate swan
#

why dont worked

alpine cove
slate swan
#

please help me pip install discord dont work

south coyote
#

smth

upbeat gust
#

It tells you exactly what to do above

upbeat gust
slate swan
south coyote
#
@client.event
async def on_ready(self):
    print(f'Logged in as {client.user} (ID: {client.user.id})')
    print('------')
    self.add_view = (aboutus())
slate swan
#

PLS I CANT RESOLVE

upbeat gust
south coyote
#

because the error said there was one positional argument msising

upbeat gust
#

it should say something about c++ build tools

slate swan
south coyote
#
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'
upbeat gust
slate swan
#

again

#

the same error

upbeat gust
#

How many times do you want me to tell you

#

It says in the error

#

You need Microsoft C++ build tools

south coyote
#

no i get it

slate swan
#

I go to google and I see no solution

upbeat gust
#

because it says exactly what to do inside the error

slate swan
#

ok i install

south coyote
#

put args and kwargs

upbeat gust
#

???

#

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

south coyote
#

it said that it was missing in on ready

polar hazel
upbeat gust
upbeat gust
#

Do you know how to read errors

south coyote
#

not really

upbeat gust
#

Go learn python, dpy isn't for beginners

blissful lagoon
#

@upbeat gust you should re-read our code of conduct

#

this attitude is not acceptable for our community

upbeat gust
upbeat gust
#

I don't see any better way to respond to this guy

blissful lagoon
#

then don't

south coyote
#

can you just tell me so we can all move on

upbeat gust
#

Tell you what..? I've told you what the problem is, why it's happening, and what to do instead

slate swan
#

"van installation package is missing or damaged"

south coyote
#

the solution

#

i just want to make it work man

#

ill learn from this

polar hazel
#

my balls hurt

upbeat gust
south coyote
#

wow

upbeat gust
#

Don't you remember how you finally put sync in setup_hook

#

do that for this too

blissful lagoon
#

!mute 891101494445764638 2d You've been told to cut that out

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied mute to @polar hazel until <t:1667788411:f> (2 days).

upbeat gust
south coyote
#

this is where i learn man

blissful lagoon
#

@upbeat gust ^

south coyote
#

thanks mods

zinc jacinth
south coyote
#

do they help in there?

#

im not getting paid for what im doing

upbeat gust
#

neither are we

south coyote
#

i knew you would say that

#

see you later then

upbeat gust
#

I have told you everything you need to know but ok

south coyote
#

i wish i was as smart as you man

#

i just want to take a break now

#

i appreciate it

upbeat gust
south coyote
#

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

upbeat gust
#

Cool

primal token
upbeat gust
#

and uh this doesn't really seem like something you'd even use classes for anyway

south coyote
#

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

primal token
#

Yep

#

Inheritance, Polymorphism, encapsulation and abstraction

south coyote
#

im writing down poly and abstact

#

im sorry i forgot what you told me chrispy

#

this is getting weird i think i should go

south coyote
#

im in desperate need of assistance right now can someone please help me with my bot

alpine cove
#

on it xD

trail sandal
#

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)

upbeat gust
#

does anything work? does anything get printed to console?

prisma pivot
#

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

slate swan
#

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?

slate swan
vocal snow
#

yes, it doesn't

toxic turtle
#

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

toxic turtle
alpine cove
#

and taks.loop doesnt accept a positional arg

toxic turtle
vocal snow
unkempt canyonBOT
#

@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").
alpine cove
#

I'm not at home rn so I cant check

vocal snow
# unkempt canyon

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

alpine cove
#

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

toxic turtle
slate swan
#

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

mighty pilot
mighty pilot
#

I would put them all in 1 set of parentheses on 1 line

naive briar
#

That shouldn't be the problem

cerulean folio
#

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 
slate swan
#

1 min

cerulean folio
slate swan
#

btw you don't need to pass bot there in the function explicit

slate swan
#

just use ctx.bot, it will give you the bot

slate swan
cerulean folio
#
#------------------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

slate swan
#
    response = await bot.wait_for(
        "message",
        check=lambda message: head(
            await filter_user(ctx, bot, message) for _ in "_"
        ),
    )
``` for 72 chars^