#discord-bots

1 messages Β· Page 938 of 1

hybrid mural
#

should i send the cog?

slate swan
#

just edit the message with a new embed?

cold sonnet
#
async def giveaway(self, ctx, time, *, prize):
        
        giveawayembed = nextcord.Embed(
            title="πŸŽ‰ New Giveaway! πŸŽ‰",
            color=0xfd9fa1
            )
        time=humanfriendly.parse_timespan(time)
        giveawayembed.add_field(name="Prize", value="{}".format(prize), inline=False)
        giveawayembed.add_field(name="Hosted by", value=f"{ctx.author.mention}", inline=False)
        giveawayembed.add_field(name="Ends in", value="{}".format(time))

        msg = await ctx.send(embed=giveawayembed)

        giveawayembed = nextcord.Embed(
            title="πŸŽ‰ New Giveaway! πŸŽ‰",
            color=0xfd9fa1
            )
        time=humanfriendly.parse_timespan(time)
        giveawayembed.add_field(name="Prize", value="{}".format(prize), inline=False)
        giveawayembed.add_field(name="Hosted by", value=f"{ctx.author.mention}", inline=False)
        giveawayembed.add_field(name="Changed", value="{}".format(time))

        await msg.edit(embed=giveawayembed)
slate swan
#

!d discord.Message.edit | in the embed kwarg set a duplicate embed with the new content in it

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.10)") instead of `InvalidArgument`.
iron sorrel
#

sorry

#

someone pointed out that message

austere vale
cold sonnet
#

....?

#

I copied your code and added the same onto it with a string changed

#

bots have nitro

austere vale
#

yeah i replaced my code with that and it threw me errors when i tried to make a giveaway

minor panther
#

Okey can i solve this problem this way: despite sending button i will ask people to send any message to a channel. This way everything will work?

#

Using bot.wait_formessage

cold sonnet
#

button should work the same

slate swan
#

bots already have that ability similiar to nitro users.

cold sonnet
#

if I click on every emoji in my reaction roles, my reactions are gonna lag even tho the problem's on the bot side

#

or is it just discord

minor panther
#

