#discord-bots
1 messages · Page 135 of 1
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)```
are you sure you're importing Modal from the right place?
yes because it worked without def __init__()
from discord.ui import Select, View, TextInput, Button, Modal
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
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
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
Why would I need super().__init__? I don't even use a subclass.
print data.admins
you're subclassing Modal
all I need is to pass an argument to it, that's all. It worked without def __init__(self, test_list: list)
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__
inside def __init__() or?
correct
class Questionnaire(Modal, title='Questionnaire Response'):
def __init__(self, test_list: list):
super.__init__()
self.test_list = test_list```
anything wrong?
super**()**
oh my bad
apart from that, nothing wrong by the looks of it
async def profile(ctx, user: discord.Member = None):
if not user:
user = ctx.author``` any way to simplify this just curious
i'll try it rn
user = user or ctx.author
or
async def profile(ctx: commands.Context, user: discord.Member = commands.Author):
...
@fading marlin py raised an error: SyntaxError: invalid syntax (userAnswer.py, line 8) Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x00000205D77CE560>
ok thanks
class Questionnaire(Modal, title='Questionnaire Response'):
def __init__(self, test_list: list):
super.()__init__()
self.test_list = test_list```
why does it work, wouldnt user or ctx.author be a boolean
the period is in the wrong place
No, if user is none then it takes ctx.author
it checks whether user evaluates to True, if it does, then it keeps it, if it doesn't, it uses the value of ctx.author. user and ctx.author act as booleans, the or operator decides which one to use based on if the value of the left one evaluates to True
im blind, thanks it worked now
is using bot.var the same as using global var?
you can use bot.var in a cog. You can't do that with a global var
quick question, any way to get the interactions msg id from an view
since im pretty sure i cant just do msg = interaction.message.id
you can
ah thought i had an error before with that, ill give it a try thanks
it can return None though, that might be the reason for the error
How to create a simple discord bot using python
why would it return none?
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?
with lots of patience and knowledge
And how can I turn my python into an app
awful way to learn how to code
LOL i know
dunno, docs don't specify 
yes
pingu u good, u been typing for 100 years
I rather not, if you have any questions, please ask them here
well that settles it im gonna struggle bus through another button menu
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

