#discord-bots

1 messages · Page 135 of 1

potent light
#

yes, it comes from this one:
line 34, in callback await interaction.response.send_modal(Questionnaire(test_list))

fading marlin
#

could you send your code?

potent light
# fading marlin could you send your code?
class Questionnaire(Modal, title='Questionnaire Response'):
    def __init__(self, test_list: list):
        self.test_list = test_list
    email = TextInput(label='Email address', custom_id = "0")
    name = TextInput(label='Username', custom_id = "1")
    how_can_we_help = TextInput(label='How we can help', style=discord.TextStyle.paragraph, custom_id = "5")

    async def on_submit(self, interaction: discord.Interaction):
        await interaction.response.send_message(f'Thanks for your responses!', ephemeral=True)
        print(interaction.data['components'])
        print(self.test_list)```
#

Question class^

#
    @commands.command()
    async def test(self, ctx):
        button = Button(
        custom_id="primary",
        label="Insert information",
    )
        tp = TextInput(label = "hello")
        
        async def callback(interaction):
            test_list = [1, 2]
            await interaction.response.send_modal(Questionnaire(test_list))
            print(interaction)```
fading marlin
#

are you sure you're importing Modal from the right place?

potent light
#

yes because it worked without def __init__()

#

from discord.ui import Select, View, TextInput, Button, Modal

fading marlin
#

oh

#

you're not calling super().__init__

#

you're not instantiating the subclass

hollow gazelle
#

that is full error but holdon

#
if data.license:
    @bot.slash_command(guild = discord.Object(id=guild), name="license", description="adds a person to use all commands")
    async def license(interaction: discord.Interaction, user: discord.User):
        logger().info(f"{interaction.user} ({interaction.user.id}) ran (license)")
        if not is_admin(interaction.user.id):
            await interaction.response.send_message(embed=no_perms, ephemeral=True)
        elif is_admin(interaction.user.id):
            if not licensed(user.id):
                logger().info(f"{user} ({user.id}) is not licensed, giving his license")
                open(f"users/{user.id}.txt", 'w')
                await interaction.response.send_message(f"Licensed {user.mention}")
            elif licensed(user.id):
                logger().info(f"{user} ({user.id}) is licensed, removed his license")
                os.remove(f"users/{user.id}.txt")
                await interaction.response.send_message(f"Unlicensed {user.mention}")
``` THIS IS THE CODE ```py
this is the error 
[19:39:56](*) Xiniu#9702 (886046838019461120) ran (license)
Ignoring exception in command license:
Traceback (most recent call last):
  File "d:\BOTS\xiniu boost\discord\commands\core.py", line 126, in wrapped
    ret = await coro(arg)
  File "d:\BOTS\xiniu boost\discord\commands\core.py", line 897, in _invoke
    await self.callback(ctx, **kwargs)
  File "d:\BOTS\xiniu boost\main.py", line 110, in license
    if not is_admin(interaction.user.id):
  File "d:\BOTS\xiniu boost\main.py", line 19, in is_admin
    if author in data.admins:
TypeError: argument of type 'int' is not iterable

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

Traceback (most recent call last):
  File "d:\BOTS\xiniu boost\discord\bot.py", line 1082, in invoke_application_command
    await ctx.command.invoke(ctx)
  File "d:\BOTS\xiniu boost\discord\commands\core.py", line 375, in invoke
    await injected(ctx)
  File "d:\BOTS\xiniu boost\discord\commands\core.py", line 134, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: TypeError: argument of type 'int' is not iterable
fading marlin
#
  File "d:\BOTS\xiniu boost\main.py", line 110, in license
    if not is_admin(interaction.user.id):
  File "d:\BOTS\xiniu boost\main.py", line 19, in is_admin
    if author in data.admins:
TypeError: argument of type 'int' is not iterable

this is the part you gotta take a look into

hollow gazelle
#

ok

#

def is_admin(author: int):
if author in data.admins:
return True
else:
return False

def licensed(user):
try:
open(f"users/{user}.txt", "r")
return True
except FileNotFoundError:
return False

#

i those at the top to

potent light
fading marlin
potent light
fading marlin
#