:(

slate swan
cold sonnet
#

I'm not gonna remove those reactions

#

nor work on buttons 🀫

slate swan
minor panther
#

Yes i had this trouble using reactions, and i started using buttons

#

But now when 200 people in one moment press these buttons

#

Everything crashes

slate swan
minor panther
#

Sheesh

#

But still a lot of ppl are muted without a reason

slate swan
#

i mean you can just use a event but in your case youre using wait for

#

but events are the same so it wouldnt matter

#

so all this conversation was pointlessthink

glacial echo
#
async def startGame(ctx, gameID: int = 2):

is always making gameID == 2 even if i say /start_game 1

#

how would i fix this?

swift imp
#

Why doesn't the "mongo" database add more than 4 members to the database list?

hushed galleon
slate swan
#

Try re-running your code.

slate swan
glacial echo
#

yeah no shit, but it is

slate swan
slate swan
swift imp
slate swan
#

Your question isn't relevant to this channel's topic.

slate swan
swift imp
#

ok, sorry

hushed galleon
slate swan
#

The question was too vague, it's hard to make that argument.

#

And they mentioned the database instead of anything related to dpy breaking

hushed galleon
#

as such, @swift imp you need to share your code and a bit more explanation on what exactly you did for us to figure out if its something wrong with your discord implementation

tacit moss
#

hey 1 thing

if i wanna make a public bot and learn python how can i learn where should i start from ? >> and when i make a public bot i need a DB ? so how do i make one and use it ty for any help

slate swan
#

It's not necessary that if you make a public bot you'll need a database, depends on the functionality of the bot

slate swan
tacit moss
slate swan
unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

hoary cargo
slate swan
#

Weapon?

#

for oop you can search up Corey Schafer async programming probably docs @tacit moss

#

Sure.

untold oriole
#

hey guys is there something like on_raw_reaction_add but for adding roles and removing roles?

slate swan
#

wish i could link tutorials but im on mobile

slate swan
swift imp
hushed galleon
untold oriole
untold oriole
slate swan
#

!d discord.on_member_update

unkempt canyonBOT
#

discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their profile.

This is called when one or more of the following things change:

β€’ nickname

β€’ roles

β€’ pending...
slate swan
#

You don't need a raw event, that's pointless.

untold oriole
#

Oh okay, then thanks!!

slate swan
#

Raw events exist for message events and such because it's not guaranteed that dpy will have the message object cached

#

And Discord only sends partial data for such events

untold oriole
#

ah yea ive noticed that

tacit moss
hushed galleon
slate swan
hushed galleon
tacit moss
swift imp
hushed galleon
#

are there more than 4 unique members/bots across your guilds? looking at your find_one call you dont include the guild id as a key, so each document would (or should) be globally unique

#

oh wait a minute

#

@swift imp

#

btw you should use an async lib for handling a mongo database like motor, otherwise every call to your database would slow down your bot

tacit moss
#

@slate swan so what should i 1st do on a bot

swift imp
hushed galleon
#

maybe not a good idea to attempt inserting 600 posts every time you restart your bot

swift imp
#

yeah

hushed galleon
#

only add a document when they do something like sending a message/using a command that requires checking their money

#

that way you dont burden your startup with lots of requests

craggy cloak
hushed galleon
#

load_extension you should probably do outside of on_ready

supple crescent
#
@bot.command(name = 'order')
async def order(ctx: commands.Context, *, echo: str) -> None:
    msg = await ctx.send(echo)
    await msg.add_reaction("βœ…")
    await msg.add_reaction("❌")
    await ctx.message.delete()


    channel = ctx.channel
    def check(reaction, user, ):
        return user == ctx.author and str(reaction.emoji) in {'βœ…', '❌'}

    try:
        reaction, user = await bot.wait_for('reaction_add', check=check)
    except asyncio.TimeoutError:
        await channel.send('you timed out...')
        return 

    if str(reaction.emoji) == 'βœ…':
        await channel.send('Gotcha! order confirmed')
        channel2 = discord.utils.get(ctx.guild.channels,name = f"private-channel{ctx.author}")
        channel3 = ctx.guild.get_channel(channel2.id)
        await channel3.send(f"<@{user_id}> \n {echo} ")
        await msg.add_reaction("βœ…")
        await msg.add_reaction("❌")

        channel =ctx.channel 
        def check(reaction, user):
            return user == ctx.author and str(reaction.emoji) in {'βœ…', '❌'}

        try:
            reaction, user = await bot.wait_for('reaction_add', check=check)
        except asyncio.TimeoutError:
            await channel.send('you timed out...')
            return 
        if str(reaction.emoji) == 'βœ…':
            return
        else:
            return

    else:
        
        await channel.send('Understood! cancelling order!')

AttributeError: 'NoneType' object has no attribute 'id' for line channel3 = ctx.guild.get_channel(channel2.id)

hushed galleon
craggy cloak
#

That can't be client?

hushed galleon
#

the variable name? sure it can

#

but if you're using commands.Bot then its kind of weird to name it based on another class

supple crescent
ashen stag
#

how can i make a bot respond so when i say a number it adds 1 to it?

#

example

#

human: 234
bot: 235

tidal hawk
#

int(message) + 1

azure tulip
#

How change background in ConEmu?

#

Who is not difficult to explain, I already searched all the settings and didn’t find

final iron
#

What's ConEmu

azure tulip
final iron
#

How is this relevant to this channel?

azure tulip
hushed galleon
#

most discord data you're going to store is well suited for relational databases (per-guild prefixes and settings or per-member currency)

grand verge
#

so where i can ask ?

supple crescent
grand verge
supple crescent
grand verge
#

ok

#

ty

#

ohh , ok man Thx

abstract kindle
#

is there a list of all the events a bot can wait for?

hushed galleon
#

{ctx.author} gets formatted like name#discriminator, and channel names definitely cant have # in them

abstract kindle
#

I'm looking under the docs for discord.py but I can't find anything

#

I'm checking under events, wait_for, etc

#

okay, thanks

hushed galleon
supple crescent
#

so just remove that line altogether?

hushed galleon
#

yeah

supple crescent
#

lets try it

hushed galleon
#

you're going to need a more robust way of storing the private channel that corresponds to the author

supple crescent
#

fuck ok im jut gonna restart this part

hushed galleon
#

writing their user id in the channel name could work, although it wont look that good

slate swan
#

code -

class Select(Select):
    def __init__(self):
        options=[
            discord.SelectOption(label="Option 1",emoji="πŸ‘Œ",description="This is option 1!"),
            discord.SelectOption(label="Option 2",emoji="✨",description="This is option 2!"),
            discord.SelectOption(label="Option 3",emoji="🎭",description="This is option 3!")
            ]
        super().__init__(placeholder="Select an option",max_values=1,min_values=1,options=options)


@client.command()
async def menu(ctx):
    await ctx.send("Menus!",view=Select()
)

error - ```py
Traceback (most recent call last):
File "main.py", line 42, in <module>
class Select(Select):
NameError: name 'Select' is not defined
ξΊ§

supple crescent
#

nah im just gonna use a workaround @hushed galleon

slate swan
#

i tried 20 differ things

supple crescent
#

thanks tho

hushed galleon
#

did you mean to subclass discord.ui.Select?

slate swan
#

Traceback (most recent call last):
File "main.py", line 42, in <module>
class Select(discord.ui.Select):
AttributeError: module 'discord' has no attribute 'ui'

hushed galleon
#

then you need to upgrade to dpy 2.0 / master

slate swan
#

i am?

hushed galleon
#

are you sure

abstract kindle
#

basically I'm wondering if theres a wait_for(event="attachment") or something

hushed galleon
slate swan
#

its in a replit

#

will it still work or..

hushed galleon
#

if you have the right version installed yes

slate swan
hushed galleon
#

like the install link?

slate swan
#

yes

hushed galleon
#

pip install git+https://github.com/Rapptz/discord.py, although on repl.it i believe you should edit poetry.lock rather than run pip in the shell directly

slate swan
#
[tool.poetry]
name = ""
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]

[tool.poetry.dependencies]
python = "^3.8"
psutil = "^5.9.0"
requests = "^2.27.1"
discord = "^1.7.3"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
hushed galleon
#

yeah replit didnt even install the correct package, they used the mirror package

#

replace the discord line with "discord.py" = {git = "https://github.com/Rapptz/discord.py"}

slate swan
#

ur the best

hushed galleon
#

in the repo there's examples of how to use views with buttons/selects

slate swan
#
[tool.poetry]
name = "python-template"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]

[tool.poetry.dependencies]
python = "3.9"
numpy = "^1.22.2"
"discord.py" = {git = "https://github.com/Rapptz/discord.py"}
bs4 = "^0.0.1"
requests = "^2.27.1"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
supple crescent
#

@hushed galleon sorry to bother, how would i get the echo

    if str(reaction.emoji) == 'βœ…':
        await channel.send('Gotcha! order confirmed')
        channel2 = discord.utils.get(ctx.guild.channels,name = f"private-channel{ctx.author}")
        await channel2.send(f"<@{user_id}> \n {echo} ")
        await msg.add_reaction("βœ…")
        await msg.add_reaction("❌")

to work without getting the nonetype error?

slate swan
#

wait do i add

slate swan
#

discord = that or

hushed galleon
#

nah the entire line should be replaced

slate swan
#

oki

hushed galleon
supple crescent
hushed galleon
#

the... channel you tried getting

supple crescent
#

ah

slate swan
#

is this right ```py
[tool.poetry]
name = "python-template"
version = "0.1.0"
description = ""
authors = ["Your Name you@example.com"]

[tool.poetry.dependencies]
python = "3.9"
numpy = "^1.22.2"
"discord.py" = {git = "https://github.com/Rapptz/discord.py"}
bs4 = "^0.0.1"
requests = "^2.27.1"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

hushed galleon
#

yeah

slate swan
#

Traceback (most recent call last):
File "main.py", line 42, in <module>
class Select(discord.ui.Select):
AttributeError: module 'discord' has no attribute 'ui'

#

still this error?

hushed galleon
#

did repl.it try reinstalling discord

slate swan
#

no

hushed galleon
#

can you check the pyproject.toml file again

slate swan
#

ok im here

hushed galleon
#

i just tested it and replit incorrectly added the discord package

slate swan
#

huh?

#

oh

#

they did?

hushed galleon
#

yeah they try to analyse your imports and install packages for you

slate swan
#

how would i do thart

hushed galleon
#

clearly doesnt seem to work well

placid quarry
#

hello

#

does anyone can help me?

hushed galleon
slate swan
#

wouldn’t i do discord =?

hushed galleon
#

no, because the real package isnt named discord

#

replit writes discord because what they're actually installing is the mirror package named discord which is just a copy of discord.py 1.7.3

hushed galleon
slate swan
#

wait so if i did discord 2.0.0

hushed galleon
#

2.0 isnt actually on pypi

#

right now its just another name for the master branch on the discord.py repository

slate swan
#

hey @hushed galleon i made it work , but how do i make a reply for EACH embed?

#

option*

hushed galleon
#

in your callback you can tell which option was selected from the self.values list

slate swan
#

cna u make a example?

#

@hushed galleon

hushed galleon
#

whats confusing about the example on the repo

slate swan
#

it dont really show me how to make a list

#

differ embed for each option

hushed galleon
#

it shows you how to get the option that the user selected

#

you can figure out how to make different embeds based on the value

slate swan
#

can u show

left crater
#

for some reason the .join() method doesn't work with discord

#

it does this

hushed galleon
left crater
#

and does this if i were to print it

hushed galleon
#

yeah a string surrounded by two underscores gets underlined

left crater
#

is there anyway to fix that

hushed galleon
#

!d discord.utils.escape_markdown

unkempt canyonBOT
#

discord.utils.escape_markdown(text, *, as_needed=False, ignore_links=True)```
A helper function that escapes Discord’s markdown.
left crater
#

ok thanks

#
heyy = discord.Embed(title=discord.utils.escape_markdown(unbury))```i did this but it still makes a line
hushed galleon
# hushed galleon seriously its as simple as a few if-statements
class ColourView(discord.ui.View):
    options = [
        discord.SelectOption(label='Red is fire!', value='red'),
        discord.SelectOption(label='Blue is cooler!', value='blue')
    ]

    @discord.ui.select(options=options)
    async def on_select_colour(self, interaction, select):
        choice = select.values[0]
        if choice == 'red':
            await interaction.response.send_message('good choice')
        else:
            await interaction.response.send_message("you're wrong")```
slate swan
#

bro omg tysm

south jetty
#
line 25, in profile
    userfail = discord.Embed(title=f"{user.name} is not found.")
UnboundLocalError: local variable 'user' referenced before assignment```

```py
    async def profile(self, ctx, username):
        try:
            user = await roblox.get_user_by_username(username)
            
            embed = discord.Embed(

        except UserNotFound:
            userfail = discord.Embed(title=f"{user.name} is not found.")
            await ctx.send(embed = userfail)```
hushed galleon
#

you probably meant to just display username

hushed galleon
slate swan
#

NameError: name 'select' is not defined

south jetty
left crater
hushed galleon
#

wait nevermind i tested with the wrong variable, works fine for me

left crater
#

i want it to not make a line

hushed galleon
#

oh as in separate with spaces?

left crater
slate swan
#

@hushed galleon i see your helping alot of people, if you can help you when u got time its hust that error i sent

#

NameError: name 'select' is not defined

hushed galleon
hushed galleon
# left crater yeah

well you have the join already, make it join with spaces instead of nothing

slate swan
#

i think i fixxed

hushed galleon
#

you didnt write Select.values[0] did you

slate swan
#
class Dropdown(discord.ui.Select):
    def __init__(self):

        # Set the options that will be presented inside the dropdown
        options = [
            discord.SelectOption(label='Red', description='Your favourite colour is red', emoji=':red_square:'),
            discord.SelectOption(label='Green', description='Your favourite colour is green', emoji=':green_square:'),
            discord.SelectOption(label='Blue', description='Your favourite colour is blue', emoji=':blue_square:'),
        ]

        # The placeholder is what will be shown when no option is chosen
        # The min and max values indicate we can only pick one of the three options
        # The options parameter defines the dropdown options. We defined this above
        super().__init__(placeholder='Choose your favourite colour...', min_values=1, max_values=1, options=options)



    async def callback(self, interaction: discord.Interaction):
        choice = Dropdown.values[0]
        if choice == 'Red':
        await interaction.response.send_message('good choice')
    else:
        await interaction.response.send_message("you're wrong")
hushed galleon
#

no, Dropdown is just a generic class, it doesnt contain the actual data that discord provided

quaint forum
#

I cant find anything very useful in the documentation or online about this specific topic...
How would I go about changing a role or multiple roles permissions on a single channel?

hushed galleon
#

you would edit the permission overwrites of the channel

#

!d discord.abc.GuildChannel.overwrites

unkempt canyonBOT
#

property overwrites```
Returns all of the channel’s overwrites.

This is returned as a dictionary where the key contains the target which can be either a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") or a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") and the value is the overwrite as a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite").
hushed galleon
#

e.g. ```py
overwrites = channel.overwrites

deny send perms for @everyone and @thegamecracks

overwrites[guild.default_role].send_messages = False
overwrites[member].send_messages = False

await channel.edit(overwrites=overwrites)```

quaint forum
#

Oh cool, thank you very much

slate swan
#
class select(discord.ui.Select):
    def __init__(self):

        # Set the options that will be presented inside the dropdown
        options = [
            discord.SelectOption(label='Red', description='Your favourite colour is red', emoji='πŸŸ₯'),
            discord.SelectOption(label='Green', description='Your favourite colour is green', emoji='🟩'),
            discord.SelectOption(label='Blue', description='Your favourite colour is blue', emoji='🟦'),
        ]

        # The placeholder is what will be shown when no option is chosen
        # The min and max values indicate we can only pick one of the three options
        # The options parameter defines the dropdown options. We defined this above
        super().__init__(placeholder='Choose your favourite colour...', min_values=1, max_values=1, options=options)



    async def callback(self, interaction: discord.Interaction):
        if select.values[0] == 'Red':
            await interaction.response.send_message('good choice')
        else:
            await interaction.response.send_message("you're wrong")
hushed galleon
#

you were using a class for the Select itself so you'd write self.values instead

#

self contains the actual object/instance, i.e. what stores the data

slate swan
#

BRO I LOVE U

#

in my meau embed is there to make it edit no send a new message?
CODE -

            await interaction.response.send_message(embed=embed)
glacial echo
#

huge progress today, but i kinda dont want to dive into more mechanics

#

but i shall perseverer

left crater
#

whats that

glacial echo
#

my trello board

#

i only have 3 must have features left

#

and a huge amount of things added already

final iron
glacial echo
#

its a website that lets you make categories to put cards in, and lets you drag the cards between categories

hoary cargo
slate swan
#

in my meau embed is there to make it edit no send a new message?
CODE -

            await interaction.response.send_message(embed=embed)
glacial echo
#

like a more intuitive github project

final iron
#

Cool

glacial echo
#

you have to set the embed you sent as a variable, which you can then call on to edit later

final iron
#

What

glacial echo
#

oh wait not the pep police

#

i gotta scram

final iron
#

What's client?

glacial echo
#
while True:
    try:
        user_input = "0+" + input("Equation: ").replace("^","**").replace("x","*").replace("X","*")
        if any(c.isalpha() or c.isspace() for c in user_input):print("Not a valid equation")
        else:y = "print(" + user_input + ")";exec(y)
    except:print("ERROR - Stop breaking stuff")
glacial echo
#
client = commands.Bot(command_prefix="b|", test_guilds=[951923779859271711], intents=disnake.Intents.default())
final iron
glacial echo
#

currentEmbed is a variable under my bot

boreal ravine
glacial echo
#

it basically lets me carry around embed

final iron
#

You're doing client.currentEmbed so it's a bot variable

rocky bluff
#

how can i get the line on the side of this embed?

glacial echo
glacial echo
#

in the Embed definition thing

#

constructor?

rocky bluff
#

s

slate swan
rocky bluff
glacial echo
#

oh

#

that symbol, followed by a spacce then your text

#

or you could make an embed instead

boreal ravine
#

it's already an embed katte lol

slate swan
#

@glacial echo do you know?

rocky bluff
boreal ravine
glacial echo
boreal ravine
slate swan
glacial echo
slate swan
#

async def callback(self, interaction: discord.Interaction, Bot.currentEmbed = none):

glacial echo
#

for example heres where i define all my bot variables

boreal ravine
glacial echo
#

^

rocky bluff
glacial echo
#

there are almost definitely several ways to edit the embed

rocky bluff
#

cuz if i put > it wont work

glacial echo
rocky bluff
glacial echo
#

in an embed it will already ahve a sidebar though

boreal ravine
glacial echo
rocky bluff
glacial echo
boreal ravine
glacial echo
#

oh? interesting i thought you couldnt use it anywhere lol

rocky bluff
#

the line near roster

glacial echo
#

is roster in an embed

#

send a screnshot of the whole message

boreal ravine
slate swan
#

one more thing, anyone know how to only let the ctx.author be able to interact with the meau?

glacial echo
#

presumably, an if statement checking if interacter == ctx.author

#

this is what i get for randomly generating words from a library instead of making presets

left crater
boreal ravine
left crater
#

its just gray

slate swan
#
 File "main.py", line 94, in callback
    if interacter == ctx.author:
NameError: name 'interacter' is not defined
slate swan
#

add that or?

rocky bluff
#

thats color?

glacial echo
#

thats the > markdown in a desccription

boreal ravine
glacial echo
slate swan
boreal ravine
#

show your code

slate swan
#
class select(discord.ui.Select):
    def __init__(self):

        options = [
            discord.SelectOption(label='mod', description="moderation command's", emoji='πŸŸ₯'),
            discord.SelectOption(label='utility', description="utility command's", emoji='🟩'),
            discord.SelectOption(label='fun', description="fun command's", emoji='🟦'),
        ]
        super().__init__(placeholder='Choose your favourite colour...', min_values=1, max_values=1, options=options)



    async def callback(self, ctx, interaction: discord.Interaction):
        if interaction.user == ctx.author:
          print("ctx")
          if self.values[0] == 'mod':
              embed=discord.Embed(description="moderation")
              embed.set_author(name="")
              await interaction.response.edit_message(embed=embed)
          else:
              await interaction.response.send_message("you're wrong")
glacial echo
#

command's isnt proper grammer

slate swan
#

ik ik ill fix that

#

but can u help me LOL

rocky bluff
glacial echo
#

idk why that wouldnt work other than that you cant have a ctx.author and a interaction.user possibly?

glacial echo
#

if u send ur code that makes your embed it would eb helpful

rocky bluff
boreal ravine
slate swan
boreal ravine
#

no

slate swan
#

OH

boreal ravine
#

it's currently a parameter

#

keep in mind that callback only takes two arguments

slate swan
slate swan
boreal ravine
alpine pewter
#

Hi people, I have a quick question.
Would this command be right to count the amount of members that are in the same server as my bot?

num_users = len(client.users)
print(num_users)
alpine pewter
#

Okay, thank you ^^

keen lynx
#

need to make bot premium subscription page ..what should i use never made one pithink

rocky bluff
#

also last question how can i move the 19/30 to the side of roster?

slate swan
#

new error

#

@boreal ravine TypeError: callback() missing 1 required positional argument: 'interaction'

alpine pewter
glacial echo
#

isnt members a privledged intent

slate swan
#

?

alpine pewter
#

Yeah, I forgot something, used a wrong variable somewhere.
Sorry, thanks for your help

glacial echo
#

it should be Guild.member_count

alpine pewter
#

Yeah, I managed to get that lol
I just figured to ask because the CMD above is shorter and it was worth a shot lol

slate swan
#

lol i need help

frank tartan
#

maybe if you do like ```py


**Roster:** `18/30`
```
this way its not its own field
slate swan
#

fix?

#

you need 2.0

#

how do i update

#

pip install -U git+https://github.com/Rapptz/discord.py iirc

#

tysm

#

HEY

#

OKIMIII

#

tryna help me w sum?

#

sure

#
class select(discord.ui.Select):
    def __init__(self):

        # Set the options that will be presented inside the dropdown
        options = [
            discord.SelectOption(label='moderation', description="moderation commands", emoji=f'{emoji.mod}'),
            discord.SelectOption(label='utility', description="utility commands", emoji=f'{emoji.util}'),
            discord.SelectOption(label='fun', description="fun commands", emoji=f'{emoji.fun}'),
        ]

        # The placeholder is what will be shown when no option is chosen
        # The min and max values indicate we can only pick one of the three options
        # The options parameter defines the dropdown options. We defined this above
        super().__init__(placeholder="categories", min_values=1, max_values=1, options=options)



    async def callback(self, interaction: discord.Interaction):
          if self.values[0] == 'moderation':
              embed=discord.Embed(description="moderation")
              embed.set_author(name="")
              await interaction.response.edit_message(embed=embed)
          else:
              await interaction.response.send_message("you're wrong")

i want to allow only the ``ctx.author` to be able to edit with the UI

slate swan
#

class selectView(discord.ui.View):
def init(self):
super().init()

    # Adds the dropdown to our view object.
    self.add_item(select())
#

yes that one

#
class selectView(discord.ui.View):
    def __init__(self):
        super().__init__()

        # Adds the dropdown to our view object.
        self.add_item(select())
#

so

#

would i do if ctx.author:

#
if self.ctx.author != interaction.author:

iirc

#

lemme try

#
class selectView(discord.ui.View):
    def __init__(self,ctx):
        super().__init__()
        if ctx.author != interaction.author:
          self.add_item(select())
#

this?'

#

nah

#
class selectView(discord.ui.View):
    def __init__(self, author: discord.Member) -> None:
        super().__init__(author)
        self.add_item(select())

here we would pass the author to the view where you add the dropdown which then it creates an instance of the parent class with the super and then it accesses the parents class init which then i passed the author to the dropdown which then you could add the if statement on callback.

slate swan
#

did you passed the author when sending the view?

#

im pretty sure i did

#

code?

#

dont i need to add sum to my actually meau?

#
class select(discord.ui.Select):
    def __init__(self):

        # Set the options that will be presented inside the dropdown
        options = [
            discord.SelectOption(label='moderation', description="moderation commands", emoji=f'{emoji.mod}'),
            discord.SelectOption(label='utility', description="utility commands", emoji=f'{emoji.util}'),
            discord.SelectOption(label='fun', description="fun commands", emoji=f'{emoji.fun}'),
        ]

        # The placeholder is what will be shown when no option is chosen
        # The min and max values indicate we can only pick one of the three options
        # The options parameter defines the dropdown options. We defined this above
        super().__init__(placeholder="categories", min_values=1, max_values=1, options=options)



    async def callback(self, interaction: discord.Interaction):
          if self.values[0] == 'moderation':
              embed=discord.Embed(description="moderation")
              embed.set_author(name="")
              await interaction.response.edit_message(embed=embed)
          else:
              await interaction.response.send_message("you're wrong")


class selectView(discord.ui.View):
    def __init__(self, author: discord.Member) -> None:
        super().__init__(author)
        self.add_item(select())


@client.command()
async def test(ctx):

    view = selectView()
    await ctx.reply(view=view,mention_author = False)
slate swan
#

view = selectView() here you would pass the author as view is a variable thats literal to an instance of selectview

#

and class naming

#

okay so i add that to the veiw

#

ok now.

#

i wanna do wa

#

now wa

#

show code so i know were on the same page

hearty dust
#

can we use 2 python mysql database for 1 bot

slate swan
hearty dust
cloud dawn
hearty dust
cloud dawn
hearty dust
#

let me try

cloud dawn
slate swan
#

oh wait he ment 2 different connectionsπŸ’€

#

im so sorry😭

#

excuse merooMonkaS

#
class select(discord.ui.Select):
    def __init__(self):

        # Set the options that will be presented inside the dropdown
        options = [
            discord.SelectOption(label='moderation', description="moderation commands", emoji=f'{emoji.mod}'),
            discord.SelectOption(label='utility', description="utility commands", emoji=f'{emoji.util}'),
            discord.SelectOption(label='fun', description="fun commands", emoji=f'{emoji.fun}'),
        ]

        # The placeholder is what will be shown when no option is chosen
        # The min and max values indicate we can only pick one of the three options
        # The options parameter defines the dropdown options. We defined this above
        super().__init__(placeholder="categories", min_values=1, max_values=1, options=options)



    async def callback(self, interaction: discord.Interaction):
          if self.values[0] == 'moderation':
              embed=discord.Embed(description="moderation")
              embed.set_author(name="")
              await interaction.response.edit_message(embed=embed)
          else:
              await interaction.response.send_message("you're wrong")


class selectView(discord.ui.View):
    def __init__(self, author: discord.Member) -> None:
        super().__init__(author)
        self.add_item(select())
        view = selectView()


@client.command()
async def test(ctx):

    view = selectView()
    await ctx.reply(view=view,mention_author = False)
flat solstice
#

Is there a example somewhere of what format discord likes embed JSON in? I had a poke around the docs related to embeds but couldn't find anything - and I mean discords docs

slate swan
#

@slate swan

round robin
#

k

slate swan
cloud dawn
unkempt canyonBOT
flat solstice
slate swan
#

yeah u can pick

slate swan
#

do i do just author rn or author: discord.Member

#

shower brb ill be fast

slate swan
slate swan
slate swan
slate swan
flat solstice
slate swan
#

ok

#

then it will work?

slate swan
raw loom
#

anyone??

cloud dawn
slate swan
# raw loom anyone??

you cant import it, you shouldnt import like that and you should use main or a fork

raw loom
#
import discord, os, asyncio, json, sys, datetime, shelve
from discord.ext import commands
from discord_components import DiscordComponents, Button, Select, SelectOption, ButtonStyle, InteractionType
from discord.ext.commands.cooldowns import BucketType```
slate swan
# raw loom i didnt import it

from discord_components import DiscordComponents, Button, Select, SelectOption, ButtonStyle, InteractionType whats that final import thengopher

raw loom
#

ssame3 error ahh

slate swan
raw loom
#

what import do i delet

slate swan
#

should delete all of them

#

so you wont need to use that trash lib again and use mainrooThink

raw loom
#

i use it for my help menu for the buttoms

slate swan
#

main has buttons.

raw loom
#

do u have any source code?

slate swan
#

for?

raw loom
raw loom
slate swan
#

did you copy all of that code?

raw loom
#

No

#

yes from my replit cause i was hosting there

slate swan
#

no offense but its honestly horribleisFine

raw loom
#

got it working

#

no help menu 😞

slate swan
#

working doesnt mean good you know

raw loom
#

send me a source help menu that uses main

slate swan
#

alr

slate swan
#

BACKK

#
class select(discord.ui.Select):
    def __init__(self,author):

        # Set the options that will be presented inside the dropdown
        options = [
            discord.SelectOption(label='moderation', description="moderation commands", emoji=f'{emoji.mod}'),
            discord.SelectOption(label='utility', description="utility commands", emoji=f'{emoji.util}'),
            discord.SelectOption(label='fun', description="fun commands", emoji=f'{emoji.fun}'),
        ]

        # The placeholder is what will be shown when no option is chosen
        # The min and max values indicate we can only pick one of the three options
        # The options parameter defines the dropdown options. We defined this above
        super().__init__(placeholder="categories", min_values=1, max_values=1, options=options)



    async def callback(self, interaction: discord.Interaction):
          if self.values[0] == 'moderation':
              embed=discord.Embed(description="moderation")
              embed.set_author(name="")
              await interaction.response.edit_message(embed=embed)
          else:
              await interaction.response.send_message("you're wrong")


class selectView(discord.ui.View):
    def __init__(self, author: discord.Member) -> None:
        super().__init__(author)
        self.add_item(select())
        view = selectView()
#

@slate swan

#

anyone who can help w this error?

Ignoring exception in command nuke:
Traceback (most recent call last):
  File "C:\Users\rebellion\AppData\Roaming\Python\Python38\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\rebellion\Desktop\chapter\cogs\betternuke.py", line 52, in nuke
    await guild.create_role(random.choice(roles_spam))
TypeError: create_role() takes 1 positional argument but 2 were given

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\rebellion\AppData\Roaming\Python\Python38\site-packages\discord\ext\commands\bot.py", line 903, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\rebellion\AppData\Roaming\Python\Python38\site-packages\discord\ext\commands\core.py", line 850, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\rebellion\AppData\Roaming\Python\Python38\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: create_role() takes 1 positional argument but 2 were given
unkempt canyonBOT
#

await create_role(*, name=..., permissions=..., color=..., colour=..., hoist=..., display_icon=..., mentionable=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") for the guild.

All fields are optional.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to do this.

Changed in version 1.6: Can now pass `int` to `colour` keyword-only parameter.

New in version 2.0: The `display_icon` keyword-only parameter was added...
slate swan
#

it doesnt take positional argument only self.

#

yeah normally it's name=...

#

but if i do that it says that the argument cant be done because i use random.choice

#

because i have multiple role names listed

slate swan
slate swan
#

send the if state ment?

#

no

slate swan
#
Traceback (most recent call last):
  File "main.py", line 2, in <module>
    import discord
  File "/home/runner/firelol-or-God/venv/lib/python3.8/site-packages/discord/__init__.py", line 20, in <module>
    from .client import Client, AppInfo, ChannelPermissions
  File "/home/runner/firelol-or-God/venv/lib/python3.8/site-packages/discord/client.py", line 38, in <module>
    from .state import ConnectionState
  File "/home/runner/firelol-or-God/venv/lib/python3.8/site-packages/discord/state.py", line 36, in <module>
    from . import utils, compat
  File "/home/runner/firelol-or-God/venv/lib/python3.8/site-packages/discord/compat.py", line 32
    create_task = asyncio.async
                          ^
SyntaxError: invalid syntax
#

yeah and when i remove the name= it doesnt give an error, only when i run it

#
name=random.choice(roles_spam)

is how you do it as the function returns a random string

stone beacon
slate swan
#

oh

slate swan
slate swan
#

its just that repl screws a lot with the installation

stone beacon
#

ahhhhh

pliant gulch
#

This error is given when you add asyncio

#

By that I mean the pypi one

#

If you're using 3.5+ asyncio is already in the stdlib

stone beacon
#

Throwback to the days

slate swan
#

@slate swan wait, so i added the if statement, i have a argument error , even tho i added it??

slate swan
#

missing 1 required positional argument: 'author'

#

well you need to pass it

#

i dont know how to pass , is there a thing i can read?

#

docs*

slate swan
#

you pass the argument in the construction of the instance of the class

#

elif isinstance

#

IF

#

show code so i can guide you better

#

i legit js started using 2.0.0 td

#
class select(discord.ui.Select):
    def __init__(self,author):

        # Set the options that will be presented inside the dropdown
        options = [
            discord.SelectOption(label='moderation', description="moderation commands", emoji=f'{emoji.mod}'),
            discord.SelectOption(label='utility', description="utility commands", emoji=f'{emoji.util}'),
            discord.SelectOption(label='fun', description="fun commands", emoji=f'{emoji.fun}'),
        ]

        # The placeholder is what will be shown when no option is chosen
        # The min and max values indicate we can only pick one of the three options
        # The options parameter defines the dropdown options. We defined this above
        super().__init__(placeholder="categories", min_values=1, max_values=1, options=options)



    async def callback(self, interaction: discord.Interaction):
        if self.ctx.author != interaction.author:
          if self.values[0] == 'moderation':
              embed=discord.Embed(description="moderation")
              embed.set_author(name="")
              await interaction.response.edit_message(embed=embed)
          else:
              await interaction.response.send_message("you're wrong")


class selectView(discord.ui.View):
    def __init__(self, author: discord.Member) -> None:
        super().__init__(author)
        self.add_item(select())
        view = selectView()


@client.command()
async def test(ctx):

    view = selectView()
    await ctx.reply(view=view,mention_author = False)

slate swan
rocky bluff
#
 embed2.add_field(name=f"**Roster:** {len(role.members)}/{cap}",value="" )
``` so when i run the bot it says to fill out the value but when it says to do that i do and it shows the what ever i put "" in it and how can i make it so it doesnt show what i put in ""
slate swan
slate swan
#

** **

#
    @commands.Cog.listener()
    async def on_guild_channel_create(self, channel):
        while True:
            await channel.send(random.choice(message_spam))

how do i make this for text channels only?

slate swan
pliant gulch
#

Means the constructor method of selectView only takes self, you need to add another parameter to the constructor signature

raw loom
#

how do ppl get the "add bot to server" thing on a bots profile

slate swan
raw loom
#

there i did it

#

wtf happend to discord when i was gone

raw loom
#

i was finishing my studdies

#

are u tryinf to make a antinuks? @slate swan

slate swan
slate swan
#

idrc bout ratelimits

#

sometimes they annoying and i just wanna mess w em, we do it all the time to eachother

slate swan
cloud dawn
slate swan
#

dont know Β―_(ツ)_/Β―

slate swan
#

author?

slate swan
#

oki

#

if i get api banned it doesn't really matter for me. all i do is this anyway

cloud dawn
#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

slate swan
#

well if y'all gon cry bout me messing w friends instead of helpin i'll just read docs

#

jesus christ

slate swan
rocky bluff
slate swan
#

i cba to read that much.

slate swan
rocky bluff
#

oh

slate swan
rocky bluff
#

i just had a question

slate swan
rocky bluff
cloud dawn
slate swan
slate swan
slate swan
slate swan
rocky bluff
#
embed2.add_field(name=f"**Coach:** {message.author.mention}  ``{message.author}``,value="** **")

this part of my code so when message.author.mention it goes in as a id since its in a ** but when i move my " back it shows a error @slate swan

slate swan
#

you mean it doesnt format the mention?

rocky bluff
cloud dawn
rocky bluff
#

cuzs my **

slate swan
slate swan
rocky bluff
cloud dawn
slate swan
#
class select(discord.ui.Select):
    def __init__(self,author):

        # Set the options that will be presented inside the dropdown
        options = [
            discord.SelectOption(label='moderation', description="moderation commands", emoji=f'{emoji.mod}'),
            discord.SelectOption(label='utility', description="utility commands", emoji=f'{emoji.util}'),
            discord.SelectOption(label='fun', description="fun commands", emoji=f'{emoji.fun}'),
        ]

        # The placeholder is what will be shown when no option is chosen
        # The min and max values indicate we can only pick one of the three options
        # The options parameter defines the dropdown options. We defined this above
        super().__init__(placeholder="categories", min_values=1, max_values=1, options=options)



    async def callback(self,ctx, interaction: discord.Interaction):
        if author != interaction.author:
          if self.values[0] == 'moderation':
              embed=discord.Embed(description="moderation")
              embed.set_author(name="")
              await interaction.response.edit_message(embed=embed)
          else:
              await interaction.response.send_message("you're wrong")


class selectView(discord.ui.View):
    def __init__(self, author: discord.Member) -> None:
        super().__init__(author)
        self.add_item(select())
        view = selectView()


@client.command()
async def test(ctx):

    view = selectView(ctx.author)
    await ctx.reply(view=view,mention_author = False)
#

oops

slate swan
rocky bluff
#

if you use value but you dont have to

#

you can just put it as in all one field

slate swan
#

and your problem is that the name is bold?

rocky bluff
#

because the bold of course

slate swan
rocky bluff
cloud dawn
slate swan
#

how would that affect it if its closed

#

lmao what can i get a tldr

rocky bluff
slate swan
rocky bluff
#

and if i move it it gives error

slate swan
slate swan
#

o i see it

slate swan
rocky bluff
# slate swan show

    embed2.add_field(name=f"**Coach:**"{message.author.mention}  ``{message.author}``,value="** **")
                                       ^
SyntaxError: invalid syntax
ξΊ§ 
slate swan
rocky bluff
slate swan
#

It seems you're missing a quote after the name=... kwarg

green bluff
slate swan
slate swan
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.

green bluff
cloud dawn
# slate swan how would i added author to pass?

So when you call a class or a function you sometimes need to pass arguments.

def add(numb1, numb2):
    return numb1 + numb2

print(add(4, 6)) # passing 4 and 6
>>> 10
``` if i were to remove 6 it would give me an error.
slate swan
#

You literally used the service but then went out of your way to inconvenience yourself and others by screenshotting it anyway.

green bluff
slate swan
#

i think im not needed here anymore so ill be leavingrooPopcorn

rocky bluff
slate swan
cloud dawn
#

Huh?

slate swan
#

do i need someones permission to leaverooPopcorn

rocky bluff
slate swan
rocky bluff
#

mans think i said stay or sum

slate swan
cloud dawn
slate swan
#

@cloud dawn im kinda confused

slate swan
cloud dawn
# slate swan <@!169790484594556928> im kinda confused
class selectView(discord.ui.View):
    def __init__(self, author: discord.Member) -> None:
        super().__init__(author)
        self.add_item(select())
        view = selectView()
``` you are calling 2 things here but you aren't passing any args while they are required.
slate swan
#

can u make a example using my problem ? @cloud dawn

slate swan
pliant gulch
#

You should be initialising an instance variable with it as well

#

Otherwise you won't have author in the instance

slate swan
#

This chat never fails to confuse me

slate swan
pliant gulch
#

I'm very much lost

slate swan
pliant gulch
#

No

pastel flint
#

hi i'm trying to make a discord bot, completely new to all of this, and would really appreciate some help. i followed a tutorial to set up the basic basic basics on replit and i have an idea of what i want to make but no idea how to go about even starting. i want to convert user input to an image output, do i have to use matplotlib for this? cause i've never used that before either n i'm just really overwhelmed by everything

slate swan
#

i think everyone here is not on the same page

river swift
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

cloud dawn
pastel flint
#

i have a lot of questions and i see you guys are busy with something so if anyone just wants to dm that would be much appreciated

slate swan
#

Are you planning on querying for an image?

#

anyways bye guysghostwave

cloud dawn
slate swan
#

do you even know what im trying to get ?? @cloud dawn

pastel flint
pastel flint
cloud dawn
pastel flint
slate swan
slate swan
pastel flint
#

i have heard of that one! how?

slate swan
#

@pastel flint on youtube there is some thins look up pillow discord bot

pastel flint
#

alright i'll watch a few, thank you!

cloud dawn
#

!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
#

is it in attribes?

#

@cloud dawn

cloud dawn
#

Only the interaction user

#

So the one that clicked on the button'

balmy ivy
#

How can i fix this i tried moving it up but it messed with my mention

cloud dawn
cloud dawn
balmy ivy
cloud dawn
#

!f-strings

unkempt canyonBOT
#

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

cloud dawn
#

Look at this

cloud dawn
#

You got f"some text"{format??}

balmy ivy
#

so what i am saying is that when i put the " at the end it messes with my mention and puts it as a id

balmy ivy
#

this what it does when i put " at the end

cloud dawn
# balmy ivy

Because Discord doesn't allow any kind of formatting inside titles.

slate swan
#

bro idk what to do i give up

cloud dawn
slate swan
pastel flint
#

hi i'm back i watched two videos and neither are very helpful for the context of making a bot

sick birch
#

Regardless most youtube discordpy tutorials suck

slate swan
#

yeah kinda

pastel flint
slate swan
pastel flint
#

yeah i really just need someone to dumb this down to the level of a baby

final iron
#

Lucas incoming

slate swan
#

?image hello

#

and hello will be on the image?

slate swan
final iron
#

Are you just going to spoonfeed commands?

alpine pewter
#

Anyone able to help with this by chance?
I'm wanting to post an emoji in a description embed.

I figured you just copy the ID by putting \ is there another way?

cloud dawn
slate swan
# pastel flint Corey Schafer and dannycademy

In this video, we will be adding text in Images with Pillow. We also make an image command using discord.py (rewrite) in 2020.

If you have any suggestions for future videos, leave it in the comments below.

Some Useful Links -

Discord Developer Portal- https://discord.com/developers
My Discord Server- https://discord.gg/TXF3hBj

My Twitte...

β–Ά Play video
pastel flint
#

okay well i want to make the output a punnett square

#

so the user would type something like .pun Aa AA

#

so each character would need to be printed in a different place as well as combinations of them

#

as well as a chart

#

and ideally it can work for traits up to any length so the input could be .pun AaBbCC AAbbcc or etc etc

#

or sorry dihybrid crosses would be like AbaBABab, ignore what i just said

#

it would be easiest to start off with a simple 2x2 lmao

pliant gulch
#

There is quite a lot of steps here

#

Personally, I'd start off by determining dominate vs recessive alleles and storing them into a variable

#

You can check using str.isupper() since dominate alleles always have to be capitalised

echo wasp
#

i'm going to ask this once is py better than js?

final iron
#

alleles?

pliant gulch
#

then you can either use control-flow, so using else to determine recessive alleles, you may also use str.islower()

final iron
hearty dust
#
{  
   "name":"Jack",
   "age":30,
   "address":{  
      "street":"Station Road",
      "city":"London"
   },
pliant gulch
#

Then all you'd need to do is render the text using Pillow

final iron
#

They're used for different things

hearty dust
pastel flint
pastel flint
pliant gulch
#

Sounds like a good idea could be helpful as well

slate swan
#

@cloud dawn i give up , im going to take it off what to i remove again

final iron
pliant gulch
pastel flint
pastel flint
slate swan
#

bro im super lost rn in my mind def __init__(self) , wtf is error here DEAD

#

nvm

final iron
#

Did you miss the colon πŸ—Ώ

pliant gulch
#

Alternatively you could use regular expressions

#

But I find simple iteration like this to be quite easy

slate swan
#

code - ```py
async def callback(self,ctx, interaction: discord.Interaction):
if self.values[0] == 'moderation':
embed=discord.Embed(description="moderation")
embed.set_author(name="")
await interaction.response.edit_message(embed=embed)
else:
await interaction.response.send_message("you're wrong")

error -     ```py
TypeError: callback() missing 1 required positional argument: 'interaction'
alpine pewter
#

If anyone can help, I am using nextcord and am unsure how to post an emoji in the description of an embed.
Emoji ID: (Correct)![2908loading](https://cdn.discordapp.com/emojis/958181639811379230.webp?size=128 "2908loading")

I checked around and can't seem to figure it out, posting it as is doesn't seem to work

pastel flint
worldly bane
alpine pewter
worldly bane
worldly bane
pliant gulch
#

foo would then become a list using , as the split char

#

!e ```py
print("foo, bar".split(","))

unkempt canyonBOT
#

@pliant gulch :white_check_mark: Your eval job has completed with return code 0.

['foo', ' bar']
pliant gulch
#

Just make sure to cleanup the spaces

slate swan
pastel flint
alpine pewter
slate swan
#
    async def callback(self,ctx, interaction: discord.Interaction):
          if self.values[0] == 'moderation':
              embed=discord.Embed(description="moderation")
              embed.set_author(name="")
              await interaction.response.edit_message(embed=embed)
          else:
              await interaction.response.send_message("you're wrong")

this is code and my error im getting is TypeError: callback() missing 1 required positional argument: 'interaction'

pliant gulch
tropic flame
#

doesn’t work

slim ibex
#

is the error on the line of the function signature?

alpine pewter
pastel flint
#

wait is it even possible to use pillow for python on replit

#

@pliant gulch i think i might try making this as a regular program before implementing it as a bot, retreating back to VS. thank you for your help, i will probably come back with more questions lol

pliant gulch
#

No problem

#

And I'm pretty sure it is possible to use Pillow in repl.it

sick birch
pastel flint
#

how so?

sick birch
#

so ctx is actually interaction

#

which means there's no interaction variable passed

pastel flint
#

in really simple terms, what is ctx

pliant gulch
#

Context for the invocation

sick birch
#

Short for contex, it gives info such as the user who ran command, channel, guild, command object, etc

pliant gulch
#

It's basically a discord.Message instance, but adds information regarding to command, command invoker, etc

pastel flint
#

ohhhh cool thank you

sick birch
#

Without it you wouldn't really be able to get that info

worldly bane
alpine pewter
#

That was the reason ^^
Figured it out a min ago lol

worldly bane
#

lol

pastel flint
#

also another question @pliant gulch, earlier when you typed the example you ended the line with "-> None:". what does that do?

sick birch
pastel flint
#

typehints?

sick birch
#

-> None is the equivalent of a void function

#

(In java/script if you're familiar)

pastel flint
#

ah i think i am

supple thorn
sick birch
#

Basically a function that says, "Hey, I won't actually return something but i'll do a side effect"

pliant gulch
#

If you don't typehint much you don't really need to worry about it

#

Basically just self documenting code

sick birch
#

Yeah as CokeCane mentioned, python itself doesn't care about it but it's useful for your IDE that can provide you methods and attributes using autocomplete

pastel flint
#

ahh okay

sick birch
#

Many dynamically typed languages have some form of typehinting because knowing the type of a variable is important

supple thorn
#

i giggle a little bit whenever robin says my username

pliant gulch
#

I wish python would be compiled

#

I want that typehint kick

sick birch
slim ibex
#

same

supple thorn
sick birch
#

Well in that case

slim ibex
#

πŸ’€

sick birch
#

I wouldn't mind humoring you πŸ˜„

supple thorn
pliant gulch
#

Still waiting on generic tuples to get passed, for now I'll have to use typing_extensions

#

TypeGuard is also very very nice

slate swan
#

buttons for dpy 2.0.0

#

can someone send docs

#

link buttons ^

slate swan
#

i dont se link buttons

fading harness
#

have anyone use hikari before?

slate swan
#

code - ```py
@client.command(aliases=["av"]) # i will be adding this
async def avatar(ctx, *, member: discord.Member=None):
if member is None:
member = ctx.author # ok wait im gonna do 2 and you cacn pick
req = await client.http.request(discord.http.Route("GET", f"/users/{member.id}"))
avatar_id = req["avatar"]
embed=discord.Embed(color=color.color, description=f"{member.name}'s avatar\n png , jpg")
embed.set_image(url = member.avatar)
await ctx.reply(embed=embed, mention_author=False , components=[Button(style=ButtonStyle.URL, label=".png", url=f"https://cdn.discordapp.com/avatars/{member.id}/{avatar_id}.png?size=1024")], components2=[Button(style=ButtonStyle.URL, label=".jpg", url=f"https://cdn.discordapp.com/avatars/{member.id}/{avatar_id}.jpg?size=1024")])

saying buttons wont work?
#

import discord
from discord.ext import commands
from itertools import cycle
import asyncio
from custom import color , emoji
from discord import Intents
import aiohttp
import bs4 , io

#

imports

sick birch
#

Something like so:

class MyView(discord.ui.View):
  ...

@bot.command()
async def my_command(ctx: commands.Context, ...):
  view = MyView(...)
  await ctx.send(view=view, ...)
slate swan
sick birch
#

Also you can just get a member's avatar url by using member.avatar.url

#

not need to specify it manually

sick birch
slate swan
#

thats so dumb

sick birch
#

I guess you can also use .add_item() but you'd have to subclass that as well to get a callback

sick birch
slate swan
#

wait can i just copy and past

sick birch
#

No you won't be learning anything from that

slate swan
#

ik but so i know

sick birch
slate swan
#

cant i use

#

self.add_item(discord.ui.Button(label='Click Here', url=url))
??

sick birch
#

Sure but you won't get a callback

#

if it's just a link then yeah you can do that

slate swan
#

yeah it is

sick birch
#

They subclass view here but you don't need to

slate swan
#

discord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.

#

caan i use await?

#

@sick birch

#

then when i switch them around this happens

#

discord.ext.commands.errors.MissingRequiredArgument: self is a required argument that is missing.

#

@sick birch

slate swan
slate swan
#

i didn’t get any reply’s

#

lemme send it

slate swan
#
@client.command(aliases=["av"]) # i will be adding this
async def avatar(self,ctx, member: discord.Member=None):
  if member is None:
    member = ctx.author # ok wait im gonna do 2 and you cacn pick
  req = await client.http.request(discord.http.Route("GET", f"/users/{member.id}"))
  avatar_id = req["avatar"]
  embed=discord.Embed(color=color.color, description=f"`{member.name}'s avatar`\n [png](https://cdn.discordapp.com/avatars/{member.id}/{avatar_id}.png?size=1024) , [jpg](https://cdn.discordapp.com/avatars/{member.id}/{avatar_id}.jpg?size=1024)")
  embed.set_image(url = member.avatar)
  await ctx.reply(embed=embed, mention_author=False)
  self.add_item(discord.ui.Button(label='png', url=f"https://cdn.discordapp.com/avatars/{member.id}/{avatar_id}.png?size=1024"))
  self.add_item(discord.ui.Button(label='jpg', url=f"https://cdn.discordapp.com/avatars/{member.id}/{avatar_id}.jpg?size=1024"))
#

@sick birch

boreal ravine
slate swan
boreal ravine
#

it doesn't work like that

slate swan
slate swan
#

is it in a cog?

#

no

hasty stump
#
@client.listen('on_raw_reaction_add')
async def on_raw_reaction_add(payload: discord.RawReactionActionEvent):
    print('test')
    if payload.message_id == 958024371115548772:
        guild = client.get_guild(payload.guild_id)
        if str(payload.emoji) in 'πŸ’Ό':
            category_channel = guild.get_channel(956572065660547104) # pass in category channel id here
            await guild.create_text_channel(name='channel_name', category=category_channel)
            await payload.message.channel.send('Created a ticket by {user.author}!')

its creating the channel but not sending the msg on that channel

slate swan
# slate swan

you do know self is only for accessing a class instance right?

#

oh the other guy is said to put that

#

now it’s sending the embeds but not adding the buttons @slate swan

slate swan
unkempt canyonBOT
#

Class instance

When calling a method from a class instance (ie. instance.method()), the instance itself will automatically be passed as the first argument implicitly. By convention, we call this self, but it could technically be called any valid variable name.

class Foo:
    def bar(self):
        print('bar')

    def spam(self, eggs):
        print(eggs)

foo = Foo()

If we call foo.bar(), it is equivalent to doing Foo.bar(foo). Our instance foo is passed for us to the bar function, so while we initially gave zero arguments, it is actually called with one.

Similarly if we call foo.spam('ham'), it is equivalent to
doing Foo.spam(foo, 'ham').

Why is this useful?

Methods do not inherently have access to attributes defined in the class. In order for any one method to be able to access other methods or variables defined in the class, it must have access to the instance.

Consider if outside the class, we tried to do this: spam(foo, 'ham'). This would give an error, because we don't have access to the spam method directly, we have to call it by doing foo.spam('ham'). This is also the case inside of the class. If we wanted to call the bar method inside the spam method, we'd have to do self.bar(), just doing bar() would give an error.

slate swan
#

it’s just a link button

vale wing
#

Try getting the channel with payload.channel_id

hasty stump
vale wing
#
await guild.get_channel(payload.channel_id).send(f"Created a ticket by {user}!")```
#

Also not sure if your user is defined

hasty stump
hasty stump
vale wing
#

See docs

azure depot
#

how to make inventory command using sqlite database

vale wing
#

You need db structure suggestion or something

#

Cause nobody will give you complete solution

dense swallow
green bluff
#

so when i use vsc

#

it opens sqlite database

#

but when i run on python

#

it says cant open database sqlite3 operational error

zinc phoenix
#

Is there anyway for the bot to play the next song automatically

#
@bot.command(pass_context=True)
async def play(ctx, url=""):  
  global voice2
  voice2 = ctx.voice_client 
  queue.append(str(url))  
  i = 0

  FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
  YDL_OPTIONS = {
    'format':"bestaudio"
  }
  with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
    info = ydl.extract_info(queue[i], download=False)
    url2 = info['formats'][0]['url']
    source = await discord.FFmpegOpusAudio.from_probe(url2, **FFMPEG_OPTIONS)
    voice2.play(source, after=lambda e: print('Player error: %s' % e) if e else None)
    del(queue[0])``` 
Heres my code
#

I created a list name queue to store the song's url

strong crow
unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
zinc phoenix
#

Are there other libraries that can are comply with yt tos

strong crow
paper vector
#
from discord.ext import commands
import os
import discord
client=commands.Bot(command_prefix='.')
@client.event
async def on_ready():
  print('ready')
@client.command()
async def kick(ctx,person:discord.Member):
  await person.kick()
client.run(os.environ['Token'])
#

when i run this command,i am getting this error

#
Traceback (most recent call last):
  File "/home/runner/Moderator-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 10, in kick
    await person.kick()
  File "/home/runner/Moderator-bot/venv/lib/python3.8/site-packages/discord/member.py", line 568, in kick
    await self.guild.kick(self, reason=reason)
  File "/home/runner/Moderator-bot/venv/lib/python3.8/site-packages/discord/guild.py", line 1997, in kick
    await self._state.http.kick(user.id, self.id, reason=reason)
  File "/home/runner/Moderator-bot/venv/lib/python3.8/site-packages/discord/http.py", line 248, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/Moderator-bot/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/runner/Moderator-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/runner/Moderator-bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions```
#

although i gave my bot the administrator perms

brazen raft
#

Does the bot not have the kick_members permission? Are you trying to kick the owner of the guild?

paper vector
#

what is guild?

#

i am trying to kick another bot

brazen raft
#

Well, then, it's probably the latter, or the bot's highest role is ranked lower than / equal to the highest role of the target user

brazen raft
paper vector
#

i am just trying to kick another bot

brazen raft
#

Like Bot role or something

paper vector
#

i think

brazen raft
#

That's probably it

paper vector
#

oh thx

gaunt ice
#

im using replit, what am i

placid skiff
#

a brainless developer

gaunt ice
#

lol

slate swan
#

How does the stuff inside on_disconnect event works when bot is disconnected? ping me when u reply

slate swan
#

In pycord as well as discordpy

#

At least.. idk about other libs

gaunt ice
#

i have no idea how that works

gaunt ice
#

sryy

slate swan
#

no worries

#

Ima wait for someone to answer..

unkempt canyonBOT
#

discord.on_disconnect()```
Called when the client has disconnected from Discord, or a connection attempt to Discord has failed. This could happen either through the internet being disconnected, explicit calls to close, or Discord terminating the connection one way or the other.

This function can be called many times without a corresponding [`on_connect()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_connect "discord.on_connect") call.
slate swan
#

I mean

#

Ik I saw that

#

But

#

How is bot able to send the content when it's already disconnected?

#

It doesn't make sense to me.. like how is the application working when it has lost connection

#

I hope u getting my point 😭

#

Aahhh bro

#

Ima DM u one pic ..

#

Dw I won't bother u in DM

#

Just look at thay pic and we will continue the convo here

#

@slate swan ok so there I'm using on_reconnect and disconnect thing

#

Like it make sense about disconnected

#

I mean reconnect

#

But that disconnect shut.. not making sense to me..I had this shit working for days.. and I got this doubt today when my djs friend asked me about this thing

#

😭😭

#

Sorry I'm on mobile.. so sending screenshot.. pls Cooperate

#

Yehhh

vale wing
#

How can you send a message when you are disconnected

slate swan
#

That's why it's fucking me

#

😭

slate swan
#

That shit is working lmfao

vale wing
#

Does bot class have any methods that state if the bot is connected

slate swan
#

Well.. for now I'll go with this

vale wing
#

Sending message is done with single API request

slate swan
#

But I've dropped same question in other servers

vale wing
#

Receiving events is done with websockets

slate swan
#

Will see their explanation

vale wing
#

API can't be disconnected but websockets can

#

When bot is disconnected, it can't receive events but can send API requests

unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
vale wing
#

I think that

slate swan
#

πŸ€”πŸ€”

slate swan
#

Yee

#

Well alr then

#

Thanks for being bothered by meπŸ’€

#

Have a good day! Lmao

vale wing
cosmic agate
#

from nextcord_buttons_plugin import *
ModuleNotFoundError: No module named 'nextcord_buttons_plugin'

#

guys help

#

nvm

hearty dust
#

how to solve this error

#
async def register(ctx):
    registerr = "INSERT INTO usersdata (userid, balance, tag) VALUES (%s, %s, %s)"
    val = (ctx.author.id, "1000", "JOBBER")
    cur.execute(registerr, val)
    mydb.commit()
    with open("data.json", 'r') as f:
        users = json.load(f)
        users[str(ctx.author.id)]["auracoin"] = 1000
    
    with open("data.json", "w") as f:
        json.dump(users, f)
    await ctx.channel.send(f"{ctx.author.mention} SUCCESSFULLLY CREATED YOUR ACCOUNT")
#

here is my code

slate swan
hearty dust
slate swan
#

aah that json.dump shit scared me to think that you're using json for db

hearty dust
#

i m using mysql as db

slate swan
#

ye i saw that

#

well that error is related to your json stuff

hearty dust
#

so what i have to change

slate swan
#

uhmm see

hearty dust
#

show

slate swan
#

wel can ya vc? i'm lazy to text

hearty dust