are u using form models
or did i miss understood that
discord.ui.modal
guessing so
ooo wait what if i make it send another modal on submit of the first one
so whats ur problem, the max 6 questions thing?
cant do that sadly
whelp
wont work
yea the max values of modals being so low
your best bet is to on submit, send a view to open y our next model
yeah haha
Not exactly, A global variable is bounded to a module object while an instance variable is bounded to that certain instance, its best to keep your global scope clean!
@mighty pilot if you wanna be lazy
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}'
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
well you could do that with one view
when eber im disasbleing a button i just do it with two seprate views since its easier
but i like the idea
i know but self.button.disabled.whatever is garbage
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
either will work, consider using a list instead of a plain string though
i have it working (almost) flawlessly in my main project lol
ah nice
theres one view that i cant disable buttons on timeout, other than that ive got disabling buttons working great
Hey @upper lodge!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
welp
idk how to use list like that..
is there any example?
https://paste.pythondiscord.com/lebofahebi
https://fluffycat.pics/wPFv7A11
Anyone know if theres a way to edit copiolet suggestions? it always suggests it like this when that wont work (interaction has to be first, then button)
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
you can even use a class attribute instead of a botvar
somebody help me with this again.. happens everytime i reinstall my pc and i always forget how to fix it
🤷 I've got no clue how copilot works
rip, thanks tho
py -3 -m pip install ... for windows
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?
Thanks but isnt there a way to just make it pip? I mean i used it before
sir, this is the discord.py channel
dunno, I haven't used windows in a long time
it's probably somewhere on google
so if i use that the command will work even if 2 pers or more use it at the same time and is there any example?
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
ty for the help
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?
same thing happened when i wanted to install discord so i thought nextcord would work
super annoying
3.11 ?
yes
try 3.10.8
is the new version of dpy much better than the old?
wdym?
1.7 and. 2.0?
well 1.7 doesnt support slash commands, context menus, modals and all the fancy ui stuff
oh.
the docs should go more into detail on that
well 2.0 works just like 1.7 with slash support
maybe some tiny little changes but thats it
just go with 2.0
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
Why cant I load a cog? Used to do it like that
ye
!d asyncio.run
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...
well then why r u trying to use .Option
thats a thing most forks include like pycord
idk
i just swtiched from pycord
disocrd.py uses app_commands.describe
check the examples
i have it wont work when ive treid
its being black
wdym?
nothing i just like saying it
thats on ur end
im black
well that didnt really change anything but im sure u werent tryna be hateful towards anyone
i was towards the bot
look its 3am but i, just gonna say that that sounds racist af
"its being black" being used as an insult is problematic
is that why its messing up
can someone tell me how i can stop it from trying to message itself?
or why the except is being ignored?
dont use nextcord
i ended up doing this, made a view with 2 buttons which open different modals with different questions. right now each modal sends different messages into a channel for the answers. is there a way i could combine them all into one embed?
!d nextcord.HTTPException 
exception nextcord.HTTPException(response, message)```
Exception that’s raised when an HTTP request operation fails.
use a db to upload your answers too?
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
I was trying to avoid a db with this bot 😂 how would I pass the answers around like that?
just from model one, pass it into it? then pass the answers from the buttons to model two
and why, just use sqlite, shit but works good for simple things like this
I have a whole mariadb running on my server, that's not my issue. Just preference in which bots are doing what
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
Hmmm alright. I'll have to mess with it a bit tomorrow. Thanks for the insight!
np
can some one show example to how to use list?
here the code https://paste.pythondiscord.com/lebofahebi
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?
Also i would love suggestions on the README😭
looks pretty good. maybe add the content of the message when u send a message
Yeah, i think the project lacks a bit of verbosity in messages/descriptions
Why are you using fetch_channel
intercord/client.py line 29
channel = await self.fetch_channel(self.channel_id)```
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
There's no way to tell what this even does without looking into code
guilds are chunked on connection
Was the examples not good enough?
It doesn't show what your client even does
Can you refer me to the code where this action happens?
i would just add a quick summary of what it does
Will do i guess :p
And also no subclass for commands.Bot?
The method that dispatches the parser for the guilds to be chunked!
Right now, the extra boilerplate isn't needed, but when i do make documentation i will probably use cogs
Just curious
??
?
how does this have anything to do with cogs
I'm saying you only have a client subclass and not one for bot
so people using bot can't use this
Because i havent implemented commands yet?
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
discord/state.py line 533
async def _delay_ready(self) -> None:```
(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)
🦦
reminded me of bad memories with bitlocker
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(...)```
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
why aren't you just using the proper type
why take id
For other large numbers all you can do is use str
because 1. I use it for database and 2. I have another large id I need to handle, using discordid type for that would be misleading
nvm there isnt a datatype for it
- And..?
- Just stick with str
well excuse me for wanting a cleaner solution, this just doesn't make much sense to me, because a discordid is a valid integer
an integer is 16 bytes the discord id is more than that
what u need id for?
I stole information about user in database, the id is the identifier
so why not just type hint discord.Member
Well, I have another ID as a possible parameter that is like discordid
it's a discord limitation
i guess i will use discord.Member and check manually the other then :/
how do I set a default Choice[int] parameter? it doesn't accept a Choice object as default
name_param: int = 0 should work
it'll be marked as optional parameter by discord
I had an integer as default but then I need to check if the parameter is Choice or int
yeah
do u know discord.py 2.0
@ocean dragon are u using discord.Option with choices?
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):
...
ok, lemme check the docs
is this pycord?
no its discord.py
try this:
async def ping(self, interaction: discord.Interaction, c: typing.Litera["choice", "choice2"] = "choice"):
...
works but then there is no integer, but ig I can convert it
typing.Literal can accepts intger
yeah but I need int - str pair
converting to int is the most efficient way to get ids from slash commands
discord.Member can accept str also
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
not how slash command choices work
the user will have to provide a choice, so there's no point of having a default value
https://github.com/Rapptz/discord.py/blob/master/examples/app_commands/transformers.py#L97-L108 this example is more suitable for you
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))```
@ocean dragon ^
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^^
I dont think we support music in thr server
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
uh? I dont wanna play music here. Its for an RolePlay server to play OWN created music oO
What?
@naive briar With the GUI in the background dont how to tell the bot to play music. Without a channel command
you can use get_channel with ids
voice_client: discord.VoiceClient = discord.utils.get(bot.voice_clients, guild=guild)
or
Bot.fetch_channel(id) ?
first one should work if you have a Guild object
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
!d discord.Guild.voice_client use ctx.guild.voice_client
property voice_client```
Returns the [`VoiceProtocol`](https://discordpy.readthedocs.io/en/latest/api.html#discord.VoiceProtocol "discord.VoiceProtocol") associated with this guild, if any.
the same with get channel? ctx.guild.get_channel?
Hopefully you get well soon :)
@slate swan yeh i hope, the bot is not that problem, but to combine it with a GUI -.-
@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
what are you even asking here
how would you have ctx if you executed this from a gui
@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.
what voice channel
how do you have ctx here
wtf is going on
@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)
@self.command ??
you cant have commands inside the bot subclass
youre missing self from the command params anyway
i said voice_client not voice_clients, read properly
this whole thing is a mess
and again you used discord.utils.get, is this some stackoverflowed or tutorial code?
@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)
if that works then youve really messed up something
!d discord button
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.
dont spam here, #bot-commands
@slate swan yes commands inside the init
hell
without it, its nearly impossible to get it work in a GUI
^^
a gui with discord bot makes no sense, that would either be blocking or will have loopholes
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
lmao
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
half of this guy's message isnt even comprehensible
it would be more funny if you;re referring a discord message with buttons as a GUI
Hello there! If anyone knows how to do Slash commands, can you tag me? I need to ask a question.
what about slash commands and what lib are you using
I was going to ask nothing, for example, let's have a command called /hello, when I type this command in dm, it will not respond, but when I write it on the server, it will reply. How can we do this?
Wouldn't threading or multiprocessing solve the problem
He could actually just integrate API into bot and make requests from the GUI app
as i said, with blocking IO
heey?
api??
an ipc, not api
you can check if interaction.guild is None, if it's None, the command was used in dms
you can also hide the slash command from dm channels
!d discord.app_commands.guild_only
@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...
how ı can make hide in dm?
.
chrispy just told
Thanks
never knew it would hide it i always thought i was a check like the ext.commands version, interesting
a websocket server works too
just like discord uses events
yeah, still more ipc than api tho lol
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
yeah exactly
okay but I need to install module to make this?
rhythm's webapp was pretty cool though
what module?
it's part of discord.py and similar forks
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
yep
the command decorator should be @uncut zenith.command tho
sorry for the ping, blame your username
Now if I write /hello to your bot's dm, it won't reply to me, right?
it wont show up any /hello command there :p
okay
its tree
is it true?
this
its not working lmafo :P
elaborate
Can ı send code?
we cant read your mind, wdym not working
sure why not
@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)
bro @tree.command
what should i write
@strange knoll_commnds.command()?
wa
@app_commands.guild_only(name = 'test', description='it test command')```
right? @upbeat gust
its the same as your other commands, just add the extra guild_only deco
just do the same as your other commands.
İDK
Could you please send it to me as attached? pls
no im not gonna write code for you
@strange knoll_commands.guild_only(name = 'test', description='it test command')
this is true?
can you do this first
forget about the guild_only
just do that first
can you come dm?
WHY
@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??????
CAN YOU JUST DO THE SAME AS YOUR OTHER COMMANDS FIRST
.
no
ffs
how I can do it another commands
lol im out bye
can you send example plase
PLEASE
@upbeat gust plsssssssss
weve told you exactly what to do, im not wasting any more time on you
lmao
I don't quite understand what I will do if you give an example
i am turkish and i use translation
OKAY I UNDER STAND YOU
@discord.app_commands.guild_only()
right @upbeat gust ?
STOP PINGING ME
sory
ykw, block
is it tru rn?
you have been told like 10 times, use tree.command instead of app_commands.command
how does one simplify it
sorry Im dumb
sorry :(
noones dumb, pay attention while reading
ys
Does anyone know I can change this so my bot only sends the ids I send to my bot I’m stuck on it
..what?
or his tranlator translates tree --> app_command
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
why though
what u are attempting to do and the code u sent above aren't related unless u are sending the bot the ids through a modal
@shrewd apex
I'm more confused why you'd even want this
I js need to do it
just make a echo command -_-
🤨
Ok let me try that
i have a bad feeling now
Btw it can’t be a command
use on_message event or a modal
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
Sounds sus
But how do I format the on message to only send the ids I send back once
!d discord.ext.commands.Bot.wait_for
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**...
easiest way is just sending the ids
no need to format seperately
bro u just need it to repeat ids why u want formatting and all more sus
How do I use the on message to only send the id I send to the bot back once

😅
wdym once
i am hungry i am gonna go grab a snack chrispy gonna help u
slice cake nom nom
yum
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
Never knew a snack eats snacks, cannibalism😳
Damn everyone left me 💀
@shrewd apex @upbeat gust so I got this monstrosity
.. How is discord.Member.id supposed to work
That's a property of a class
are you looking for message.content??
Idk just experimenting ig
I want my bot to just send the users id back when I send it to the bot In chat
Soo.. The message's content
Yeah
literally asyncpg
ok
btw how do i prevent github repo from uploading my .env file
do i just do this
.gitignore
use .gitignore and then write the name of the env file
should i update it
Make a gitignore and write the name of the file!
how do i make a gitignore ;-;
Updating won't hurt
ok
Googel 🤗
ok
^ ctrl+shift+p >add to .gitignore
ok
@upbeat gust what to change
Why are ur questions so easily googleable
Ive said
make this channel a bit alive ig
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
Print eman
What should i change about the message content is what I’m asking
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"
Because the websites and tutorials you can easily find give much more info than we can over discord
Teaching to learn to google is help too imo 🤗
What?
What extra info does a gitignore have that you cant explain?
Gitignore is so easy
:/ everyone has their first time u see
You just list relative paths of files you don't wanna have in repo
make a file named .gitignore and add the files/folders you want git to ignore
Each path on separate line
oo
And there's some additional stuff like regex and ! but you don't really need it
like this?
It's not a folder
file not folder
a file, not a folder!
rename it to secrets.gitignore?
no, no, a file named .gitignore :p
no no
@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.```
how do i import that file to main.py
make a file named .gitignore, open the file and type secrets.env
u dont import that file ....., what are you doing?
How can I make my bot send the id of a discord user that I send to the bot back into chat
you dont, you put your special files dir in it that's all
im trying to store my token and db url in it
you are trying to store you token in secrets.env not .gitignore
ye
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
@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
so will the .env file be ignored
when committing yes!
well see what I mean? took like 30 messages with 4 people when one guide online couldve perfectly explained it, with examples
Good things come with time, no?
Idk simple explanation
nothing is printed
🦆 i just export KEY=VALUE in my zshrc
After what you print it
bruh
'
I just docker-compose and github secrets
eman = interaction.user.guild.get_role(1042001023084011573) ```after this
Ok well do you have error handlers
right click on secrets.env and then click on add to .gitignore
no....
anything for discord.py similar to https://docs.pycord.dev/en/stable/ext/pages/index.html ?
you didn't create a gitignore else it would have showed up there too
Do regex search on_.+error and @.+\.error
or do you mean the paginator specifically?
paginator yes
I have a large list of strings I need to display and paginate, because it exceeds 2000 characters
you'll have to make one urself
its easy
does that work for 2.0 though
How can I make my bot send the id of a discord user that I send to the bot back into chat
Idk how to fix
i mean what error
This will find possible error handlers
Cause I've seen many people having error handler in code and not even knowing that they do
use the thing that you want to check??, the message's content
i have no literal error handler just a single slash command
I need to use this instead of on message but idk how structure this so when I send a message of a users discord id my bot can send it back In chat
instead of checking if the content is equal to 'hello', check if its numeric
as you did before
@vale wing
But how do I make it send the id back now
send msg.content instead of 'Hello'
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
code block
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
!paste
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.
I would like to append dataframe to CSV file present in Aws S3, using AWS lambda, can anyone help me regarding this. #python
this isnt related to discord
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 Alr it works now but how do I make the bot only respond to me instead of itself
oh no way youre posting in every chanenl
check if the messages author is equal to the bots user
Should I put that at the top of def check or above msg =
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
it is printed now
didnt find any handlers tho
dont use requests, it is blocking, use aiohttp
bruh
Do you have an env ext for vsc?
why would it be coloured?
where do i use intents if i want to use the same code
what....
why not along with all the other checks you have
isnumeric and channel
I would like to append dataframe to CSV file present in Aws S3, using AWS lambda, can anyone help me regarding this. #python
when you initialise Client
god damn stop posting everywhere every minute
its not even related to this channel
can you send me the changes in the code on the file i sent
thats python
this is in normal .py file
and this isnt a py file
so my syntax in .env is wrong?
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
no? why would env have syntax highlighting anyway
theres like
no syntax
No
Do it yourself
There is a syntax that must be followed?
so if i from secrets import * and do secrets.token will it be the 'MTAzNzY...'
How else would env files be parsed with "no syntax"?
imagine being forced to use notepad 😢
there is syntax i just mean like
what would even be highlited
doesnt matter
The variable names, i'm pretty sure vsc even has env support
white mode + plain text
env is not a python file, or even related to python
And docs for it
you would load the env file not import it since it isnt a module
yeah but clients is not defined and i am not able to do it
so the only way is to make a python file and make it .gitignore?
you do it where youre calling init on client
am i right?
no?? you can use .env, its just not a python file and doesnt work the same way
not exactly
so i have to add intents in 15
So I can see how to do it
??????????
do what
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
its just message.author == client.user
forget it im just gonna make a python file and .gitignore it
bro just send please!!!!!
env files are a pain anyway, good choice
send what? based on your code it looks like you have some idea what youre doing
You can! its easier, you can also use JSON!
i dont its got messy now
send what
people here dont like gif in case udk
just pass intents to the intents kwarg of client.__init__, where youre calling super init
is this code right? eh
depends what library ur using
pycord?
still dont get it
uh
so for what should i use for slash commands in discord.py?
bot.tree.command
tree being you (application) command tree
application command = slash command btw
what local commit is waiting
i am learning from a youtube channel and in the mid of series he shifted to nextcord
now i am confused af
💀 let me guess
dont watch yt tutorials then
look at official guides, and the ones posted by dpy people
what dont you understand?
Lucas
just read the docs and look at the github examples
most tutorials are less then mediocre
i think he means his spoonfeed KEKW
yep, i am trying
thanks
not discord bot related
look the code i sent you is written by my team mate i compiled the database and was finishing it but it doesn't work
can u even import discord in railway.app 💀
mb
I’m fr confused on where to put it
@upbeat gust please help bro
what help do u need???? we cant help without knowing the problem
prob a pip python mismatch
r u using virtual envs?
im using vsc
he told you to do it urself
that means i need to update it?
ur just gonna make him block you
look the code i sent earlier is for a discord bot when i run it in replit it gives an saying missing intents
How do I stop my bot from sending messages to its own messages
where do i need to put intents
what does sending messages to its own messages even mean
am i illiterate or something
nope too lazy to explain do following for me (in the terminal):
python
import sys
print(sys.version)
timeout
copy pasta the 3 line?
yea
How long and are u sure cause @upbeat gust say do msg.author==client.user
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
yea
?
@wintry cape just help me
yea
sad anyone noises
unlikely
bro i need help
?
i told it above
btw its not even doing it
bruh
what does it print?
this is all the log is showing 💀
!intents @agile oak
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.
i dont get it
the stupid vsc throwing it down after i save it 💀
you don't have requirements.txt
its the railway host right
yeye
what is that
nvr heard of that
i think the only time i saw this is in my minecraft world folder 💀
it doesnt work this way?
Do you know how importing works
ik
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
It's just basic python
is there a library to make it easier?
What is that
!e
from math import pow
print(math.pow(2, 8))
@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
Can you spot what's wrong
a Discord api lib that's not a fork
lmao
?
you enter your pip dependencies inside it
!e
from math import pow
print(pow(2, 8))
@loud junco :white_check_mark: Your 3.11 eval job has completed with return code 0.
256.0
i see
?
huh???
which word out of those 7 did you not understand
i create a file call requirement.txt and copy pasta the pip dependencies?
no you enter all libraries that you pip installed for your project there
@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'
discord.py
pillow
pynacl
``` for example
Use #bot-commands for the love of God
please take it to #bot-commands this is not a spam channel
oo
but i mean #bot-commands is going to be a better place
while True is technically a spam 
no one will be there
=.=
btw @slate swan
ignore the bot = blahblah first
@slate swan?
but why is it an hour ago
:/
how can i make bot to connect certain voice channel?
oo i need to push it to origin💀
read the docs
!d discord.VoiceChannel
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.
!d discord.VoiceChannel.connect
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").
mr nootnoot
u know about requirement.txt?
all ur requirements
alr we have some progress
looks good
u know how to fix it?
yea
:D
how
code
the easiest fix is prob the worst
its:
import pip
pip.main(["install", "discord.py"])
this will work as long as pip is installed
yep
btw gtg
insert that at the top
cya
did you add the requirements.txt?
I couldn't lmafo
!d discord.ext.commands.Bot.add_view
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.
mh?
does that actually work?
like does it continue listening after being turned on and off?
it doesnt right?
dx
lol I just saved them
bruh
I dont belive that
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```
@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.
nextcord
ewwwwww
?
what
just dont
what
ima go off I'm crying
it asks you to add custom_id for each component that discord.py utilises for the next boot
You use it when you start the bot to listen for views that have already been sent
bro can you give me an example about the question i just asked as a code
what question
Because I am a person who does not understand anything without a brain.
.
...
@tree.command()
@app_commands.guild_only()
async def command(...):
...``` what's so complex with it?
ı made it
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'```
this error
those arguments are supposed to go into command decorator not guild_only
ha?
😐 idk what to say at this point of time
!resources please learn basic python, it will save time of both helpers and yourself
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
!d discord.app_commands.CommandTree.command you see the name kwarg? that should go there
@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.
Thanks Sarth :3
yo anyone here
does anyone know why i cant import discord
even tho i have pip installed discord-py
i alr did that
uhm idk
Make sure that:
- do you have the correct python interpreter selected?
- You have restarted the IDE
dw i have fixed it
but thanks tho
cool
No I mean I hope you get well soon, unless your 10 role play isn't normal
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
that makes sense nvm then
ewww thats not d.py
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)```
disgusting
discord.py forks disgust me
A weird take, but ok
I mean, it would be the same code even it was in discord.py
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?
Not sure but probably options=options should be options = self.options
Ill try thanks
np
idc lol
@alpine cove bro can u help me
@alpine cove ialreadydid.com
nextcord.errors.ApplicationInvokeError: Command raised an exception: TypeError: __init__() takes 1 positional argument but 2 were given
Same issue. Can you send the full error? It should show what line has that issue.
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
i am making a slash command, the bot runs but i cant see the command in sever. can someone tell me why is that?
Send the lines around 291 where there is view = Help(interaction.user)
@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
async def helping(self, interaction: nextcord.Interaction):
lol
any discord.py guy?
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.```
when im trying to load the bot
nice
self should not be there
oh
@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)
for that
yes
wait
might as well just ask your question
nvm
^
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'```
bcs of the guild prob
so it worked now you're having another issue
send the code where u have payload["components"] = view.to_components()
@alpine cove dude did u check my issue im almost crying now
i dont have it
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()
what r u doing?
im dumb
it workedd
@alpine cove this is my issue tho
thank uu
lesgo, what did u do?
:chad: yes
i made a view that takes the select menu
genius

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'```
you mean
uh the bot dont have perms or something to create commands in the server? eh
@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'
yea or the guild id is wrong
are u syncing ur commands?
bot.tree.sync
use bot instead of client
oh nevermind got it
alr where did u post ur pronlem + code
here^
...how?
ok sure
?
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
bruh
Does it show any error in your shell?
No
did u copy the github example?
ok print(select.values) below select.placeholder = f"..." then see what it says.
okay
used a sample from discordpy.readthedocs.io but I modified it.
doesnt print anything
It means that async def help_callback(self, select, interaction: nextcord.Interaction): isn't getting called.
try
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'```
nono my modal works fine. The problem that im having is how to use third_topic_name that I pass as an argument outside of def __init__()
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.
yea
send the lines where you used callback()
async def callback(self, select, interaction: nextcord.Interaction):
commands inside the init?
