#discord-bots

1 messages ยท Page 132 of 1

naive briar
#

๐Ÿคท

fading marlin
#

inside your select class...?

mighty pilot
#

there is no interaction to get the original response for

slate swan
#

? wdym vsc it meant for programming

#

not working and no error

slate swan
#

IN VSC*

#

vsc has a live share feature

#
Appelsy is online!
Ignoring exception in command <nextcord.application_command.SlashApplicationCommand object at 0x0000019B24EE9C40>:
Traceback (most recent call last):
  File "C:\Users\PC\AppData\Roaming\Python\Python39\site-packages\nextcord\application_command.py", line 863, in invoke_callback_with_hooks
    await self(interaction, *args, **kwargs)
  File "c:\Users\PC\Desktop\Appelsy Bot\main.py", line 78, in embed_create
    embed.colour = dict(black="0x000000", white="0xffffff")
  File "C:\Users\PC\AppData\Roaming\Python\Python39\site-packages\nextcord\embeds.py", line 313, in colour
    raise TypeError(
TypeError: Expected nextcord.Colour, int, or None but received dict instead.

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

nextcord.errors.ApplicationInvokeError: Command raised an exception: TypeError: Expected nextcord.Colour, int, or None but received dict instead.```
mighty pilot
mighty pilot
#

or are you trying to grab more than one?

#

its saying you gave it a dict

slate swan
#

wdym

slate swan
coarse yew
#

can somebody help me

mighty pilot
# fading marlin what?
future: <Task finished name='discord-ui-view-timeout-f2bc84966b2c58a04ef27a4873cfa588' coro=<Roles.on_timeout() done, defined at /home/luke/Desktop/levels.py:517> exception=AttributeError("'Roles' object has no attribute 'message'")>
Traceback (most recent call last):
  File "/home/luke/Desktop/levels.py", line 521, in on_timeout
    await self.message.edit(view=self)
AttributeError: 'Roles' object has no attribute 'message'
#
        print("menu has timed out")
        for item in self.children:
            item.disabled=True
        await self.message.edit(view=self)```
#

'Roles' is my view

coarse yew
mighty pilot
#

!paste

naive briar
#

You have to set it yourself

slate swan
#
Appelsy is online!
Ignoring exception in command <nextcord.application_command.SlashApplicationCommand object at 0x0000019B24EE9C40>:
Traceback (most recent call last):
  File "C:\Users\PC\AppData\Roaming\Python\Python39\site-packages\nextcord\application_command.py", line 863, in invoke_callback_with_hooks
    await self(interaction, *args, **kwargs)
  File "c:\Users\PC\Desktop\Appelsy Bot\main.py", line 78, in embed_create
    embed.colour = dict(black="0x000000", white="0xffffff")
  File "C:\Users\PC\AppData\Roaming\Python\Python39\site-packages\nextcord\embeds.py", line 313, in colour
    raise TypeError(
TypeError: Expected nextcord.Colour, int, or None but received dict instead.

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

nextcord.errors.ApplicationInvokeError: Command raised an exception: TypeError: Expected nextcord.Colour, int, or None but received dict instead.```
mighty pilot
#

the message im trying to edit is sent inside an on_message

slate swan
#

it was something like that

slate swan
mighty pilot
#

the original interaction comes back as the message sent that triggers the on_message. which comes from a user so i get an error saying it cant be edited

mighty pilot
cold frigate
#

@fading marlin can i dm u

pearl inlet
#
@bot.slash_command(description="Buy things!")
async def buy(interaction: nextcord.Interaction, Literal: Literal["Potato", "Watermelon"] = nextcord.SlashOption(description="Item Name", required=True)):

it's saying that literal is not defined, someone told me to use literals instead of strings

naive briar
#

Move it in the class, but not in the __init__

cold frigate
slate swan
cold frigate
#

@slate swan ?

slate swan
#

correct

cold frigate
slate swan
#

select argument should not be there

#
    if self.values[0] == 'Shop':
      view = View()
      view.add_item(mt.select)
      view.add_item(mt.shop)
      await interaction.response.send_message(view=view, ephemeral=True)
#
Traceback (most recent call last):
  File "/home/runner/miner-bot/venv/lib/python3.8/site-packages/discord/ui/view.py", line 425, in _scheduled_task
    await item.callback(interaction)
  File "main.py", line 183, in callback
    await interaction.response.send_message(view=view, ephemeral=True)
  File "/home/runner/miner-bot/venv/lib/python3.8/site-packages/discord/interactions.py", line 769, in send_message
    await adapter.create_interaction_response(
  File "/home/runner/miner-bot/venv/lib/python3.8/site-packages/discord/webhook/async_.py", line 220, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.components.1.components.0.options.1.label: This field is required
In data.components.1.components.0.options.1.value: This field is required
cold frigate
slate swan
#

nothing, only interaction

#

with self ofc

silent ermine
#

Is there a way to find out who a user replied to and get the message that they replied to? (so like if I replied to John and he said xyz, I want to get the name John and the text xyz)

mighty pilot
# slate swan with self ofc

so i tried the edit_original_response method and it just tells me 'message' object doesnt have that attribute. because thats just for interactions. and if i try to edit the interaction specified for the view itself, it says it cant edit a message authored by another user. so that returns the original message that triggered my on_message

slate swan
#
mt.shop = myselect2(min_values=1, max_values=1,
      placeholder = 'Zio Miner Shop',
      options=[
        discord.SelectOption(label='Upgrade Pick', emoji=funny, description='Upgrade your pickaxe!'),
        discord.SelectOption(label=f'{mt.drilldisplay}', emoji=arrow, description=f'{mt.drilldesc}')
])
    with open("users.json", "r") as f:
        users = json.load(f)
    user = interaction.user
    drill = users[f'{user.id}']['drill']
    if drill == 0:
        drilldisplay=str("Drill")
        drilldesc=str("This is locked!")
    if drill != 0:
        drilldesc=str("Upgrade your drill power!")
        drilldisplay=str(f"Upgrade drill")
#

why isnt this changing

#

when I have a score of 1 or greater its not suppose to say its locked

#

Someone know free host for discord bots?

jolly quartz
slate swan
#

ืœื ื—ื•ืฉื‘ืช ืฉื”ื•ื ื™ืฉืื™ืจ ืืช ื”ืžื—ืฉื‘ ืืชื•ื— ื›ื› ื”ืจื‘ื”

jolly quartz
#

ืฉื™ืงื ื” ืื—ืกื•ืŸ ื‘2$

#

ืื™ืŸ ื—ื™ื ื

slate swan
jolly quartz
abstract kindle
#

How come there is no hidden attribute for Slash commands?

slate swan
#

cause slash commands can't be hidden

abstract kindle
#

๐Ÿ˜ฆ

#

Oh you just use permissions to hide

slate swan
#

its a discord thing, not related to the library
prefix commands on the other hand are discord.py thing

slate swan
abstract kindle
#

I see. I had a help command from somewhere online, and it was a super nice format where it would add all the commands a user could use to the help embed

#

And it would hide the commands that were hidden

#

So I guess I'd have to change that command to add ones that everyone has permission to use

slate swan
#
@mt.tree.command(name='shop', description='Use your moneu here!')
async def shop(interaction: discord.Interaction):
        with open("users.json", "r") as f:
            users = json.load(f)
        user = interaction.user
        drill = users[f'{user.id}']['drill']
        if drill == 0:
          mt.drilldisplay=str("Drill")
          mt.drilldesc=str("This is locked!")
        if drill != 0:
          mt.drilldesc=str("Upgrade your drill power!")
          mt.drilldisplay=str("Upgrade drill")
        view = View()
        view.add_item(mt.select)
        view.add_item(mt.shop)
        await interaction.response.send_message(view=view, ephemeral=True)
#

can someone tell me why the bottom one isnt changing??

#

hello guys please help File "C:\ss\main.py", line 4, in <module> import client ModuleNotFoundError: No module named 'client' its wont download client i did pip install client

#

@slate swan you dont import client

slate swan
#

its wont download client i did pip install client

#

why are you importing it?

#

for discord bot

#
client = commands.Bot(command_prefix='-', intents=discord.Intents.all())
#

replace that with this

#

dm me

cold frigate
#

anyone know why the bots message wont delete

slate swan
cold frigate
naive briar
slate swan
#

who are u

unkempt canyonBOT
#

await send_message(content=None, *, embed=..., embeds=..., file=..., files=..., view=..., tts=False, ephemeral=False, allowed_mentions=..., suppress_embeds=False, delete_after=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Responds to this interaction by sending a message.
fading marlin
fading marlin
#

also, you're responding to an interaction twice, you can't do that

fading marlin
unkempt canyonBOT
#

await delete_original_response()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Deletes the original interaction response message.

This is a lower level interface to [`InteractionMessage.delete()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionMessage.delete "discord.InteractionMessage.delete") in case you do not want to fetch the message and save an HTTP request.
fading marlin
#

read the error...?

slate swan
#

@fading marlin

#

could you help me with something confusing?

fading marlin
#

could you elaborate?

slate swan
#

so basically when you do /shop its suppose to get your drill objective

#

if its more than one it will say you can upgrade it and if you dont have it then it will say to buy it

#

but it doesnt update, so it doesnt tell me I have it

fading marlin
#

what doesn't update?

slate swan
#

see where is says buy this

#

thats suppose to update

#
        with open("users.json", "r") as f:
            users = json.load(f)
        user = interaction.user
        drill = users[f'{user.id}']['drill']
        if drill == 0:
          mt.drilldisplay=str("Drill")
          mt.drilldesc=str("This is locked!")
        if drill != 0:
          mt.drilldesc=str("Upgrade your drill power!")
          mt.drilldisplay=str("Upgrade drill")
mighty pilot
slate swan
#

yes

winged linden
#

Hi, so I have designed a system that when a user presses a button, it creates a new channel and posts a selectionList in it. How can I make it so that only the person who pressed the button can use the selectionList.

mighty pilot
#

Then it's going to say it's locked because if drill ==0

slate swan
#

self.author

winged linden
#

self.author?

slate swan
slate swan
winged linden
#

ok boss

slate swan
mighty pilot
winged linden
#

the thing is the button and selection are two seperate classes

#

so how would this work

#

wouldn't the author of the selectionlist be who every uses it

mighty pilot
winged linden
#

how does init work

#

I tried using it yesterday and i got confused

#

does the init go in the selection class or the button class

mighty pilot
#

There's mine for a button

tired kestrel
#

whats wrong when i want to do npm install

slate swan
mighty pilot
slate swan
#

alr alr

tired kestrel
#

someone help?

slate swan
#

it prints one

feral frost
#

how can i check if the owner used the command ? for example i do .test it prints hi {user} but if the owner does it it will print hi {user} is the owner of the bot

sick birch
tired kestrel
#

where do i even get help on that one then

sick birch
#

on a javascript server

winged linden
#

cereal?

slate swan
tired kestrel
#

ty

slate swan
#

@mighty pilot prints one

winged linden
mighty pilot
winged linden
mighty pilot
slate swan
#

its wtv tho ill just make it fancy

mighty pilot
mighty pilot
slate swan
#

What is the problem

winged linden
abstract kindle
#

Can slash commands have more than 1 name

north pecan
#

i've been getting the error:

AttributeError: 'Intents' object has no attribute 'GUILD_PRESENCES'```
when trying to use any intents for interactions discord bot. i've looked online and there isn't even a flag for that
north pecan
abstract kindle
#

Nope

#

That works for prefix commands, but not slash commands

north pecan
#

no

#

disccusion said they will not add aliases to slash commands

#

but im sure there are work arounds

#

not sure why you want aliases tho considering commands can have full names and desciptions now its ease of use to know

slate swan
#
  with open("badges.json", "r") as f:
     users = json.load(f)
  badge1d = users[f'{user.id}']['badge1']
  badge2d = users[f'{user.id}']['badge2']
  badge3d = users[f'{user.id}']['badge3']
  funny = ":adsmd:"
  if badge1d == 1:
    badge1 = funny
  if badge2d == 1:
    badge2 = funny
  if badge3d == 1:
    badge3 = funny
  File "/home/runner/miner-bot/venv/lib/python3.8/site-packages/discord/app_commands/commands.py", line 862, in _do_call
    return await self._callback(interaction, **params)  # type: ignore
  File "main.py", line 294, in profile
    profile2.add_field(name='Badges', value=f'{badge1}\n{badge2}\n{badge3}')
UnboundLocalError: local variable 'badge1' referenced before assignment

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

Traceback (most recent call last):
  File "/home/runner/miner-bot/venv/lib/python3.8/site-packages/discord/app_commands/tree.py", line 1242, in _call
    await command._invoke_with_namespace(interaction, namespace)
  File "/home/runner/miner-bot/venv/lib/python3.8/site-packages/discord/app_commands/commands.py", line 887, in _invoke_with_namespace
    return await self._do_call(interaction, transformed_values)
  File "/home/runner/miner-bot/venv/lib/python3.8/site-packages/discord/app_commands/commands.py", line 880, in _do_call
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'profile' raised an exception: UnboundLocalError: local variable 'badge1' referenced before assignment
north pecan
glossy shore
#

Hello,Iโ€™m planning to make a discord music bot
With a web-app, that allows for media control over the music-bot

Is it possible to receive status updates from the bot
And send commands like, play/pause from the web-app to the bot ?

slate swan
abstract kindle
north pecan
#

thats what descriptions are for

slate swan
#

i fixed it dw

north pecan
#

also i wouldn't structure your code that way kinda DRY

abstract kindle
#

I suppose. But if someone is used to typing /balance and i change it to /profile, they're probably not going to look through and read the descriptions to find the command

#

They might just assume that it got deleted or removed because not every user is smart

north pecan
#

well skill issue lmao but i believe you can just make a function x and pass the ctx to the old function a

#

however that seems counter intuitive why change the name in the first place

abstract kindle
#

think like a developer

slate swan
abstract kindle
#

I don't care if its counter intuitive, its a possibility, and user experience matters in every possibility

slate swan
#

how do I get custom emojis in embeds

north pecan
#

like i said

#

create a new bot command, call it the name u want, invoke the old command and pass the ctx to it

#

and whatever other *args, **kwargs

#
@bot.command()
async def new_command(ctx, *args, **kwargs):
  await asyncio.gather(asyncio.create_task(old_command(ctx, *args, **kwargs))

might be the wrong asyncio command but u get the idea

abstract kindle
#

I'm using slash commands btw

north pecan
#

i know

#

im just writing a mock up example

north pecan
#

btw you don't need to use f-strings when you're only accessing a variable

slate swan
#

@north pecan sure

north pecan
#

awit

#

i think i made a mistake hold up

north pecan
#

sorry got distracted

#

anyway after you load users you can do users[user.id] = {key : (funny if value == 1 else value) for key, value in users[user.id].items()}

#

if u want u can also do it for all users easily

#

i know i know not the most intuitive

cold frigate
#

how do i get my bot to send 2 sepereate messages after interacting to a dropdown?

shrewd apex
cold frigate
#

oh i see

#

i think

glad cradle
#

you can also use Interaction.send

cold frigate
slate swan
# slate swan What is the problem

You dont have a requirements.txt

ie:

discord.py==1.7.3
dnspython==2.1.0
motor==2.5.1
humanize==3.12.0
attrs==21.2.0
buttons==0.1.9```
cold frigate
#

1 interaction

shrewd apex
#

oof

glad cradle
cold frigate
#

yes

glad cradle
#

-d discord.Interaction.send

shrewd apex
glad cradle
#

hell

cold frigate
#

this code wont work because it says its already interacted to 1

glad cradle
#

i said Interaction.send

shrewd apex
# cold frigate

yeah so either followup.send or channel.send not sure abt interaction.send

#

lemme check source

glad cradle
cold frigate
#

@glad cradle it wont work

glad cradle
cold frigate
glad cradle
#

!d disnake.Interaction.send

unkempt canyonBOT
#

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

Sends a message using either [`response.send_message`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionResponse.send_message "disnake.InteractionResponse.send_message") or [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send").

If the interaction hasnโ€™t been responded to yet, this method will call [`response.send_message`](https://docs.disnake.dev/en/latest/api.html#disnake.InteractionResponse.send_message "disnake.InteractionResponse.send_message"). Otherwise, it will call [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send").

Note

This method does not return a [`Message`](https://docs.disnake.dev/en/latest/api.html#disnake.Message "disnake.Message") object. If you need a message object, use [`original_response()`](https://docs.disnake.dev/en/latest/api.html#disnake.Interaction.original_response "disnake.Interaction.original_response") to fetch it, or use [`followup.send`](https://docs.disnake.dev/en/latest/api.html#disnake.Webhook.send "disnake.Webhook.send") directly instead of this method if youโ€™re sending a followup message.
glad cradle
#

a good library

shrewd apex
#

didn't find any interaction.send in dpy source oh ic

shrewd apex
north pecan
cold frigate
#

how do i use .folloup??

shrewd apex
glad cradle
north pecan
#

have you had this issue with intents:

AttributeError: 'Intents' object has no attribute 'GUILD_PRESENCES'```
when i try to pass my intents
#

without intents it works but i need my intents

glad cradle
#

what lib are you using

north pecan
#

interactions, discord

#
intents = discord.Intents.all()
intents.members = True
intents.presences = True
intents.message_content = True

client = interactions.Client(token=os.environ.get('SYMBASY_BOT_TOKEN'), intents=intents)```
shrewd apex
#

bro

north pecan
#

?

shrewd apex
#

is that like 2 diff libs? are u passing intents class instance from dpy to interactions lib?

north pecan
#

is there interactions.intents?

#

am i not supposed to use dpy at all

#

i just got back into dpy and slash commands are new to me im unaware of the libraries needed

glad cradle
north pecan
#

plus the docs showed using discord intents

shrewd apex
#

... bro just use discord.py dont use same random third party lib even if u are using atleast use disnake hikari nextcord

cold frigate
#

btw guys does anyone i can make my dropdown so only you click it once??

north pecan
#

wdym

#

intereactions is slash command

shrewd apex
#

discord api lib packages generally cause conflicts with each other

north pecan
#

its not third party its offical

glad cradle
shrewd apex
north pecan
#

yeah it works now ty

glad cradle
cold frigate
#

isnt it like buttons? cant i do

glad cradle
#

!d discord.ui.View.interaction_check

unkempt canyonBOT
#

await interaction_check(interaction, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

A callback that is called when an interaction happens within the view that checks whether the view should process item callbacks for the interaction.

This is useful to override if, for example, you want to ensure that the interaction author is a given user.

The default implementation of this returns `True`.

Note

If an exception occurs within the body then the check is considered a failure and [`on_error()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View.on_error "discord.ui.View.on_error") is called.
cold frigate
#

self.stop

shrewd apex
#

u can that stops the view

shrewd apex
shrewd apex
# slate swan

that was an example u are supposed to make one for ur project specifically

#

there is some conflict within the packages u installed

#

since idk contents of bot.py i have no idea what dependencies u need

cold frigate
#

how do i make my bot copy and paste into general ids i send to it and only ids nothing else?

slate swan
shrewd apex
cold frigate
#

but just ids and nothing else and when i mean ids i mean discord ids

shrewd apex
cold frigate
shrewd apex
#

how do you take in ids then?

#

also what type of id is it?

cold frigate
#

discord

#

i js need it to copy a id i send of someone and paste it but i only want it to paste ids nothing else

shrewd apex
#

role, user, channel, message ๐Ÿ—ฟ

cold frigate
#

i have ticket tool for that

shrewd apex
cold frigate
shrewd apex
#

so why cant it be a command?

cold frigate
#

it js cant

shrewd apex
#

so the ids that are being sent by this ticket tool is part of the bot itself right?

#

or is it another bot or something

cold frigate
shrewd apex
#

idk

#

only ticket thing ik is where u click on a button to create a ticket channel

cold frigate
shrewd apex
#

given the limited amount ik from your question my suggestion would be to use the on_message event then

cold frigate
shrewd apex
#

just create a seperate channel for dumping ids

cold frigate
#

what do u mean?

shrewd apex
#

i mean alot a channel for dumping ids make it a pvt channel and let bot listen to it

cold frigate
#

@shrewd apex shall i show u a example of what i mean

#

by what im looking for

shrewd apex
#

go ahead

cold frigate
#

ok

slate swan
cold frigate
#

@shrewd apex dmed u

shrewd apex
#

ok

slate swan
#

hey

#

can anyone help me to get started?

#

i want to get into making bots

#

but i would need some help

#

Has anyone got a simple mute command?

naive briar
#

!d discord.Member.timeout

unkempt canyonBOT
#

await timeout(until, /, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Applies a time out to a member until the specified date time or for the given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "(in Python v3.11)").

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

This raises the same exceptions as [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.edit "discord.Member.edit").
cold frigate
#

does anyone know how i can make my bot dropdown options only clickable once?

alpine cove
#

button_presses = []

#

*pressed

#

if button in buttons_pressed

#

return

alpine cove
#

u get the point tho

cold frigate
#

wot

#

ohhhhhhhh lemme try it out

mighty pilot
#

Is there a way to see users use commands for other bots?

#

There's a bump reminder bot that starts a timer when you bump Disboard and that intrigues me

fading marlin
mighty pilot
#

It's a slash command though

fading marlin
#

oh? ๐Ÿค”

mighty pilot
#

Yea it's got me lol

naive briar
#

Then check if the content is from the bot and bump related or not probably

mighty pilot
#

Ohh it can see the message content sent from the disboard bot

cold frigate
naive briar
#

I would just disable it

cold frigate
#

but where do i put the self.stop

naive briar
#

Or remove the view from the message entirely

mighty pilot
cold frigate
fading marlin
cold frigate
#

like this @mighty pilot ?

mighty pilot
# cold frigate

Inside your if statements for self.values you could put self.stop() and the menu will still be there but unable to interact with it. Or you can make the menu go away like Lee and Catgal said

fading marlin
mighty pilot
#

Yea that's what i interpreted unavailable as

#

Many ways to skin a cat Idkchu pick your poison

naive briar
#

My god

fading marlin
unkempt canyonBOT
mighty pilot
north pecan
slate swan
#

i dont understand it

silent ermine
#

Is there a way to find out who a user replied to and get the message that they replied to? (so like if I replied to John and he said xyz, I want to get the name John and the text xyz)

slate swan
slate swan
#

Can someone help with that

merry sail
#

do "ls" and check if the file is actually there

slate swan
merry sail
#

yeah

slate swan
# merry sail yeah
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        11/13/2022   5:52 PM            828 badge.py


PS C:\Users\dynam\Documents\badge>```
#

is what i got

merry sail
#

you're trying to get python to run a file called main.py but the only file you have is badge.py

slate swan
#

๐Ÿคฆ

#

Oh my

#

Sorry dude I'm so use to doing main.py

slate swan
#
from discord import app_commands 

class aclient(discord.Client):
    def __init__(self):
        super().__init__(intents = discord.Intents.default())
        self.synced = False

    async def on_ready(self):
        await self.wait_until_ready()
        if not self.synced:
            await tree.sync() 
            self.synced = True
        print(f"Logged in as {self.user}.")

client = aclient()
tree = app_commands.CommandTree(client)

@tree.command(name = 'discord_badge', description='Active Developer Badge')
async def self(interaction: discord.Interaction, name: str):
    await interaction.respond.send_message(title="Hello {name}", description=f"Thank you for running the Slash Command")

client.run("token.")```
merry sail
#

slash commands take a few minutes to register in discord since you don't have any test servers set

slate swan
# merry sail slash commands take a few minutes to register in discord since you don't have an...

Oh it registered just doesn't work

  File "C:\Users\dynam\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\commands.py", line 876, in _invoke_with_namespace
    return await self._do_call(interaction, transformed_values)
  File "C:\Users\dynam\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\commands.py", line 869, in _do_call
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'discord_badge' raised an exception: AttributeError: 'Interaction' object has no attribute 'respond'```
sick birch
slate swan
# sick birch Did you do `interaction.respond(...)`?
@tree.command(name = 'discord_badge', description='Active Developer Badge')
async def self(interaction: discord.Interaction, name: str):
    await interaction.respond.send_message(title="Hello {name}", description=f"Thank you for running the Slash Command")```
sick birch
#

It's interaction.response

slate swan
#

Okay I'll test

slate swan
# sick birch It's `interaction.response`
  File "C:\Users\dynam\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\commands.py", line 851, in _do_call
    return await self._callback(interaction, **params)  # type: ignore
  File "C:\Users\dynam\Documents\badge\badge.py", line 21, in self
    await interaction.response(title="Hello {name}", description=f"Thank you for running the Slash Command")
TypeError: 'InteractionResponse' object is not callable

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

Traceback (most recent call last):
  File "C:\Users\dynam\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\tree.py", line 1240, in _call
    await command._invoke_with_namespace(interaction, namespace)
  File "C:\Users\dynam\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\commands.py", line 876, in _invoke_with_namespace
    return await self._do_call(interaction, transformed_values)
  File "C:\Users\dynam\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\commands.py", line 865, in _do_call
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'discord_badge' raised an exception: TypeError: 'InteractionResponse' object is not callable```
sick birch
slate swan
# sick birch It's just `interaction.response.send_message(...)`
from discord import app_commands 

class aclient(discord.Client):
    def __init__(self):
        super().__init__(intents = discord.Intents.default())
        self.synced = False

    async def on_ready(self):
        await self.wait_until_ready()
        if not self.synced:
            await tree.sync() 
            self.synced = True
        print(f"Logged in as {self.user}.")

client = aclient()
tree = app_commands.CommandTree(client)

@tree.command(name = 'discord_badge', description='Active Developer Badge')
async def self(interaction: discord.Interaction, name: str):
    await interaction.response.send_messagee(title="Hello {name}", description=f"Thank you for running the Slash Command")

client.run("")
#

Good?

sick birch
slate swan
# sick birch Run it and see โ„ข๏ธ
Traceback (most recent call last):
  File "C:\Users\dynam\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\commands.py", line 851, in _do_call
    return await self._callback(interaction, **params)  # type: ignore
  File "C:\Users\dynam\Documents\badge\badge.py", line 21, in self
    await interaction.response.send_messagee(title="Hello {name}", description=f"Thank you for running the Slash Command")
AttributeError: 'InteractionResponse' object has no attribute 'send_messagee'

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

Traceback (most recent call last):
  File "C:\Users\dynam\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\tree.py", line 1240, in _call
    await command._invoke_with_namespace(interaction, namespace)
  File "C:\Users\dynam\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\commands.py", line 876, in _invoke_with_namespace
    return await self._do_call(interaction, transformed_values)
  File "C:\Users\dynam\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\commands.py", line 869, in _do_call
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'discord_badge' raised an exception: AttributeError: 'InteractionResponse' object has no attribute 'send_messagee'```
sick birch
#

You have an extra e

#

In send_messagee

slate swan
# sick birch In `send_messagee`
Traceback (most recent call last):
  File "C:\Users\dynam\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\commands.py", line 851, in _do_call
    return await self._callback(interaction, **params)  # type: ignore
  File "C:\Users\dynam\Documents\badge\badge.py", line 21, in self
    await interaction.response.send_message(title="Hello {name}", description=f"Thank you for running the Slash Command")
TypeError: InteractionResponse.send_message() got an unexpected keyword argument 'title'

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

Traceback (most recent call last):
  File "C:\Users\dynam\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\tree.py", line 1240, in _call
    await command._invoke_with_namespace(interaction, namespace)
  File "C:\Users\dynam\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\commands.py", line 876, in _invoke_with_namespace
    return await self._do_call(interaction, transformed_values)
  File "C:\Users\dynam\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\app_commands\commands.py", line 865, in _do_call
    raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'discord_badge' raised an exception: TypeError: InteractionResponse.send_message() got an unexpected keyword argument 'title'```
sick birch
#

Are you trying to send an embed?

slate swan
#

no embeds I just want to run an slash command

sick birch
sick birch
#

You do not

#

You have title= and description= which is not valid

merry sail
#

no, you're trying to set 'title' and 'description'

#

yeah, which are not arguments that send_message() takes

sick birch
#

!d discord.InteractionResponse.send_message

unkempt canyonBOT
#

await send_message(content=None, *, embed=..., embeds=..., file=..., files=..., view=..., tts=False, ephemeral=False, allowed_mentions=..., suppress_embeds=False, delete_after=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Responds to this interaction by sending a message.
sick birch
#

The documentation is pretty clear

slate swan
sick birch
upbeat gust
#

Maybe

slate swan
upbeat gust
#

!d discord.Embed.from_dict

unkempt canyonBOT
#

classmethod from_dict(data)```
Converts a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.11)") to a [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") provided it is in the format that Discord expects it to be in.

You can find out about this format in the [official Discord documentation](https://discord.com/developers/docs/resources/channel#embed-object).
slate swan
#

I wanna send out embed, it has a lot of information and needs to be edited often

#

Thinking I can just have it as a json and send it from that

upbeat gust
#

Load the json into a dict

sick birch
upbeat gust
sick birch
#

It looks like it's all the data for sending a message

#

I would suggest you send a raw API POST request to the endpoint then

slate swan
sick birch
#

Though I don't really get how using a raw JSON is going to make it easier to send it

sick birch
#

Not really

#

You don't get type checking

#

Or any other type of checks really

upbeat gust
pliant gulch
#

It'll be easier in the fact that JSON removes all library abstractions but, it'll backfire if you don't know what you're really doing

upbeat gust
#

just seems like a lot of extra effort using an external tool to make something that you then have to parse

pliant gulch
#

Of course this should follow case-by-case, sometimes it's fine to curl and other times it's best to use a wrapper

#

But for webhooks and what not I usually make my own requests manually

#

Since I won't need a server or what not

upbeat gust
upbeat gust
hollow gazelle
#

never seen this before who can help not even importing discord.sinks

pliant gulch
#

Do you see what I mean

#

And again this is case-by-case

#

You shouldn't be using curl and simple stuff for things that requires gateway connection

upbeat gust
#

No idea what this guy's actually trying to do though so can't exactly tell what to suggest

upbeat gust
#

just ask your question

hollow gazelle
#

never seen this before who can help not even importing discord.sinks

upbeat gust
#

Or some 3rd party lib

hollow gazelle
upbeat gust
#

check, use pip list
Give me a yes/no answer

hollow gazelle
#

discord 2.0.0
discord.py 2.0.1
discord-webhook 0.17.0

upbeat gust
#

show the full output

slate swan
#

i have all these installed already but its telling me to agaibn

#

reload the ide

#

?

supple herald
#

Hi

#

My discord-bot always leaves the server...

#

What am I doing wrong?

upbeat gust
supple herald
#

I use replit.

#

I invite the bot to my server.

#

My bot is alive and writes a message to the server.

#

Then it leaves the server.

upbeat gust
#

lmao what

#

Someone's kicking ur bot

sick birch
#

yeah

#

the bot shouldn't be leaving the server on its own

#

unless you have another instance of your bot running / someone has your token and is running their own script on your bot

#

both of which can be solved by resetting your token

supple herald
#

Hmm..

slate swan
tranquil badge
#
initial_extensions = ['cogs.simple']

# Here we load our extensions(cogs) listed above in [initial_extensions].
async def load():
    for extension in initial_extensions:
        try:
            await bot.load_extension(extension)
        except Exception as e:
            print(f'Failed to load extension {extension}.', file=sys.stderr)
            traceback.print_exc()

I can't get my cog to load. Ive double checked that the cog works by running the file by itself.

#

I have used a couple different methods for loading but nothing seems to work

sick birch
#

What's the traceback?

tranquil badge
#

nothing at all

sick birch
#

Try putting a print statement in the cog's __init__

tranquil badge
#

there is

#

put a listener for when it loads up

sick birch
tranquil badge
#
class SimpleCog(commands.Cog):
    def __init__(self, bot: commands.Bot) -> None:
        self.bot = bot

    @commands.Cog.listener()
    async def on_ready(self):
        print('This bitch loaded')
#

thats what you mean correct?

sick birch
#

Not the listener

tranquil badge
#

nothing

#

on startup

sick birch
tranquil badge
#

oooh found the problem

#

Its not reading that portion

#

Ill post more of the file in few

slate swan
#

does anyone know how I can make a event or something like when someone sends a message in a channel from another serv a bot copy and pastes it into a channel of my choice

tranquil badge
#
@bot.event
async def on_message():
slate swan
tranquil badge
#

not really

sick birch
#

You'll need to implement the logic

tranquil badge
#

^^

sick birch
#
@bot.listen()
async def on_message(message: discord.Message) -> None:
  channel = bot.get_channel(...) # this is the channel which the message should be sent to
  await channel.send(f"User {message.author} said: '{message.content}' in server {message.guild}")
#

@slate swan

#

something similar to that will do

slate swan
#

since im using client

sick birch
#

Yes

slate swan
tranquil badge
#
class RocBot(commands.Bot):
    def __init__(self) -> None:
        super().__init__(command_prefix="!", intents=discord.Intents.all(),
        #NinjaPanda ID, change to yours while running.
        description='Pheonix 2 iOS information bot', owner_ids= [352986404621647873])

    async def setup_hook(self) -> None:
        self.tree.copy_global_to(guild=discord.Object(id=722310060671500410)) #replace your guild id.
        await self.tree.sync()

bot = RocBot()

initial_extensions = ['cogs.simple']

# Here we load our extensions(cogs) listed above in [initial_extensions].
async def load():
    for extension in initial_extensions:
        print('blah')
        try:
            print('work bitch')
            await bot.load_extension(extension)
        except Exception as e:
            print(f'Failed to load extension {extension}.', file=sys.stderr)
            traceback.print_exc()

bot.run(token)
sick birch
tranquil badge
#

none

sick birch
#

Are you actually calling the load() function?

tranquil badge
#

i think its getting skipped entirely

slate swan
#

im not using cogs

sick birch
slate swan
#

oh ok

sick birch
#

They're asking for help, not providing help

slate swan
#

oh sorry

sick birch
#

no worries

tranquil badge
#

smh

#

the unfortunate side of rewriting other peoples code

pliant gulch
#

Why not just smack that all inside of setup_hook

sick birch
#

You could yeah

slate swan
# sick birch no worries
async def on_message(message: discord.Message) -> None:
  channel = client.get_channel("1041476774531432480") # this is the channel which the message should be sent to
  await channel.send(f"User {message.author} said: '{message.content}' in server {message.guild}")``` 
I have this now how could I add where the bot gets message from channels from other servers?
sick birch
#

But since you've already got it in another function, you can just await load()

sick birch
#

on_message gets triggered whenever there is a message anywhere

pliant gulch
#

Where? unless you somehow allow top-level await (without exec flags)

slate swan
pliant gulch
#

It's must easier to get rid of manually setting an entry point and just let the wrapper do it for you

sick birch
tranquil badge
#

oh yeea

sick birch
slate swan
sick birch
#

And only a select list of other channels?

slate swan
sick birch
#

Alright. You'd probably create a list of channel IDs, and in your on_message function, you would check if message.channel.id in channel_ids where channel_ids is the aforementioned list of channel IDs

slate swan
sick birch
slate swan
sick birch
#

that's not a copy paste example

#

you'll have to modify your existing code

#

it should only be a 2 line addition

slate swan
#

i wish I knew how man

sick birch
#

first add a list of channel IDs

slate swan
upbeat gust
slate swan
#

I have

async def on_message(m):
    if m.channel.id in channel_ids:
    # send message to your own server```
#

right now

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/latest/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.11)") of [`File`](https://discordpy.readthedocs.io/en/latest/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/latest/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.11)") of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
sick birch
#

!d discord.Client.get_channel

unkempt canyonBOT
#

get_channel(id, /)```
Returns a channel or thread with the given ID.

Changed in version 2.0: `id` parameter is now positional-only.
upbeat gust
slate swan
slate swan
upbeat gust
tranquil badge
#
initial_extensions = ['cogs.simple']

# Here we load our extensions(cogs) listed above in [initial_extensions].
async def load():
    for extension in initial_extensions:
        print('blah')
        try:
            print('work bitch')
            await bot.load_extension(extension)
        except Exception as e:
            print(f'Failed to load extension {extension}.', file=sys.stderr)
            traceback.print_exc()

class RocBot(commands.Bot):
    def __init__(self) -> None:
        super().__init__(command_prefix="!", intents=discord.Intents.all(),
        #NinjaPanda ID, change to yours while running.
        description='Pheonix 2 iOS information bot', owner_ids= [352986404621647873])

    async def setup_hook(self) -> None:
        await self.load()
        self.tree.copy_global_to(guild=discord.Object(id=722310060671500410)) #replace your guild id.
        await self.tree.sync()

bot = RocBot()
    await self.load()
TabError: inconsistent use of tabs and spaces in indentation```
I dont understand
slate swan
upbeat gust
#

of what

upbeat gust
slate swan
upbeat gust
#

what part is confusing

tranquil badge
#

how is it that though

slate swan
upbeat gust
#

yes but what dont you understand

tranquil badge
slate swan
#

I have this and it runs but doesnt work

#
async def on_message(m):
    if m.channel.id in channel_ids:
        channel = client.get_channel(1041527847396835338)
        await channel.send('{message}')```
upbeat gust
#

youre missing the @client.listen() decorator

slate swan
# upbeat gust youre missing the `@client.listen()` decorator
from discord import app_commands 

class aclient(discord.Client):
    def __init__(self):
        super().__init__(intents = discord.Intents.default())
        self.synced = False

    async def on_ready(self):
        await self.wait_until_ready()
        if not self.synced:
            await tree.sync() 
            self.synced = True
        print(f"Logged in as {self.user}.")

client = aclient()
tree = app_commands.CommandTree(client)

@client.listen()
async def on_message(m):
    channel_ids = [1041476774531432480]
    if m.channel.id in channel_ids:
        channel = client.get_channel(1041527847396835338)
        await channel.send('{message}')

    # send message to your own server

client.run("")```
upbeat gust
#

looks good

sick birch
#

I don't think client objects have a listen method do they

slate swan
#

is my code I got the error of @client.listen()
AttributeError: 'aclient' object has no attribute 'listen'

upbeat gust
#

ugh

sick birch
#

might just be a thing of Bot

pliant gulch
#

wait_until_ready waits for asyncio.Event() to be set (ready) and on_ready is also called when ready is set

#

was there as reason for it

upbeat gust
slate swan
#
TypeError: Client.event() missing 1 required positional argument: 'coro```
upbeat gust
#

dont call it

hollow gazelle
#

AttributeError: module 'discord' has no attribute 'Bot'

upbeat gust
hollow gazelle
upbeat gust
slate swan
sick birch
hollow gazelle
upbeat gust
hollow gazelle
#

well

#

i have it imported

upbeat gust
sick birch
hollow gazelle
#

but even it still dont work

slate swan
hollow gazelle
#

ok

slate swan
#

oops

#

sorry i read it wrong

upbeat gust
#

setup_hook is a method of client that you can override

#

it only runs once so you dont have to worry about self.synced

#

if youre watching a tutorial, its pretty bad

slate swan
slate swan
upbeat gust
#

a better way that does affect it is syncing using a command

slate swan
upbeat gust
#

what error

upbeat gust
#

i answered already

upbeat gust
slate swan
#

acting like i can read ur mind

upbeat gust
#

calling is a basic python term/concept

#

I expect you to know this

slate swan
#

I don't understand why you cant be specific

upbeat gust
#

am I not?

upbeat gust
slate swan
#

Whatever imma go to a help channel im not tryna fight wit u

sick birch
#

I'm with Chris on this one, sorry. They're pretty specific. discord.py is not a library suitable for beginners, so unfortunately we do expect a certain level of Python knowledge before coming in. You may find !resources to be helpful before continuing

upbeat gust
tranquil badge
sick birch
#

We just need to use our best judgement

pliant gulch
upbeat gust
#

maybe turn on indentation guides/extensions etc in your ide

tranquil badge
#

ok

#

ill check into it

tranquil badge
sick birch
#

Your IDE/editor will usually tell you

hollow gazelle
#

Exception has occurred: AttributeError
'Bot' object has no attribute 'slash_command'

#

helppppppp pls

sick birch
#

Please don't crosspost

hollow gazelle
#

whats that

sick birch
#

Sending your question in multiple channels

hollow gazelle
sick birch
#

People are going to try to help you even if someone already helped you

sick birch
hollow gazelle
#

ye

tranquil badge
#

found it, weird indentation that looked proper

slate swan
#

@upbeat gust when I remove the on_ready the whole thing under it is an error

shrewd apex
upbeat gust
#

nice

tranquil badge
#

nice drawing

slate swan
#

wow what a bunch of a holes innit whats the point of being here to not help ๐Ÿคก

upbeat gust
#

for the people who actually have some idea what theyre doing

sick birch
exotic rover
#

B I G

tranquil badge
#

pog u

#

it finally loaded

#

thanks @sick birch

potent light
#

What's the event for select menu when using wait_for()?

upbeat gust
potent light
# upbeat gust why do you need an event?

Yes discordpy 2.0. I need the event for a select menu to make sure that the bot waits for the user to choose before they can proceed executing the rest of the code.

upbeat gust
#

Components in dpy use callbacks

#

You don't use events like forks

#

1 sec

potent light
#

I am doing it already. I was just trying to figure out if there is a way to call another select menu without doing it inside the callback.

upbeat gust
#

then access the select values

upbeat gust
#

you literally said you're using dpy

#

now you link pycord docs

potent light
#

oh my bad

#
view = View()
view.add_item(select)
await view.wait()
await ctx.send("SELECT MENU", view = view)```
shrewd apex
#

subclassing view and select makes this easier

potent light
#

now it doesn't even call the menu

sick birch
shrewd apex
shrewd apex
potent light
#

@shrewd apex@sick birch i'll try that after this

#
                    async def my_callback(interaction):
                        
                        await interaction.response.send_message(f"nice choice: {select.values}")
                    select.callback = my_callback
                    view = View()
                    view.add_item(select)
                    
                    await ctx.send("SELECT MENU", view = view)
                    await view.wait()```
#

well how do I format the spaces on Discord? this message looks ugly.
Also, now it sends the SELECT MENU but apparently it keeps waiting. When is stop() called? can I just put it inside my_callback()?

shrewd apex
#

either i am seeing wrong or is the indentation messed up

potent light
#

It worked guys! tysm!

potent light
shrewd apex
#
view = View()
select = Select()

async def foo(inter):
    # respond
    view.stop()

select.callback = foo
view.add_item(select)
await ctx.send(view=view)
await view.wait()
#

@potent light

potent light
tranquil badge
#
@bot.command(name='sync')
@commands.guild_only()
@commands.is_owner()
async def sync(ctx: commands.Context, guilds: Greedy[discord.Object], spec: Optional[Literal["~", "*", "^"]] = None) -> None:

me again

#

getting a greedy is not defined. using code written by someone else, don't know how to define it within the bot file.

#

unsure if it's an import that i need. I have from typing import Optional, Literal already

#

got an error when i tried to import Greedy

#

would guilds: Get[discord.Object] be better for this case?

potent light
#

@shrewd apex what if I want to close interaction in select menu after the user picks one without using send_message() what should be used in this case?

potent light
sick birch
tranquil badge
#

yea i do

#

got a type error with get

sick birch
#

not sure if that's a valid converter though let me check

tranquil badge
#

not subscriptable

potent light
shrewd apex
tranquil badge
#

that makes sense

sick birch
#

yeah

tranquil badge
#

lemme try

shrewd apex
#

!d discord.ext.commands.Greedy

unkempt canyonBOT
#

class discord.ext.commands.Greedy```
A special converter that greedily consumes arguments until it canโ€™t. As a consequence of this behaviour, most input errors are silently discarded, since it is used as an indicator of when to stop parsing.

When a parser error is met the greedy converter stops converting, undoes the internal string parsing routine, and continues parsing regularly.

For example, in the following code:

```py
@commands.command()
async def test(ctx, numbers: Greedy[int], reason: str):
    await ctx.send("numbers: {}, reason: {}".format(numbers, reason))
```  An invocation of `[p]test 1 2 3 4 5 6 hello` would pass `numbers` with `[1, 2, 3, 4, 5, 6]` and `reason` with `hello`...
tranquil badge
#

yep

#

worked

potent light
#

nice

tranquil badge
#

someone github got 99% of the way there lol

potent light
dense flower
#

anyone got a recommended library for interacting with twitter?

potent light
shrewd apex
potent light
dense flower
shrewd apex
#

in an interaction u need to respond somehow no matter what

potent light
#

apparently there are not enough methods provided for InteractionResponse so...

potent light
shrewd apex
potent light
#

when there is no response.

shrewd apex
#

u need to respond thats what my point is if u want no change at all u can just edit the message again with just the view that way nothing changes

potent light
tacit sentinel
#
def give_rank(rank=["Trades: 0", "Trades: 5", "Trades: 20", "Trades: 35", "Trades: 50", "Trades: 75"]):
    @client.event
    async def on_message(message):
        if message.content == "CALC":
            if v_MN[0] > 0: 
                pos = [0,5,20,35,50,75].index(v_MN[0])
                role = get(message.author.guild.roles, name=rank[pos])
                await message.author.add_roles(role)```
#

I am trying to give a role automaticly.

#

v_MN[0] is a function that basicly just returns the correct number (0, 5, 20, 35, 50 or 75).

#

I use .index to receive the position of the rank list.

#

So that I can precisely name the correct rank "Trades: 5".

#
role = get(message.author.guild.roles, name="Trades: 5")
await message.author.add_roles(role)```
Should then give me that rank.
#

So why does it not work?

chilly dove
tranquil badge
#

Is there a way to hide commands from showing in the slash command list? Iโ€™m using hybrid commands with hidden=True to hide it in the help menus. I havenโ€™t seen anything for hiding commands in the slash list

shrewd apex
tranquil badge
#

what i mean is when you type / it shows a list of available commands

#

im wondering if there is a way to hide commands in that list

#

such as a command that has is_owner()

slate swan
#

i use it to hide dev cmds. i set a guild_id for the command and set default perms to admin so only ppl in my server with admin will see the command which is just me.

#

nextcord.errors.ApplicationInvokeError: Command raised an exception: TypeError: Expected nextcord.Colour, int, or None but received dict instead.

#

what are u trying to do? mix the colors if so thats not possible has to be one solid color

slate swan
#

then do

if colour == "white":
    embed.colour = white
#

elif statement for black

#

if colour == "white":
embed.colour = 0xffffff

#

mhm

#

thanks!

#

ill try

#

WORKS

#

tysmm

#

yup np

dense horizon
#

Guys, how to make a program to show 2 modal forms in a row. discord.py

shrewd apex
dense horizon
#

Dammit

#

Thanks

placid skiff
#

and you will not need to convert every string into a Colour object

slate swan
#

Ye that will work too

#

Tyy

placid skiff
#

if you want to add something fancy, you can check if the user types "random" and then use discord.Colour.random()

#

!d discord.Colour.random

unkempt canyonBOT
#

classmethod random(*, seed=None)```
A factory method that returns a [`Colour`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Colour "discord.Colour") with a random hue.

Note

The random algorithm works by choosing a colour with a random hue but with maxed out saturation and value.

New in version 1.6.
slate swan
#

is there a server where i can pay crypto for an experienced developer to build a bot for me

placid skiff
#

i don't think that this is the right place to ask that

slate swan
#

fiverr

cloud dawn
#

It's pretty normal for people to pay over 10k for temporary single release bots in Python.

placid skiff
#

is it made with gold? PepeCryLaugh

drowsy atlas
#
@client.event
async def on_ready():
    user = await client.fetch_user(596956753657069599)
    print(f'{user}')
    a = user._asdict()
    print(a)```
"It says User object has no attribute _asdict"
So how to print the user obj as json?
cloud dawn
#

So an hourly rate of 10_000/4 people / 40hrs * 4 = 15.625 euro/dollar, pretty reasonable and on the cheap side lol

placid skiff
cloud dawn
#

!d json.loads

unkempt canyonBOT
#

json.loads(s, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)```
Deserialize *s* (a [`str`](https://docs.python.org/3/library/stdtypes.html#str "str"), [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") or [`bytearray`](https://docs.python.org/3/library/stdtypes.html#bytearray "bytearray") instance containing a JSON document) to a Python object using this [conversion table](https://docs.python.org/3/library/json.html#json-to-py-table).

The other arguments have the same meaning as in [`load()`](https://docs.python.org/3/library/json.html#json.load "json.load").

If the data being deserialized is not a valid JSON document, a [`JSONDecodeError`](https://docs.python.org/3/library/json.html#json.JSONDecodeError "json.JSONDecodeError") will be raised.

Changed in version 3.6: *s* can now be of type [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") or [`bytearray`](https://docs.python.org/3/library/stdtypes.html#bytearray "bytearray"). The input encoding should be UTF-8, UTF-16 or UTF-32.

Changed in version 3.9: The keyword argument *encoding* has been removed.
drowsy atlas
cloud dawn
drowsy atlas
#

hm I shall try that too

cloud dawn
# drowsy atlas hm I shall try that too

!e ```py
import json

test = {"hello": "world", "1": "2"}
print(type(test))
dmp = json.dumps(test)
print(type(dmp))
jos = json.loads(dmp)
print(type(jos))
print(jos)

unkempt canyonBOT
#

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

001 | <class 'dict'>
002 | <class 'str'>
003 | <class 'dict'>
004 | {'hello': 'world', '1': '2'}
cloud dawn
#

Now it's serialized so considered a "json object"

drowsy atlas
#

ok lemme test it

cloud dawn
#

It's weird that there isn't a function for this smh

drowsy atlas
#
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type User is not JSON serializable```
cloud dawn
#

Then there is an issue somewhere in your dict that needs attention.

#

Do you have anything as key that isn't a string?

#

Because you do need to still follow json rules, there isn't a "converter" that does that for you.

drowsy atlas
slate swan
#

the user class is slotted, you can dict it

#

*can't

cloud dawn
#

monkey patching ๐Ÿ’

cloud dawn
drowsy atlas
#

so do I need to write a subroutine to just print the variable I need?

slate swan
placid skiff
#

it saves all necessary attributes

cloud dawn
slate swan
#

tell me its for saving the user in a json file and im calling the FBI

drowsy atlas
#

read the user info

placid skiff
drowsy atlas
#

XD

cloud dawn
slate swan
placid skiff
#

Pls don't tell us that you want to use it as a database D_D

cloud dawn
drowsy atlas
#

I am learning. haven't reached the level of app command yet

cloud dawn
#

Or just get or fetch it again.

#

Or just use self with subclassing.

#

Or botvar

#

Ill stop

slate swan
#

why doesn't discord.py let the users get the raw payloads lol

cloud dawn
placid skiff
placid skiff
#

oh lol didn't read that

cloud dawn
#

Also I think it's better to use inspect.

placid skiff
#

Well i still think that there is no use in doing that lol

slate swan
unkempt canyonBOT
#

discord/user.py line 89

def __init__(self, *, state: ConnectionState, data: Union[UserPayload, PartialUserPayload]) -> None:```
slate swan
#

could have just added it as an attr of the class

placid skiff
#

even if you want to save some data the only user attribute that you really need is the id

cloud dawn
tepid dagger
#

wait

#

how do you get commands to be able to select options

#

like these:

slate swan
#

make the parameter just that

#

async def rank(member: discord.Member)

tepid dagger
#

what if i want it to be like a keyword

#

like an amount or some integer value

slate swan
#

you can use typing.Literal and supply an option like so

tepid dagger
#

example?

slate swan
#
async def random_number(number: typing.Literal["1", "2"])

will give the option of choosing 1 or 2

tepid dagger
#

ok

#

what if it's like any integer

#

from 1 2 infintie

slate swan
#

number: int
this will only accept integers

shrewd apex
#

for integer use app_command.range iirc something similar

tepid dagger
slate swan
#

yes

tepid dagger
#

ok

slate swan
#

will do this if u dont supply an integer

tepid dagger
#

does it need to be a slash command

slate swan
#

nah

tepid dagger
#

ok

#

how to store that value as a variable

#

and use that variable in the command

#

.

tepid dagger
river obsidian
#

are there any webhook example?

soft radish
#

how do i fix py Privileged message content intent is missing, commands may not work as expected.

tepid dagger
#

go to the discord dev portal

#

open the application

#

with the bot

#

go to the bot section

#

switch the privileged message content intent on

#

did it work

slate swan
#

you need to enable message_content intents in the code as well

tepid dagger
#

by doing: intents = discord.Intents().all()

soft radish
#

like way before

soft radish
slate swan
#

good for you

soft radish
#

like 3 hrs ago

slate swan
#

show code lol

soft radish
#

whole?

#

or partial?

slate swan
#

just your intents and bot constructor

soft radish
#

k

soft radish
#

my commands doesnt work but my event works

slate swan
soft radish
slate swan
#

put it next to the intents= discord.Intents.default()

tepid dagger
#

imo you should do

#

intents = discord.Intents.all()

slate swan
#

bad practice doing that especially if youre not using all

#

that enables all intents thats unnecessary

tepid dagger
#

but either works fine

slate swan
#

then you when u go to verify you have to explain why you want all intents

#

then realize u dont need them then yea

#

if something works that doesn't mean you should be doing that

#

^

tepid dagger
#

wut

tepid dagger
#

i stupid

tepid dagger
#

i have too many questions to ask in this server

slate swan
#

oo its documented in the bot

tepid dagger
#

is there a section

placid skiff
#

it's python typing D_D

slate swan
#

yeah a python book

#

lol

tepid dagger
#

wut

placid skiff
#

!d typing

unkempt canyonBOT
#

New in version 3.5.

Source code: Lib/typing.py

Note

The Python runtime does not enforce function and variable type annotations. They can be used by third party tools such as type checkers, IDEs, linters, etc.

This module provides runtime support for type hints. The most fundamental support consists of the types Any, Union, Callable, TypeVar, and Generic. For a full specification, please see PEP 484. For a simplified introduction to type hints, see PEP 483.

The function below takes and returns a string and is annotated as follows...

tepid dagger
#

ok

#

cus me want to make it for all integers less than smth

#

i couldnโ€™t find anything anywhere

placid skiff
#

do you mean with a command?

tepid dagger
#

yes

#

oh wait nvm

placid skiff
#

with commands things work differently

#

but it is suggested that you learn to work with typing first

austere gust
#

Hey. I tried to add a slash command but I get this error:

placid skiff
#

also typing is very helpful

austere gust
#
bot = commands.Bot(command_prefix='.', intents=intents)
tree = app_commands.CommandTree(bot)
bot.remove_command("help")

@tree.command(name = "hello", description = "Badge", guild=discord.Object(id=959079594886070372)) 
async def first_command(interaction):
    await interaction.response.send_message("Hello!")```
#

this is the code

slate swan
#

it already has one by default

austere gust
#

oo

slate swan
austere gust
#

tree = app_commands.CommandTree(bot)

#

so I delete this line?

slate swan
#

remove dat line, use bot.tree whenever you want the tree

austere gust
#

o

#

thx

slate swan
#

๐ŸŒณ save trees

austere gust
#

the command isnt working

#
@bot.tree.command(name = "hello", description = "Badge", guild=discord.Object(id=959079594886070372))
async def first_command(interaction):
    await interaction.response.send_message("Hello!")```
#

Did I do something wrong?

slate swan
#

!d discord.app_commands.CommandTree.command

unkempt canyonBOT
#

@command(*, name=..., description=..., nsfw=False, guild=..., guilds=..., auto_locale_strings=True, extras=...)```
A decorator that creates an application command from a regular function directly under this tree.
slate swan
#

did you sync the command tree?

merry cliff
#

in your on_ready, make sure to do await bot.tree.sync()

slate swan
#

that would work yeah, but its suggested to sync manually using some command or on_message event instead

naive briar
#

It is more recommended to do it in setup_hook

slate swan
#

on_ready can get triggered multiple times

merry cliff
#

oop ok

austere gust
#
@bot.tree.command(name = "hello", description = "Badge", guild=discord.Object(id=959079594886070372))
async def first_command(interaction):
    await interaction.response.send_message("Hello!")

@app_commands.context_menu()
async def react(interaction: discord.Interaction, message: discord.Message):
    await interaction.response.send_message('Very cool message!', ephemeral=True)

@bot.event
async def on_ready():
    await bot.tree.sync()```
Still no
merry cliff
#

oh this is for the badge lmao

austere gust
#

xD

merry cliff
#

it needs to be a global command

austere gust
#

bru

merry cliff
#

set guild=None

#

then let it register for like 5 min

unkempt canyonBOT
#

examples/app_commands/basic.py lines 22 to 28

# In this basic example, we just synchronize the app commands to one guild.
# Instead of specifying a guild to every command, we copy over our global commands instead.
# By doing so, we don't have to wait up to an hour until they are shown to the end-user.
async def setup_hook(self):
    # This copies the global commands over to your guild.
    self.tree.copy_global_to(guild=MY_GUILD)
    await self.tree.sync(guild=MY_GUILD)```
austere gust
#

guild=discord.Object(None))

naive briar
merry cliff
#

I thought it was but ok

slate swan
tepid dagger
slate swan
tepid dagger
#

what is that

merry cliff
#

in your sync(), set guild=None like the example

austere gust
#

yep

merry cliff
tepid dagger
#

ok

#

so like number: int < 100

merry cliff
#

ye

slate swan
tepid dagger
#

idk proper syntax for that

#

cus it didnโ€™t work in ze bot

#

for commands

austere gust
#
bot.listen()
async def on_ready():
    async def setup_hook(self):
        # This copies the global commands over to your guild.
        self.tree.copy_global_to(guild=None)
        await self.tree.sync(guild=None)```
Should it be like this?
slate swan
#

if you wanna set max values for options just use a slash command lol

tepid dagger
#

how to use those

merry cliff
#

brej

tepid dagger
#

wat

slate swan
austere gust
#

I have never used slash commands, thats why I am dumb

tepid dagger
upbeat gust
slate swan
tepid dagger
slate swan
tepid dagger
#

can i not use them to setup max values

#

or is it like a lot easier

upbeat gust
tepid dagger
#

basically

#

i want to setup a function to do something n times, but n is set by the user but has to be below a certain value

#

and sarth said that itโ€™s easier with slash commands

naive briar
#

It is

tepid dagger
#

how much easier

slate swan
#

in normal command the user will be able to provide any value they want, and you'll have to check the value
in slash command discord won't let them enter the value greater than want you want

tepid dagger
#

so its easier and faster

cloud dawn
#

@slate swan you seen the automod feature?

slate swan
cloud dawn
#

The regex matching is fire

#

Now we still need regex matching for interaction command values

slate swan
#

might actually consider migrating to slash then