because if you don't add __init__, there's no point in instantiating the subclass because it uses its (the subclass') __init__

#

you just gotta call super().__init__ inside your overrided __init__

potent light
fading marlin
#

correct

potent light
#
class Questionnaire(Modal, title='Questionnaire Response'):
    def __init__(self, test_list: list):
        super.__init__()
        self.test_list = test_list```
#

anything wrong?

fading marlin
#

super**()**

potent light
#

oh my bad

fading marlin
#

apart from that, nothing wrong by the looks of it

tired notch
#
        async def profile(ctx, user: discord.Member = None):
            if not user:
                user = ctx.author``` any way to simplify this just curious
potent light
fading marlin
potent light
#

@fading marlin py raised an error: SyntaxError: invalid syntax (userAnswer.py, line 8) Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000205D77CE560>

tired notch
#

ok thanks

potent light
#
class Questionnaire(Modal, title='Questionnaire Response'):
    def __init__(self, test_list: list):
        super.()__init__()
        self.test_list = test_list```
tired notch
#

why does it work, wouldnt user or ctx.author be a boolean

fading marlin
potent light
fading marlin
potent light
upper lodge
#

is using bot.var the same as using global var?

fading marlin
#

you can use bot.var in a cog. You can't do that with a global var

indigo pilot
#

quick question, any way to get the interactions msg id from an view

fading marlin
#

you can

indigo pilot
#

ah thought i had an error before with that, ill give it a try thanks

fading marlin
#

it can return None though, that might be the reason for the error

scenic cedar
#

How to create a simple discord bot using python

indigo pilot
#

why would it return none?

mighty pilot
#

if i make a view with buttons, and i have it set to disable a button after pushing, replace it withview = self, then they push another button, disable that one and replace with view = self, will the first button still be disabled?

fading marlin
scenic cedar
#

And how can I turn my python into an app

fading marlin
indigo pilot
fading marlin
indigo pilot
#

pingu u good, u been typing for 100 years

scenic cedar
#

@fading marlin bro cannu dm me?

#

I got something for u

fading marlin
#

I rather not, if you have any questions, please ask them here

mighty pilot
#

well that settles it im gonna struggle bus through another button menu lmaoDial i want to have people fill out an application but i cant put 8 values in a modal and i dont think it would feel right with a select menu

fading marlin
indigo pilot
#

or did i miss understood that

mighty pilot
#

discord.ui.modal

indigo pilot
#

guessing so

mighty pilot
#

ooo wait what if i make it send another modal on submit of the first one

indigo pilot
#

so whats ur problem, the max 6 questions thing?

mighty pilot
#

whelp

indigo pilot
#

wont work

mighty pilot
indigo pilot
#

your best bet is to on submit, send a view to open y our next model

indigo pilot
primal token
indigo pilot
#

@mighty pilot if you wanna be lazy

upper lodge
# fading marlin you can use `bot.var` in a cog. You can't do that with a global var

so i have command that copy msg when it's updated and bc off that i need to have
on_message_edit function.
and someone tell me global var is bad if i use them the command will not work if two pers use it at the same time so is self.client.s better?
or is there way to make this in one command?
sorry for the long msg

    async def re(self, ctx):
        if ctx.message.author.id != 757622620349923469:
            return
        if ctx.message.reference is not None:
            self.client.msd_id = ctx.message.reference.message_id
            replay = await ctx.channel.fetch_message(ctx.message.reference.message_id)
            self.client.s = replay.embeds[0].description
...etc
    @commands.Cog.listener()
    async def on_message_edit(self, before, after):
        if before.id != self.client.msd_id:
            return
        replay = after
        self.client.s += f'\n{replay.embeds[0].description}'
indigo pilot
#

make two diff views

#

one with button one enabled and button two disabled

#

once first form submitted, edit to view two

#

viewtwo has button one disabled and button two enabled

mighty pilot
#

well you could do that with one view

indigo pilot
#

when eber im disasbleing a button i just do it with two seprate views since its easier

mighty pilot
#

but i like the idea

indigo pilot
#

i have got it to work once

#

then some guy here told me to do it two diff views and since then ive just done that

fading marlin
mighty pilot
#

i have it working (almost) flawlessly in my main project lol

indigo pilot
#

ah nice

mighty pilot
#

theres one view that i cant disable buttons on timeout, other than that ive got disabling buttons working great

unkempt canyonBOT
fading marlin
#

welp

upper lodge
indigo pilot
#

its an easy fix if you notice, or just write the line yourself but ive ran into this 100 times without noticeing then having to go back to views and swapping it

fading marlin
mossy jacinth
#

somebody help me with this again.. happens everytime i reinstall my pc and i always forget how to fix it

fading marlin
indigo pilot
#

rip, thanks tho

fading marlin
vestal heath
#

who could help me to make a login system in a python program but the user and pass are hosted on rentry.co or other?

mossy jacinth
fading marlin
fading marlin
#

it's probably somewhere on google

upper lodge
fading marlin
#

sure, but again, it'd be better if you used a list instead of a string

#

anyway, it's lights off for me now, see y'all

upper lodge
#

ty for the help

indigo pilot
#

one moreq uestion, ive had issues with this for AGES but been to lazy to ask

say i want to do interaction.response.edit_message(view=None)
and interaction.response.send_message(),
it wont work and will say its already been responsed too, is there ANY way around this?

mossy jacinth
#

same thing happened when i wanted to install discord so i thought nextcord would work

indigo pilot
#

super annoying

upper lodge
#

3.11 ?

mossy jacinth
#

yes

upper lodge
#

try 3.10.8

hollow zealot
#

is the new version of dpy much better than the old?

alpine cove
#

1.7 and. 2.0?

hollow zealot
#

yes

#

what's more easier

alpine cove
# hollow zealot yes

well 1.7 doesnt support slash commands, context menus, modals and all the fancy ui stuff

alpine cove
hollow zealot
#

okie

#

but what's more easier?

alpine cove
#

maybe some tiny little changes but thats it

#

just go with 2.0

hollow gazelle
#

who can help

#

@app_commands.command(description='Bans a member')
@app_commands.describe(member='the member to ban') ive tried this and it didnt work

alpine cove
mossy jacinth
#

Why cant I load a cog? Used to do it like that

hollow gazelle
alpine cove
unkempt canyonBOT
#

asyncio.run(coro, *, debug=None)```
Execute the [coroutine](https://docs.python.org/3/glossary.html#term-coroutine) *coro* and return the result.

This function runs the passed coroutine, taking care of managing the asyncio event loop, *finalizing asynchronous generators*, and closing the threadpool.

This function cannot be called when another asyncio event loop is running in the same thread.

If *debug* is `True`, the event loop will be run in debug mode. `False` disables debug mode explicitly. `None` is used to respect the global [Debug Mode](https://docs.python.org/3/library/asyncio-dev.html#asyncio-debug-mode) settings.

This function always creates a new event loop and closes it at the end. It should be used as a main entry point for asyncio programs, and should ideally only be called once.

Example...
alpine cove
#

thats a thing most forks include like pycord

hollow gazelle
#

i just swtiched from pycord

alpine cove
#

check the examples

hollow gazelle
#

its being black

alpine cove
hollow gazelle
alpine cove
#

*tbh

alpine cove
hollow gazelle
alpine cove
alpine cove
alpine cove
hollow gazelle
#

is that why its messing up

alpine cove
#

I have no idea what ur talking anout?

#

*about

#

just look at the app cmds examples

mossy jacinth
#

can someone tell me how i can stop it from trying to message itself?

#

or why the except is being ignored?

slate swan
#

its not a commandinvokerror its an HTTPException

#

why would your except catch it

mighty pilot
slate swan
unkempt canyonBOT
#

exception nextcord.HTTPException(response, message)```
Exception that’s raised when an HTTP request operation fails.
mossy jacinth
#

oh

#

my bad

indigo pilot
#

or just pass in the answers from the model one to the buttons then from that to model two

#

and from model two murge them togherher

mighty pilot
#

I was trying to avoid a db with this bot 😂 how would I pass the answers around like that?

indigo pilot
#

and why, just use sqlite, shit but works good for simple things like this

mighty pilot
#

I have a whole mariadb running on my server, that's not my issue. Just preference in which bots are doing what

indigo pilot
#

yeah im just sayin gits eay to just do sqlite for simple things like this

#

it saves alot of work since its just a local file

#

another way you could do it

#

is updating the message to the answers provided in model 1

#

then accessing the message and getting the answers in model 2

#

hell but works, passing in a var that holds the answers is better tho

mighty pilot
#

Hmmm alright. I'll have to mess with it a bit tomorrow. Thanks for the insight!

indigo pilot
#

np

upper lodge
primal token
#

Hey everyone, i need some suggestions on the new project i'm working on ( https://github.com/ilynoid/Intercord ), mostly in the codebase since i havent done documentation yet, i would love for feedback and overall finding any issue(s) in the codebase as i havent really done a project in a while, i was also thinking about using MKdocs for the themes, but are they any other advantages i.e simplicity?

GitHub

Contribute to ilynoid/Intercord development by creating an account on GitHub.

#

Also i would love suggestions on the README😭

torn sail
primal token
unkempt canyonBOT
#

intercord/client.py line 29

channel = await self.fetch_channel(self.channel_id)```
primal token
#

Because i doubt the channel would be in cache if the library hasnt done any operations on the channel since you just started the bot

upbeat gust
upbeat gust
primal token
upbeat gust
#

It doesn't show what your client even does

primal token
torn sail
primal token
upbeat gust
#

And also no subclass for commands.Bot?

primal token
upbeat gust
#

I have no idea where that is in the source

#

Why do you need it

primal token
primal token
primal token
#

?

upbeat gust
#

how does this have anything to do with cogs

primal token
#

It can use cogs?

#

Since i would implement cogs i would need the commands ext, no?

upbeat gust
#

I'm saying you only have a client subclass and not one for bot

#

so people using bot can't use this

primal token
#

Because i havent implemented commands yet?

hushed galleon
# primal token Can you refer me to the code where this action happens?

once the gateway sends your bot the READY event, it'll follow up with several GUILD_CREATE payloads containing the full data with channels (assuming the guilds intent is enabled), and discord.py will wait (by default) 2 seconds to receive them before dispatching the on_ready event
discord docs: https://discord.com/developers/docs/topics/gateway#tracking-state
method delaying on_ready: https://github.com/Rapptz/discord.py/blob/v2.1.0/discord/state.py#L533

unkempt canyonBOT
#

discord/state.py line 533

async def _delay_ready(self) -> None:```
hushed galleon
#

(i was about to answer earlier but windows 11 decided to hardlock my computer, apparently for a windows update but system logs says nothing happened for the last hour)

primal token
#

🦦

shrewd apex
hushed galleon
# hushed galleon once the gateway sends your bot the READY event, it'll follow up with several GU...

you can also see for yourself by enabling debug events and printing out the payload types received: ```py
class Client(discord.Client):
async def on_socket_raw_receive(self, msg: str):
payload = json.loads(msg)
print('received', payload['t'])

async def on_ready(self):
    print('on_ready called')
    await self.close()

client = Client(intents=discord.Intents(guilds=True), enable_debug_events=True)
client.run(...)```

ocean dragon
#

I'm taking discord id as parameter, but it's too large to be an int, how can I do this without having to check whether it's a valid number?

async def ping(self, interaction: discord.Interaction, discord_id:int)
#

I dont want to use pycord's own type for discord id, because I have another large number i need to handle

upbeat gust
#

why take id

#

For other large numbers all you can do is use str

ocean dragon
upbeat gust
#

I have no idea what that even is

#

Funny pycord

ocean dragon
#

nvm there isnt a datatype for it

ocean dragon
#

well excuse me for wanting a cleaner solution, this just doesn't make much sense to me, because a discordid is a valid integer

shrewd apex
ocean dragon
#

but python can handle larger ones

#

couldn't I use an unsigned integer or something?

shrewd apex
#

what u need id for?

ocean dragon
#

I stole information about user in database, the id is the identifier

shrewd apex
#

so why not just type hint discord.Member

ocean dragon
#

Well, I have another ID as a possible parameter that is like discordid

ocean dragon
#

how do I set a default Choice[int] parameter? it doesn't accept a Choice object as default

glad cradle
#

name_param: int = 0 should work

glad cradle
ocean dragon
#

I had an integer as default but then I need to check if the parameter is Choice or int

glad cradle
#

ahh

#

so the param is a choice and you want to assign a default value?

ocean dragon
#

yeah

glad cradle
#

Well idk how to do it in pycord

#

sry

ocean dragon
glad cradle
#

@ocean dragon are u using discord.Option with choices?

ocean dragon
#

no

#
@app_commands.choices(c=[
    app_commands.Choice(name="choice1", value=0),
    app_commands.Choice(name="choice1", value=1)
])
async def ping(self, interaction: discord.Interaction, c: app_commands.Choice[int] = 1):
    ... 
glad cradle
#

ok, lemme check the docs

ocean dragon
glad cradle
#

try this:

async def ping(self, interaction: discord.Interaction, c: typing.Litera["choice", "choice2"] = "choice"):
    ... 
ocean dragon
#

works but then there is no integer, but ig I can convert it

glad cradle
#

typing.Literal can accepts intger

ocean dragon
#

yeah but I need int - str pair

glad cradle
#

converting to int is the most efficient way to get ids from slash commands

shrewd apex
ocean dragon
#

nah this is different from id, this is for an api call

#
@app_commands.choices(endpoint_id=[
    app_commands.Choice(name="Endpoint 1", value=0),
    app_commands.Choice(name="Endpoint 2", value=1)
])
async def ping(self, interaction: discord.Interaction, endpoint_id: app_commands.Choice[int] = 1):
    await post(url, data={"endpoint": endpoint_id})
#

so I'd rather want an integer identifier than to use a string

#

I could inherit Choice and make __int__ method return .value 🤔

#

nvm I get unsupported type annotation

slate swan
unkempt canyonBOT
#

examples/app_commands/transformers.py lines 97 to 108

class Fruits(Enum):
    apple = 0
    banana = 1
    cherry = 2
    dragonfruit = 3


@client.tree.command()
@app_commands.describe(fruit='The fruit to choose')
async def fruit(interaction: discord.Interaction, fruit: Fruits):
    """Choose a fruit!"""
    await interaction.response.send_message(repr(fruit))```
slate swan
#

@ocean dragon ^

finite cosmos
#

Good Morning.
Anyone one have experience with discord bot with an GUI like pyside?
I can run the bot, normaly with a button.
But i will start some Music with the GUI

@asyncSlot()
    async def play(self):
        await self.bot.play()
# IN THE BOT CLASS I HAVE A FUNCTION:
async def play(ctx, member: discord.Member):
        guild = ctx.guild
        voice_client: discord.VoiceClient = discord.utils.get(bot.voice_clients,           guild=guild)
        audio_source = discord.FFmpegPCMAudio(executable="G:/FFmpeg/bin/ffmpeg.exe", source='test.mp3')
        if not voice_client.is_playing():
            voice_client.play(audio_source, after=None)

#

but i have the problem, ctx and member dont know the member^^

slate swan
#

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

finite cosmos
#

uh? I dont wanna play music here. Its for an RolePlay server to play OWN created music oO

finite cosmos
#

@naive briar With the GUI in the background dont how to tell the bot to play music. Without a channel command

upbeat gust
finite cosmos
#

voice_client: discord.VoiceClient = discord.utils.get(bot.voice_clients, guild=guild)
or
Bot.fetch_channel(id) ?

upbeat gust
finite cosmos
#

ya tha problem is he dont get it.
First bot.voice_clients will not work proberly because the pyside. Then he tells me he dont know what guild is

#

if i run it without GUI it work

slate swan
unkempt canyonBOT
#

property voice_client```
Returns the [`VoiceProtocol`](https://discordpy.readthedocs.io/en/latest/api.html#discord.VoiceProtocol "discord.VoiceProtocol") associated with this guild, if any.
finite cosmos
#

the same with get channel? ctx.guild.get_channel?

finite cosmos
#

@slate swan yeh i hope, the bot is not that problem, but to combine it with a GUI -.-

finite cosmos
#

@slate swan
AttributeError: 'Guild' object has no attribute 'voice_clients'
with:
voice_client: discord.VoiceClient = discord.utils.get(ctx.guild.voice_clients, guild=guild)
ctx.voice_clients didnt work too

upbeat gust
#

how would you have ctx if you executed this from a gui

finite cosmos
#

@upbeat gust atm is the problem only at the voice channel.
AttributeError: 'Guild' object has no attribute 'voice_clients'
with:
voice_client: discord.VoiceClient = discord.utils.get(ctx.guild.voice_clients, guild=guild)
ctx.voice_clients didnt work too

#

if you use the normal way its:
voice_client: discord.VoiceClient = discord.utils.get(bot.voice_clients, guild=guild)
That work. But if you dont can use BOT because you go over an GUI it dont work.

upbeat gust
#

how do you have ctx here

#

wtf is going on

finite cosmos
#
        @self.command(pass_context=True)
        async def play(ctx):
            guild = ctx.guild
            #voice_client: discord.VoiceClient = discord.utils.get(bot.voice_clients, guild=guild)
            voice_client: discord.VoiceClient = discord.utils.get(ctx.voice_clients, guild=guild)

            audio_source = discord.FFmpegPCMAudio(executable="G:/FFmpeg/bin/ffmpeg.exe", source='test.mp3')
            if not voice_client.is_playing():
                voice_client.play(audio_source, after=None)
upbeat gust
#

@self.command ??

#

you cant have commands inside the bot subclass

#

youre missing self from the command params anyway

slate swan
upbeat gust
#

this whole thing is a mess

slate swan
#

and again you used discord.utils.get, is this some stackoverflowed or tutorial code?

finite cosmos
#

@upbeat gust thanks, but yes SELF.COMMAND works. (all my other commands works)
@slate swan Its a tutorial Code. But with bot. (it works but not with ctx)

upbeat gust
slate swan
#

loooli commands inside the init?

#

or declaring bot as self

scenic cedar
#

!d discord button

unkempt canyonBOT
#

In order to work with the library and the Discord API in general, we must first create a Discord Bot account.

Creating a Bot account is a pretty straightforward process.

slate swan
#

dont spam here, #bot-commands

finite cosmos
#

@slate swan yes commands inside the init

slate swan
#

hell

finite cosmos
#

without it, its nearly impossible to get it work in a GUI

slate swan
#

a gui with discord bot makes no sense, that would either be blocking or will have loopholes

finite cosmos
#

Ok i think here are only simps, people with IQ -100 and cant answer in a correct answer. Then such rets as @upbeat gust that cant answer and only shit on, but hey mb u can help.
And fk yes, a GUI Discord Bot makes sense, i depends on that what you would achive. But if yeah the first rule is, it make no sense in you mind it makes no sense in the world. fk off this python server sucks as hell

upbeat gust
#

lmao

slate swan
#

thi you're the one watching a 4 year old outdated tutorial, how can you assume IQs of people here?

And fk yes, a GUI Discord Bot makes sense
sorry to break it to you but not with blocking IO, your bot will get jammed waiting for a response from the GUI and will eventually break websocket connections from discord. if you still think that it's possible please carry on, noone decides on what you do

upbeat gust
#

half of this guy's message isnt even comprehensible

slate swan
#

it would be more funny if you;re referring a discord message with buttons as a GUI

split forge
#

Hello there! If anyone knows how to do Slash commands, can you tag me? I need to ask a question.

slate swan
split forge
vale wing
#

He could actually just integrate API into bot and make requests from the GUI app

slate swan
#

as i said, with blocking IO

slate swan
#

you can also hide the slash command from dm channels

upbeat gust
#

!d discord.app_commands.guild_only

unkempt canyonBOT
#

@discord.app_commands.guild_only(func=None)```
A decorator that indicates this command can only be used in a guild context.

This is **not** implemented as a [`check()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.check "discord.app_commands.check"), and is instead verified by Discord server side. Therefore, there is no error handler called when a command is used within a private message.

This decorator can be called with or without parentheses.

Due to a Discord limitation, this decorator does nothing in subcommands and is ignored.

Examples...
split forge
upbeat gust
slate swan
#

chrispy just told

split forge
#

Thanks

upbeat gust
#

never knew it would hide it i always thought i was a check like the ext.commands version, interesting

slate swan
upbeat gust
#

yeah, still more ipc than api tho lol

slate swan
#

i still don't the use of GUI for a sound bot like what you gonna do, open an app and ask it to play something on discord
why not just make a on_message command or an interaction lol

upbeat gust
#

yeah exactly

split forge
upbeat gust
#

rhythm's webapp was pretty cool though

upbeat gust
split forge
#

okau

#

so if i do it like this will it work?

#
tree = app_commands.CommandTree(client)

@app_commands.command()
@app_commands.guild_only()
async def my_guild_only_command(interaction: discord.Interaction) -> None:
    await interaction.response.send_message('I am only available in guilds!')

@tree.command(name = ```
#

@slate swan

slate swan
#

yep

#

the command decorator should be @uncut zenith.command tho

#

sorry for the ping, blame your username

split forge
# slate swan yep

Now if I write /hello to your bot's dm, it won't reply to me, right?

slate swan
split forge
#

okay

split forge
#

is it true?

upbeat gust
#

Yes

#

similar to the last line you posted

split forge
#

its not working lmafo :P

upbeat gust
#

elaborate

split forge
#

Can ı send code?

upbeat gust
#

we cant read your mind, wdym not working

upbeat gust
split forge
#
@app_commands.guild_only()
async def my_guild_only_command(interaction: discord.Interaction) -> None:
    await interaction.response.send_message('I am only available in guilds!')

@tree.command(name = 'test', description='it test command')
async def test(interaction: discord.Interaction,test: int):
    await interaction.response.send_message("its test !")```
#

why? @slate swan (sorry for ping)

slate swan
#

bro @tree.command

split forge
#

@strange knoll_commnds.command()?

upbeat gust
#

the same as everything else youre doing

split forge
#

wa

#
@app_commands.guild_only(name = 'test', description='it test command')```
#

right? @upbeat gust

upbeat gust
#

???

#

guild_only is a seperate decorator

#

you still need the command decorator

upbeat gust
# split forge wa

its the same as your other commands, just add the extra guild_only deco

split forge
#

Could you please send it to me as attached?

#

I did not understand anything

#

bc

upbeat gust
#

just do the same as your other commands.

split forge
#

Could you please send it to me as attached? pls

upbeat gust
#

no im not gonna write code for you

split forge
#

this is true?

upbeat gust
#

forget about the guild_only

#

just do that first

split forge
upbeat gust
#

WHY

split forge
#

@strange knoll_commands.guild_only(name = 'test', description='it test command')
async def test(interaction: discord.Interaction,test: int) -> None:
await interaction.response.send_message('I am only available in guilds!')
await interaction.response.send_message("its test bro!")

#

is it true??????

upbeat gust
#

CAN YOU JUST DO THE SAME AS YOUR OTHER COMMANDS FIRST

upbeat gust
upbeat gust
split forge
#

wait

split forge
#

how I can do it another commands

upbeat gust
#

lol im out bye

split forge
#

PLEASE

#

@upbeat gust plsssssssss

upbeat gust
#

weve told you exactly what to do, im not wasting any more time on you

naive briar
#

lmao

split forge
#

I don't quite understand what I will do if you give an example

#

i am turkish and i use translation

split forge
#

@upbeat gust pleaseeeeeee

split forge
#

@discord.app_commands.guild_only()

#

right @upbeat gust ?

upbeat gust
#

STOP PINGING ME

split forge
#

sory

upbeat gust
#

ykw, block

split forge
slate swan
#

you have been told like 10 times, use tree.command instead of app_commands.command

#

how does one simplify it

slate swan
#

noones dumb, pay attention while reading

split forge
#

ys

slate swan
#

Does anyone know I can change this so my bot only sends the ids I send to my bot I’m stuck on it

shrewd apex
slate swan
# upbeat gust ..what?

I want to send my bot another users id and then I want my bot copy the id I sent and send it back into chat so how can I do that using the code above

upbeat gust
#

why though

shrewd apex
upbeat gust
#

I'm more confused why you'd even want this

slate swan
#

I js need to do it

shrewd apex
upbeat gust
slate swan
#

Ok let me try that

shrewd apex
#

i have a bad feeling now

slate swan
shrewd apex
#

use on_message event or a modal

slate swan
# upbeat gust 🤨

What I’m trying to do can’t be a command I js wanna send a id and for my to send the id back

upbeat gust
#

Sounds sus

slate swan
shrewd apex
#

!d discord.ext.commands.Bot.wait_for

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.11)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.11)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.11)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
shrewd apex
#

no need to format seperately

#

bro u just need it to repeat ids why u want formatting and all more sus

slate swan
#

How do I use the on message to only send the id I send to the bot back once

shrewd apex
slate swan
#

😅

shrewd apex
#

i am hungry i am gonna go grab a snack chrispy gonna help u

upbeat gust
#

yeah no thanks im gonna grab a snack too

#

whats ur snack

shrewd apex
upbeat gust
#

yum

slate swan
#

I just want to see send my bot a discord id and for my bot to send that discord id back but I only want it to send the id back once and not spam it lots of times

primal token
slate swan
#

Damn everyone left me 💀

slate swan
#

@shrewd apex @upbeat gust so I got this monstrosity

upbeat gust
#

That's a property of a class

#

are you looking for message.content??

slate swan
#

Idk just experimenting ig

slate swan
upbeat gust
#

Soo.. The message's content

slate swan
#

Yeah

loud junco
#

how to import asyncpg with pip

#

-pip install what

upbeat gust
#

literally asyncpg

loud junco
#

ok

loud junco
#

do i just do this

primal token
loud junco
#

should i update it

primal token
#

Make a gitignore and write the name of the file!

loud junco
#

how do i make a gitignore ;-;

vale wing
loud junco
#

ok

vale wing
loud junco
#

ok

primal token
#

it has support for it

slate swan
#

^ ctrl+shift+p >add to .gitignore

loud junco
#

ok

slate swan
upbeat gust
upbeat gust
loud junco
charred radish
#
eman = interaction.user.guild.get_role(1042001023084011573)
        await interaction.user.add_roles(eman)
``` no erros
#

role is not added

#

bots role is above the member and above the role which is supposed to be added

#

and i got code to send an embed after adding role

#

the embed is sent

vale wing
#

Print eman

slate swan
primal token
# upbeat gust Why are ur questions so easily googleable

You can google almost everything now that still doesnt mean the user would understand, in this case it would be easy but this server is for helping each other so why not help him with such an easy task if it's "googleable"

upbeat gust
vale wing
#

Teaching to learn to google is help too imo 🤗

primal token
#

What extra info does a gitignore have that you cant explain?

loud junco
#

💀

paper sluice
#

its not a command

#

its a file

vale wing
#

Gitignore is so easy

loud junco
#

:/ everyone has their first time u see

vale wing
#

You just list relative paths of files you don't wanna have in repo

paper sluice
#

make a file named .gitignore and add the files/folders you want git to ignore

vale wing
#

Each path on separate line

vale wing
#

And there's some additional stuff like regex and ! but you don't really need it

loud junco
#

like this?

vale wing
#

It's not a folder

paper sluice
#

file not folder

primal token
#

a file, not a folder!

loud junco
#

rename it to secrets.gitignore?

primal token
#

no, no, a file named .gitignore :p

paper sluice
slate swan
#
@bot.event
async def on_ready():
    print(f"{bot.user.name} is online!")
    await bot.change_presence(status=nextcord.Status.idle, activity=nextcord.Activity(type=nextcord.ActivityType.watching, name="Prefix !"))
    async with aiosqlite.connect("main.db") as db:
        async with db.cursor() as cursor:
            await cursor.execute('CREATE TABLE IF NOT EXISTS role (role_id INTEGER , guild INTEGER)')
        await db.commit()


@bot.command()
async def set_staff(ctx):
    async with aiosqlite.connect("main.db") as db:
        async with db.cursor() as cursor:   
            await cursor.execute('SELECT role_id FROM role WHERE guild = ?', (ctx.guild.id,))
            data = await cursor.fetchone()
            if data:
                await cursor.execute('UPDATE role SET role_id = ? WHERE guild = ?', (ctx.guild.get_role, ctx.guild.id,))
            else:
                await cursor.execute('INSERT INTO role (role_id, guild) VALUES (?, ?)', (ctx.guild.get_role, ctx.guild.id,))
        await db.commit()```

nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: InterfaceError: Error binding parameter 0 - probably unsupported type.```

loud junco
paper sluice
#

make a file named .gitignore, open the file and type secrets.env

paper sluice
slate swan
#

How can I make my bot send the id of a discord user that I send to the bot back into chat

primal token
loud junco
paper sluice
loud junco
#

ye

primal token
#

no, you use an env file for that, a gitignore file is a file which you provide directories so github ignores all those files when committing to the repo

slate swan
#
@bot.event
async def on_ready():
    print(f"{bot.user.name} is online!")
    await bot.change_presence(status=nextcord.Status.idle, activity=nextcord.Activity(type=nextcord.ActivityType.watching, name="Prefix !"))
    async with aiosqlite.connect("main.db") as db:
        async with db.cursor() as cursor:
            await cursor.execute('CREATE TABLE IF NOT EXISTS role (role_id INTEGER , guild INTEGER)')
        await db.commit()


@bot.command()
async def set_staff(ctx):
    async with aiosqlite.connect("main.db") as db:
        async with db.cursor() as cursor:   
            await cursor.execute('SELECT role_id FROM role WHERE guild = ?', (ctx.guild.id,))
            data = await cursor.fetchone()
            if data:
                await cursor.execute('UPDATE role SET role_id = ? WHERE guild = ?', (ctx.guild.get_role, ctx.guild.id,))
            else:
                await cursor.execute('INSERT INTO role (role_id, guild) VALUES (?, ?)', (ctx.guild.get_role, ctx.guild.id,))
        await db.commit()```

nextcord.ext.commands.errors.CommandInvokeError: Command raised an exception: InterfaceError: Error binding parameter 0 - probably unsupported type.```

#

im trying to make a command that sets the staff role

#

and it needs to keep in db

primal token
#

e.g

#  .gitignore
secrets.env
#

the comment is just the name of the file

loud junco
primal token
upbeat gust
primal token
#

Good things come with time, no?

vale wing
charred radish
slate swan
#

🦆 i just export KEY=VALUE in my zshrc

vale wing
paper sluice
#

bruh

loud junco
vale wing
charred radish
#
eman = interaction.user.guild.get_role(1042001023084011573) ```after this
vale wing
#

Ok well do you have error handlers

paper sluice
# loud junco '

right click on secrets.env and then click on add to .gitignore

charred radish
#

no....

ocean dragon
slate swan
# loud junco '

you didn't create a gitignore else it would have showed up there too

vale wing
ocean dragon
#

paginator yes

#

I have a large list of strings I need to display and paginate, because it exceeds 2000 characters

slate swan
#

you'll have to make one urself
its easy

upbeat gust
ocean dragon
#

does that work for 2.0 though

slate swan
#

How can I make my bot send the id of a discord user that I send to the bot back into chat

upbeat gust
#

here we go again

#

I already told you what was wrong

slate swan
charred radish
vale wing
#

This will find possible error handlers

#

Cause I've seen many people having error handler in code and not even knowing that they do

upbeat gust
charred radish
slate swan
upbeat gust
#

as you did before

slate swan
upbeat gust
agile oak
#

hello

#

i typed this code

#

import os

these modules are for querying the Hugging Face model

import json
import requests

the Discord Python API

import discord

this is my Hugging Face profile link

API_URL = 'https://api-inference.huggingface.co/models/Tony8657/'

class MyClient(discord.Client):
def init(self, model_name):
super(intents).init()
self.api_endpoint = API_URL + model_name
# retrieve the secret API token from the system environment
huggingface_token = os.environ['HUGGINGFACE_TOKEN']
# format the header in our request to Hugging Face
self.request_headers = {
'Authorization': 'Bearer {}'.format(huggingface_token)
}

def query(self, payload):
    """
    make request to the Hugging Face model API
    """
    data = json.dumps(payload)
    response = requests.request('POST',
                                self.api_endpoint,
                                headers=self.request_headers,
                                data=data)
    ret = json.loads(response.content.decode('utf-8'))
    return ret
#

async def on_ready(self):
# print out information when the bot wakes up
print('Logged in as')
print(self.user.name)
print(self.user.id)
print('------')
# send a request to the model without caring about the response
# just so that the model wakes up and starts loading
self.query({'inputs': {'text': 'Hello!'}})

async def on_message(self, message):
    """
    this function is called whenever the bot sees a message in a channel
    """
    # ignore the message if it comes from the bot itself
    if message.author.id == self.user.id:
        return

    # form query payload with the content of the message
    payload = {'inputs': {'text': message.content}}

    # while the bot is waiting on a response from the model
    # set the its status as typing for user-friendliness
    async with message.channel.typing():
      response = self.query(payload)
    bot_response = response.get('generated_text', None)
    
    # we may get ill-formed response if the model hasn't fully loaded
    # or has timed out
    if not bot_response:
        if 'error' in response:
            bot_response = '`Error: {}`'.format(response['error'])
        else:
            bot_response = 'Hmm... something is not right.'

    # send the model's response to the Discord channel
    await message.channel.send(bot_response)

def main():
# DialoGPT-medium-joshua is my model name
client = MyClient('DialoGPT-small-TonyStarkBot')

keep_alive()
client.run(os.environ['DISCORD_TOKEN'])

if name == 'main':
main()

#

in replit

#

but it is giving this error

charred radish
#

code block

ocean dragon
upbeat gust
#

!paste

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.

solar basin
#

I would like to append dataframe to CSV file present in Aws S3, using AWS lambda, can anyone help me regarding this. #python

upbeat gust
#

this isnt related to discord

solar basin
#

I would like to append dataframe to CSV file present in Aws S3, using AWS lambda, can anyone help me regarding this. #python

upbeat gust
slate swan
# upbeat gust .

@upbeat gust Alr it works now but how do I make the bot only respond to me instead of itself

upbeat gust
#

oh no way youre posting in every chanenl

slate swan
upbeat gust
agile oak
slate swan
agile oak
#

replit giving error : Traceback (most recent call last):
File "main.py", line 82, in <module>
main()
File "main.py", line 76, in main
client = MyClient('DialoGPT-small-TonyStarkBot')
File "main.py", line 15, in init
super().init()
TypeError: init() missing 1 required keyword-only argument: 'intents'

#

what should i do

charred radish
charred radish
#

didnt find any handlers tho

upbeat gust
charred radish
#

prints the exact role i want to add

#

reset your token

ocean dragon
#

bruh

primal token
#

Do you have an env ext for vsc?

upbeat gust
#

why would it be coloured?

agile oak
#

where do i use intents if i want to use the same code

charred radish
#

what....

upbeat gust
#

isnumeric and channel

solar basin
#

I would like to append dataframe to CSV file present in Aws S3, using AWS lambda, can anyone help me regarding this. #python

upbeat gust
upbeat gust
#

its not even related to this channel

agile oak
#

can you send me the changes in the code on the file i sent

loud junco
upbeat gust
#

thats python

loud junco
#

this is in normal .py file

upbeat gust
#

and this isnt a py file

loud junco
ocean dragon
#

no, it's visual studio code coloring the text to make it easier to read

#

if u open same file in notepad it's just text

upbeat gust
upbeat gust
#

theres like
no syntax

upbeat gust
primal token
loud junco
#

so if i from secrets import * and do secrets.token will it be the 'MTAzNzY...'

primal token
#

How else would env files be parsed with "no syntax"?

charred radish
upbeat gust
#

what would even be highlited

#

doesnt matter

primal token
#

The variable names, i'm pretty sure vsc even has env support

charred radish
#

white mode + plain text

upbeat gust
slate swan
primal token
upbeat gust
#

docs for what

agile oak
loud junco
#

so the only way is to make a python file and make it .gitignore?

upbeat gust
loud junco
#

am i right?

upbeat gust
upbeat gust
primal token
agile oak
#

so i have to add intents in 15

slate swan
loud junco
#

??????????

upbeat gust
primal token
#

An env file is used for having credentials, some host use it to hide credentials, while a module would be a python file there's a different

upbeat gust
#

its just message.author == client.user

loud junco
#

forget it im just gonna make a python file and .gitignore it

agile oak
#

bro just send please!!!!!

upbeat gust
agile oak
upbeat gust
primal token
agile oak
#

i dont its got messy now

loud junco
loud junco
upbeat gust
#

just pass intents to the intents kwarg of client.__init__, where youre calling super init

timid spade
#

is this code right? eh

upbeat gust
#

depends what library ur using

timid spade
alpine cove
alpine cove
agile oak
#

still dont get it

timid spade
#

uh
so for what should i use for slash commands in discord.py?

alpine cove
#

tree being you (application) command tree

#

application command = slash command btw

loud junco
#

what local commit is waiting

timid spade
# alpine cove pycord?

i am learning from a youtube channel and in the mid of series he shifted to nextcord
now i am confused af

loud junco
#

💀 let me guess

upbeat gust
#

dont watch yt tutorials then

#

look at official guides, and the ones posted by dpy people

loud junco
#

is it autocode or freecodecamp

#

:D

upbeat gust
primal token
alpine cove
#

most tutorials are less then mediocre

loud junco
timid spade
alpine cove
#

not discord bot related

agile oak
loud junco
#

can u even import discord in railway.app 💀

loud junco
slate swan
agile oak
#

@upbeat gust please help bro

loud junco
alpine cove
#

r u using virtual envs?

loud junco
#

im using vsc

alpine cove
loud junco
alpine cove
agile oak
slate swan
#

How do I stop my bot from sending messages to its own messages

agile oak
#

where do i need to put intents

loud junco
#

am i illiterate or something

alpine cove
alpine cove
#

yea

loud junco
slate swan
alpine cove
# loud junco

dope now put this at the top of your code:
import sys
print(sys.version)

#

and tell me what is getting print to the console

alpine cove
#

yea

loud junco
agile oak
#

@wintry cape just help me

alpine cove
loud junco
#

sad anyone noises

alpine cove
agile oak
#

bro i need help

flint belfry
#

No@agile oak

#

Just say the Problem already

alpine cove
agile oak
#

i told it above

loud junco
alpine cove
alpine cove
loud junco
#

this is all the log is showing 💀

flint belfry
#

!intents @agile oak

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. Various features of discord.py rely on having particular intents enabled, further detailed in its documentation. Since discord.py v2.0.0, it has become mandatory for developers to explicitly define the values of these intents in their code.

There are standard and privileged intents. To use privileged intents like Presences, Server Members, and Message Content, you have to first enable them in the Discord Developer Portal. In there, go to the Bot page of your application, scroll down to the Privileged Gateway Intents section, and enable the privileged intents that you need. Standard intents can be used without any changes in the developer portal.

Afterwards in your code, you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

# Enable all standard intents and message content
# (prefix commands generally require message content)
intents = Intents.default()
intents.message_content = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see discord.py's related guide, and for general information about them, see the Discord developer documentation on intents.

alpine cove
#

*odd
save ur file

loud junco
#

lemme retr

#

gg keboard moment

agile oak
#

i dont get it

loud junco
agile oak
#

soryy

#

help

slate swan
#

its the railway host right

loud junco
#

yeye

loud junco
#

i think the only time i saw this is in my minecraft world folder 💀

#

it doesnt work this way?

naive briar
#

Do you know how importing works

loud junco
#

but i used to import it through some way that i forgotted

#

cuz the last time i did the thing is like 10 months ago

flint knoll
#

what is a good library for twitter api?

#

(for discord bots)

naive briar
#

It's just basic python

flint knoll
#

is there a library to make it easier?

loud junco
flint knoll
naive briar
#

What is that

naive briar
unkempt canyonBOT
#

@naive briar :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 2, in <module>
003 | NameError: name 'math' is not defined
naive briar
#

Can you spot what's wrong

slate swan
alpine cove
#

lmao

alpine cove
slate swan
loud junco
unkempt canyonBOT
#

@loud junco :white_check_mark: Your 3.11 eval job has completed with return code 0.

256.0
loud junco
#

i see

alpine cove
#

?

loud junco
slate swan
#

which word out of those 7 did you not understand

loud junco
slate swan
#

no you enter all libraries that you pip installed for your project there

unkempt canyonBOT
#

@stuck hearth :x: Your 3.11 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "<string>", line 1, in <module>
003 | ModuleNotFoundError: No module named 'requests'
slate swan
#
discord.py
pillow
pynacl
``` for example
naive briar
#

Use #bot-commands for the love of God

slate swan
#

please take it to #bot-commands this is not a spam channel

loud junco
#

but i mean #bot-commands is going to be a better place

slate swan
#

while True is technically a spam Kannakillyourself

loud junco
#

no one will be there

loud junco
#

btw @slate swan

#

ignore the bot = blahblah first

#

@slate swan?

#

but why is it an hour ago

lucid latch
#

how can i make bot to connect certain voice channel?

loud junco
#

oo i need to push it to origin💀

alpine cove
#

!d discord.VoiceChannel

unkempt canyonBOT
#

class discord.VoiceChannel```
Represents a Discord guild voice channel.

x == y Checks if two channels are equal.

x != y Checks if two channels are not equal.

hash(x) Returns the channel’s hash.

str(x) Returns the channel’s name.
alpine cove
#

!d discord.VoiceChannel.connect

unkempt canyonBOT
#

await connect(*, timeout=60.0, reconnect=True, cls=<class 'discord.voice_client.VoiceClient'>, self_deaf=False, self_mute=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Connects to voice and creates a [`VoiceClient`](https://discordpy.readthedocs.io/en/latest/api.html#discord.VoiceClient "discord.VoiceClient") to establish your connection to the voice server.

This requires [`voice_states`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.voice_states "discord.Intents.voice_states").
loud junco
#

u know about requirement.txt?

alpine cove
#

all ur requirements

loud junco
#

alr we have some progress

alpine cove
loud junco
#

its line 2 now

#

alright forget it

#

its the same error

#

0 progress after 1 hour

loud junco
alpine cove
#

yea

loud junco
#

:D

loud junco
unkempt canyonBOT
#
Missing required argument

code

alpine cove
loud junco
#

huh

#

i dont feel good about this

alpine cove
#

its:

import pip
pip.main(["install", "discord.py"])
#

this will work as long as pip is installed

loud junco
#

at where

#

main?

alpine cove
#

yep

loud junco
#

btw gtg

alpine cove
#

insert that at the top

alpine cove
slate swan
split forge
#

I couldn't lmafo

naive briar
#

!d discord.ext.commands.Bot.add_view

unkempt canyonBOT
#

add_view(view, *, message_id=None)```
Registers a [`View`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View "discord.ui.View") for persistent listening.

This method should be used for when a view is comprised of components that last longer than the lifecycle of the program.

New in version 2.0.
alpine cove
#

does that actually work?

#

like does it continue listening after being turned on and off?

#

it doesnt right?

slate swan
#

dx

alpine cove
alpine cove
alpine cove
slate swan
#
class Help(nextcord.ui.View):
    def __init__(self, user):
        self.user= user
        super().__init__(timeout=None)


    @nextcord.ui.Select(placeholder="What are my commands?", options=[
        nextcord.SelectOption(emoji=":moderator:", label="Moderation Commands", description="My moderation commands!"),
        nextcord.SelectOption(emoji=":tada:", label="Giveaway Commands", description="My giveaway commands!"),
        nextcord.SelectOption(emoji=":9330appdirectorygameswhite:", label="Fun Commands", description="My fun commands!")
    ])

    

    async def help_callback(self, select, interaction: nextcord.Interaction):
        select.placeholder = f"Reason: {select.values[0]}"
        reason=select.values[0]
        if reason == 'Moderation Commands':
            await interaction.response.send_message(f"!lock locks a channel, \n!unlock unlocks a channel,\n !userinfo shows info of a user,\n !ban bans a member,\n !kick kicks a member, \n!clear clears messages,\n !cm clears messages from a specific member", ephemeral=True)
        if reason == 'Giveaway Commands':
            await interaction.response.send_message(f"/create creates a giveaway, \n /reroll rerolls a giveaway", ephemeral=True)     
        if reason == 'Fun Commands':
            await interaction.response.send_message(f"!emojify turns a message into an emoji", ephemeral=True)
            


@bot.slash_command(name="help", description="Shows my commands")
async def helping(interaction: nextcord.Interaction):
    view = Help()
    embed= nextcord.Embed(title="My commands!", description="Check my commands! You can also use !help :)")
    await interaction.response.send_message(embed=embed, view=view)```

```      class Help(nextcord.ui.Select):
  File "c:\Users\PC\Desktop\Appelsy Bot\main.py", line 272, in Help
  async def help_callback(self, select, interaction: nextcord.Interaction):
TypeError: 'Select' object is not callable```
naive briar
#

Use the deco

#

!d discord.ui.select

unkempt canyonBOT
#

@discord.ui.select(*, cls=<class 'discord.ui.select.Select'>, options=..., channel_types=..., placeholder=None, custom_id=..., min_values=1, max_values=1, disabled=False, row=None)```
A decorator that attaches a select menu to a component.

The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View "discord.ui.View"), the [`discord.Interaction`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction "discord.Interaction") you receive and the chosen select class.

To obtain the selected values inside the callback, you can use the `values` attribute of the chosen class in the callback. The list of values will depend on the type of select menu used. View the table below for more information.
alpine cove
#

?

slate swan
#

what

alpine cove
#

just dont

slate swan
#

what

alpine cove
#

ima go off I'm crying

split forge
#

@alpine cove

slate swan
torn sail
split forge
slate swan
#

what question

split forge
#

Because I am a person who does not understand anything without a brain.

split forge
slate swan
#

...

#
@tree.command()
@app_commands.guild_only()
async def command(...):
  ...``` what's so complex with it?
slate swan
#

you didnt sync the code then

#

tree.sync()

split forge
#
  File "/home/container/main", line 112, in <module>
    @app_commands.guild_only(name='prices', description='shows prices')
TypeError: guild_only() got an unexpected keyword argument 'name'```
split forge
slate swan
#

those arguments are supposed to go into command decorator not guild_only

split forge
#

how??

#

IM STUPİD

#

is it have video?

slate swan
#

😐 idk what to say at this point of time

#

!resources please learn basic python, it will save time of both helpers and yourself

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.

slate swan
#

!d discord.app_commands.CommandTree.command you see the name kwarg? that should go there

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.
cloud dawn
#

Thanks Sarth :3

slate swan
#

yo anyone here

#

does anyone know why i cant import discord

#

even tho i have pip installed discord-py

split forge
#

pip install discord

slate swan
split forge
#

uhm idk

upbeat otter
slate swan
#

but thanks tho

upbeat otter
#

cool

slate swan
#

Anyone know how I can make my drop down so that you can’t press it anymore after you’ve click one of the options lmk if u need ss of my code

alpine cove
slate swan
#
class Help(nextcord.ui.Select):
    def __init__(self):   


        options = [
            nextcord.SelectOption(
                label="Moderation Commands", description="My moderation commands", emoji=":moderator:"
                ),
            nextcord.SelectOption(
            label="Giveaway Commands", description="My giveaway commands!", emoji=":tada:"
            ),
            nextcord.SelectOption(
                label="Fun Commands", description="My fun commands!", emoji=":9330appdirectorygameswhite:")
        ]
        super().__init__(
            placeholder="Choose your favourite colour...",
                min_values=1,
                max_values=1,
                options=options,
            )

    async def callback(self, select, interaction: nextcord.Interaction):
        select.placeholder = f"Reason: {select.values[0]}"
        reason=select.values[0]
        if reason == 'Moderation Commands':
            await interaction.response.send_message(f"!lock locks a channel, \n!unlock unlocks a channel,\n !userinfo shows info of a user,\n !ban bans a member,\n !kick kicks a member, \n!clear clears messages,\n !cm clears messages from a specific member", ephemeral=True)
        if reason == 'Giveaway Commands':
            await interaction.response.send_message(f"/create creates a giveaway, \n /reroll rerolls a giveaway", ephemeral=True)     
        if reason == 'Fun Commands':
            await interaction.response.send_message(f"!emojify turns a message into an emoji", ephemeral=True)
            


@bot.slash_command(name="help", description="Shows my commands")
async def helping(interaction: nextcord.Interaction):
    view = Help(interaction.user)
    embed= nextcord.Embed(title="My commands!", description="Check my commands! You can also use !help :)")
    await interaction.response.send_message(embed=embed, view=view)```
alpine cove
velvet compass
#

A weird take, but ok

torn sail
potent light
#
class Questionnaire(Modal, title='Questionnaire Response'):
    def __init__(self, form_data: list, modal_view, third_topic_name):
        super().__init__()
        self.form_data = form_data
        self.modal_view = modal_view
        self.third_topic_name = third_topic_name
        
    print("tpn: ", third_topic_name)
    print("tpn: ", self.third_topic_name)```
both return an error saying that `third_topic_name` isn't defined. The second says `self` isn't defined.
What'w wrong with this?
potent light
slate swan
#

Ill try thanks

potent light
#

np

potent light
#

@alpine cove bro can u help me

alpine cove
#

anyways go ahead

slate swan
potent light
slate swan
#
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 291, in helping
    view = Help(interaction.user)
TypeError: __init__() takes 1 positional argument but 2 were given

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

nextcord.errors.ApplicationInvokeError: Command raised an exception: TypeError: __init__() takes 1 positional argument but 2 were given
timid spade
#

i am making a slash command, the bot runs but i cant see the command in sever. can someone tell me why is that?

potent light
slate swan
#
@bot.slash_command(name="help", description="Shows my commands")
async def helping(interaction: nextcord.Interaction):
    view = Help(interaction.user)
    embed= nextcord.Embed(title="My commands!", description="Check my commands! You can also use !help :)")
    await interaction.response.send_message(embed=embed, view=view)```
#

those are the lines

potent light
slate swan
#

omg

#

why did i forgot that

potent light
#

lol

slate swan
#

i will try

#

omg

timid spade
slate swan
#
  File "C:\Users\PC\AppData\Roaming\Python\Python39\site-packages\nextcord\application_command.py", line 1542, in get_type
    raise ValueError(
ValueError: SlashCommandOption interaction of command SlashApplicationCommand help <function helping at 0x000001F41370F8B0> Type `<class 'nextcord.interactions.Interaction'>` isn't a supported typehint for Application Commands.```
potent light
slate swan
#

when im trying to load the bot

timid spade
potent light
#

@slate swan yeah I gave you a bad answer

#

I just checked that it doesn't have to be there

#

view = Help(interaction.user) the problem is with Help. Try self.Help(interaction.user)

slate swan
#

okay i will

#

so i do need to add self

slate swan
potent light
slate swan
#

wait

alpine cove
slate swan
#

i did smt

#

and now it shows that error

alpine cove
#

nvm

slate swan
#
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 293, in helping
    await interaction.response.send_message(embed=embed, view=view)
  File "C:\Users\PC\AppData\Roaming\Python\Python39\site-packages\nextcord\interactions.py", line 879, in send_message
    payload["components"] = view.to_components()
AttributeError: 'Help' object has no attribute 'to_components'

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

nextcord.errors.ApplicationInvokeError: Command raised an exception: AttributeError: 'Help' object has no attribute 'to_components'```
potent light
slate swan
#

like yes

#

i removed the interaction.user

potent light
#

send the code where u have payload["components"] = view.to_components()

#

@alpine cove dude did u check my issue im almost crying now

potent light
#

oh my bad

#

@slate swan it's a little bit hard to understand the issue with too little code around. Send the definition of Help()

potent light
potent light
slate swan
#

thank uu

alpine cove
potent light
potent light
slate swan
potent light
#

genius

slate swan
#

now when im selecting somethi9ng it says

Traceback (most recent call last):
  File "C:\Users\PC\AppData\Roaming\Python\Python39\site-packages\nextcord\ui\view.py", line 390, in _scheduled_task
    await item.callback(interaction)
TypeError: callback() missing 1 required positional argument: 'interaction'```
timid spade
slate swan
#
@tree.command(guild=[guild here], description="description", name="texting")
async def texting(interaction: discord.Interaction):
    await interaction.response.send_modal(TextModal())

Traceback:

async def texting(interaction: discord.Interaction):
AttributeError: 'int' object has no attribute 'id'
alpine cove
#

are u syncing ur commands?

#

bot.tree.sync

#

use bot instead of client

alpine cove
timid spade
timid spade
alpine cove
slate swan
#
class Help(nextcord.ui.Select):
    def __init__(self):   


        options = [
            nextcord.SelectOption(
                emoji=":moderator:", label="Moderation Commands", description="My moderation commands"
                ),
            nextcord.SelectOption(
            emoji=":tada:", label="Giveaway Commands", description="My giveaway commands!"
            ),
            nextcord.SelectOption(
                emoji=":9330appdirectorygameswhite:", label="Fun Commands", description="My fun commands!")
        ]
        super().__init__(
            placeholder="All of my commands!",
                min_values=1,
                max_values=1,
                options=options,
            )

    async def help_callback(self, select, interaction: nextcord.Interaction):
        select.placeholder = f"Reason: {select.values[0]}"
        reason=select.values[0]
        if reason == 'Moderation Commands':
            await interaction.response.send_message(f"!lock locks a channel, \n!unlock unlocks a channel,\n !userinfo shows info of a user,\n !ban bans a member,\n !kick kicks a member, \n!clear clears messages,\n !cm clears messages from a specific member", ephemeral=True, view=Help())
        if reason == 'Giveaway Commands':
            await interaction.response.send_message(f"/create creates a giveaway, \n /reroll rerolls a giveaway", ephemeral=True, view=Help())     
        if reason == 'Fun Commands':
            await interaction.response.send_message(f"!emojify turns a message into an emoji", ephemeral=True, view=Help())

and when i try to select something it does nothing

alpine cove
#

bruh

potent light
slate swan
#

No

alpine cove
potent light
# slate swan No

ok print(select.values) below select.placeholder = f"..." then see what it says.

slate swan
#

okay

potent light
potent light
alpine cove
slate swan
#

yes

#

ill try callback

#

without help?

potent light
slate swan
#
Traceback (most recent call last):
  File "C:\Users\PC\AppData\Roaming\Python\Python39\site-packages\nextcord\ui\view.py", line 390, in _scheduled_task
    await item.callback(interaction)
TypeError: callback() missing 1 required positional argument: 'interaction'```
potent light
#
class Questionnaire(Modal, title='Questionnaire Response'):
    def __init__(self, form_data: list, modal_view, third_topic_name):
        super().__init__()
        self.form_data = form_data
        self.modal_view = modal_view
        self.third_topic_name = third_topic_name
        
    print("tpn: ", third_topic_name)
    print("tpn: ", self.third_topic_name)
    email = TextInput(label='Email address', custom_id = "email_address")
    name = TextInput(label='Username', custom_id = "username")
    third_topic = TextInput(label = f'{self.third_topic_name}', custom_id = "3rd topic")```
#

Basically third_topic = TextInput(label = f'{self.third_topic_name}', custom_id = "3rd topic") says that self isn't defined. Without it the modal works fine.

alpine cove
#

yea

potent light
slate swan