#discord-bots
1 messages · Page 96 of 1
And if u want to change button then u can just do button.label = whatever and then interaction.response.edit_message(view=self)
What
Just use if statement
Much simpler
@discord.ui.button(label="Claim", style=discord.ButtonStyle.grey)
async def my_button(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.edit_message(view=self, check interaction.user.roles manage_messages=True)
its doing an error
I dont think so
OH
now I have a code called round_id = str(round_id) and I want it to write the round id in this code in my bot how can I do it
example .help
When [round_id] is entered, I want the round id we entered to appear at the bottom of the Embed.
statement
help
Ask ur question
I am trying to maske a bot that trade stocks with discord messages but it says me that "discord.ext.commands.errors.CommandNotFound: Command "Buy" is not found"
import alpaca_trade_api as tradeapi
import discord from discord.ext import commands
ALPACA_BASE_URL = "https://paper-api.alpaca.markets";
class bot(commands.Cog) :
def init(self, client):
self.alpaca = tradeapi.REST("<>","<>")
self.client = client
@commands.command()
async def Buy(self, ctx):
await self.alpaca.submit_order("BTC", 1, 'buy', 'market', 'day')
#await bot.wait_for("message")
#msg = ctx.message.content
@commands.command()
async def Sell(self,ctx,msg):
#msg = ctx.message.content
await self.alpaca.submit_order("MSFT", 1, 'sell', 'market', 'day')
def setup(client): client.add_cog(bot(client))
that's not even valid but ok.
How r u loading the extension
And can u use !paste for code
So we can see da indentation
!I am trying to maske a bot that trade stocks with discord messages but it says me that "discord.ext.commands.errors.CommandNotFound: Command "Buy" is not found"
import alpaca_trade_api as tradeapi
import discord from discord.ext import commands
ALPACA_BASE_URL = "https://paper-api.alpaca.markets";
class bot(commands.Cog) :
def init(self, client):
self.alpaca = tradeapi.REST("<>","<>")
self.client = client
@commands.command()
async def Buy(self, ctx):
await self.alpaca.submit_order("BTC", 1, 'buy', 'market', 'day')
#await bot.wait_for("message")
#msg = ctx.message.content
@commands.command()
async def Sell(self,ctx,msg):
#msg = ctx.message.content
await self.alpaca.submit_order("MSFT", 1, 'sell', 'market', 'day')
def setup(client): client.add_cog(bot(client))
indentations usually mess up while copy pasting, a screenshot is bettter
stop spamming.
im not spaming
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.
Use this to send ur code
R u sure the indents here are correct
Why is _init_ and both commands not in cog class
wait i dont paste it corectly wait a sec
Ok this look fine
But how r u loading this extension file
what version of dpy are you using?
whats that
how do i know?
from discord import version_info
print(version_info())
depends on how you installed discord.py in the first place
Or you can do pip freeze (or py -m pip freeze/python3 -m pip freeze) depending on how you installed it
Traceback (most recent call last):
File "d:\Data\alpaca trading bot\test.py", line 2, in <module>
print(version_info())
TypeError: 'VersionInfo' object is not callable
PS D:\Data\alpaca trading bot>
discord.__version__.
I mean version_info (not version_info())
how do you just cancel a slash cmd from timing out
you are probably taking to long to respond so you need to defer it
discord gives you 3 seconds to initially respond, if you need more time you can use the Interaction.defer(thinking=True) method and then follow up later
perfect ty
yeah i knew that was the reason, defer was just lost from my memory
why are u using sleep?
it's just an example smh
it's just to demonstrate how a method works
yeah but it’s unnecessary as the thinking parameter is pretty much a sleep already
...?
your sleeping the function itself tho lol and no code in the cmd would be executed
Hi, I tried using hybrid commands and it doesn't seem to work
I know?
what's the error/issue?
yea and you listed as an example so ppl will follow that example.
the slash commands aren't displayed but the prefix command works perfectly fine
heres my code
not my fault well
class Bot(commands.Bot):
def __init__(self):
intents = discord.Intents.default()
intents.message_content = True
super().__init__(command_prefix="$", intents=intents)
async def setup_hook(self):
await self.tree.sync()
print("synced")
async def on_command_error(self, ctx, error):
await ctx.reply(error, ephemeral=True)
@bot.hybrid_command(name="meme")
async def meme(ctx):
meme_url = "https://some-random-api.ml/meme"
async with request("GET", meme_url, headers={}) as response:
if response.status == 200:
data = await response.json()
meme_link = data["image"]
meme_embed = discord.Embed(title="Meme", color=0x2ecc71)
if meme_url is not None:
meme_embed.set_image(url=meme_link)
await ctx.channel.send(embed=meme_embed)
else:
print("Error")
did you enable the application commands scope?
while inviting the bot to your server
uhhhhh, no but slash commands worked perfectly fine with nextcord
so you just switched libraries?
can you print self.tree.sync() ?
lol sure
I got an error when I tried to print it out
discord==2.0.0
discord.py==2.0.1
You should delete the one that says discord==2.0.0 because it's not part of discord.py
seems like a fault with the library
How did you do this?
do I reinstall discord or...
ye I'll try it
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
is it possible to make a venv on a VPS like vultr
I wanna add 2 bots to a 2.50$ package (10 Gb space and 500Gb bandwith)
does it allow u to ssh into it?
yes
yeah all peace then
nice thanks
u can easily make venv and stuff
!indents
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
still dont work
Can you help @marble ocean again? They displayed that their discord.py version is 2.0.1
please
oracle cloud free tier has 4 core 24gb ram vps always free
nice thanks
just put discord in the requirements
then in ur script import discord
and everything will work
That's more ram than my machine
i already done this
doent set the version
?
😐
?
anyone help pls
Yessir 
whats ur traceback
its not traceback it is "discord.ext.commands.errors.CommandNotFound: Command "Buy" is not found"
thats the traceback error
I stopped using d.py a while ago, but if I'm not wrong, you should pass the name argument
so it would be something like
@commands.command(name = "alpaca_buy")
no it defaults to function name if you don’t pass name parameter
what is his function name is repeated.
not the case, but...
also, are you calling the setup function, I think if you dont do so, cogs wont be added to your main file
when we do the discord code formatting like "```py" or ```js to force the syntax highlighting, what are those labels called and is there a way for me to browse what other formats are available.
I load them in a somewhat different way
its a backtick, thats your question?
i mean the labels that can be used after the triple backtick
like "py" "js" "diff" etc, i wonder what is included in etc
Those are just code block tabs that are used to format code blocks in mark down
markdown like in github?
yes but you can declare which language to use for syntax highlighting, i want to know all the possible declarations
No, markdown files, github does use rst and md for the README file though
yeah, makes sense now.
Like all the languages that can be used for codeblocks?
thats his question, yeah
I think like all the available file extensions?
still dont work
https://www.reddit.com/r/discordapp/comments/8krzjp/list_of_languages_you_can_use_in_codeblocks/ gotchu
6 votes and 3 comments so far on Reddit
perfect, thank you very much.
Tabbed Code Blocks javascript I'm A tabconsole.log('Code Tab A'); javascript I'm tab B console.log('Code Tab B'); Single Code Block console.log('a code block'); A tabbed interface for displaying multiple code blocks. These are written nearly identically to a series of vanilla markdown code sni...
aw that is very helpful
Is it possible to ban a player who was not on the server or left the server using his id, for example, from another server?
I think no. you'll need to have a listener on on_member_join so if the user joins, you ban him 🔨
Thank you for answer and advice on how to think of it a little differently
no tho
Guild.ban requires a Snowlake
snowlake
so for example this would work:
await guild.ban(discord.Object(user_who_is_not_on_the_server_id))
new word in spanish
oh
will it?
await ban(user, *, reason=None, delete_message_days=..., delete_message_seconds=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Bans a user from the guild.
The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
You must have [`ban_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") to do this.
it was also known as hackban
@warm thunder
oooh
got it
When the python discord bot replies to people it looks like it uses the markdown Callouts that start with an emoji in a block quote.
I'm looking at the markdown docs at https://rdmd.readme.io/docs/callouts and I'm seeing that you can make your own Callout themes with some custom css and then display those custom Callouts with the emoji designated in the css.
Can you use the css in a discord message or is there an equivalent way that the python bot in this server makes custom Callouts?
Callouts are very nearly equivalent to standard Markdown block quotes in their syntax, other than some specific requirements on their content: To be considered a “callout”, a block quote must start with an initial emoji, which is used to determine the callout's theme.
I might also just be wrong about the python bot using callouts.
Discords markdown is limited, I don’t think it’s possible to do what you’re saying
Do @unkempt canyon emojis look different?
I think maybe I just misunderstood some of the bot replies i remember seeing.
Do you have an example?
I think he means embeds?
Or do you remember the command?
I cant find any specific examples, i just remember being impressed with the formatting of the bot replies and I thought that Callouts might be the source of the fancy formatting.
!src
awesome, this will sort it out, thank you.
You can check out the source if you want but it’s all just regular markdown
even if it doesnt answer my question it will answer the question I should have been asking anyway. that was what I needed, thanks.
mb had to be off for a bit, but dpy 2.0 has a fair number of breaking changes including load_extension and add_cog which have to be awaited
https://discordpy.readthedocs.io/en/stable/migrating.html#command-extension-changes
if this was the immediate cause of your issue you should have seen a RuntimeWarning: coroutine 'load_extension' was never awaited message
whats the command for reaction roles?
Hey!
Im making a bot with slash commands (pycord)
How would i get options like this?
what lib are you using?
pycord
Can anyone help me with detecting threads created on a message? I'm trying to delete both the message and the thread (if exists) in my code. I've dug through the documents and the closest thing I can find is the "parent id" for the thread
sorry but I can't help with pycord
what do you use?
disnake / dpy
in disnake there's disnake.ext.commands.Param where you can pass a kwarg called choices
pycord and dpy are very simular
!d disnake.ext.commands.Param
disnake.ext.commands.Param(default=Ellipsis, *, name=None, description=None, choices=None, converter=None, convert_defaults=False, autocomplete=None, channel_types=None, lt=None, ...)```
A special function that creates an instance of [`ParamInfo`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.ParamInfo "disnake.ext.commands.ParamInfo") that contains some information about a slash command option. This instance should be assigned to a parameter of a function representing your slash command.
See [Parameters](https://docs.disnake.dev/en/latest/ext/commands/slash_commands.html#param-syntax) for more info.
you would use this like
@bot.slash_command()
async def my_sus_cmd(inter, choices: str = commands.Param(...))
what lib are you using
discord.py 2.0.1
what would it be for d.py
how can I create and define a aiohttp session in my bot subclass using the recommended way (async)?
async def some command(self, inter, choice: typing.Literal[“first”, “second”])```
is one way
File "C:\Users\Eclipse\Desktop\Discord Bots\Eclipse's Utilities\main.py", line 6, in <module>
from discord.ext.flags import Intents
ImportError: cannot import name 'Intents' from 'discord.ext.flags' (C:\Users\Eclipse\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\flags\__init__.py)``` I keep getting this error an I dunno how else to import Intents
from discord import Intents
Or just don't import it at all
Instead use discord.Intents
just use discord.Intents().all()
name clashing
No? all is a classmethod
idfk thats what worked for me
You may already have a file/folder called discord, or some other type of shadow/clash
It will work, just know that you don't need to create an instance for it.
yea yea
It wont*
disnake/flags.py line 923
self = cls.__new__(cls)```
it's disnake but I'm quite sure discord.py has the same abstractions
It should still be able to create an instance regardless.
and yes dpy does share the same abstraction
Please enlighten me, it should raise an error
it doesn't
>>> import discord
>>> discord.Intents.all()
<Intents value=3276799>
>>> discord.Intents().all()
<Intents value=3276799>
maybe your type checker will complain but it should still work
Are you sure your discord.py version is up to date as it might have changed, as it should raise an error and warning from your type checker as said https://github.com/Rapptz/discord.py/blob/master/discord/flags.py#L661
discord/flags.py line 661
def all(cls: Type[Intents]) -> Intents:```
im pretty sure classmethods can be called on instances
it's 2.0.1.
!e
class A: ...
print((a:=A()).__new__(a))
@primal token :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 | TypeError: object.__new__(X): X is not a type object (A)
Am i having confusing myself or?
__new__ should receive the class rather than the instance there
!e
class A:
@classmethod
def method(cls):
cls.__new__(cls)
a = A()
a.method()
@torn sail :warning: Your 3.11 eval job has completed with return code 0.
[No output]
yep
staticmethods can also be called from instances i think
yeah
But how does it not raise an error here though?
This is confusing me allot
Yes, but in the given example you passed an instance of the class which isnt of an instance of type?
!e
class A:
@classmethod
def method(cls):
print(cls)
cls.__new__(cls)
a = A()
a.method()
!e
class A:
@classmethod
def method(cls):
print(cls, type(cls))
cls.__new__(cls)
a = A()
a.method()
@torn sail :white_check_mark: Your 3.11 eval job has completed with return code 0.
<class '__main__.A'> <class 'type'>
Could use some help in #help-grapes
It's a classmethod
It passes in the class instead of the instance
which is odd, as it actually doesnt pass the current state of the argument given
What do mean by that?
e.g
foo.bar()
foo would be an instance of Foo it's like doing
Foo.bar(foo)
my point is, the instance given within methods which when passed the local variable would be called self, in a class method when using it on an instance it actually doesnt pass the current instance, but the polymorphic object it came from
It's odd to me
Well it does pass the instance
Just not to method
The instance is passed to the wrapper function returned by the classmethod decorator
Which then grabs the class from that, and passes that to the method
def my_classmethod(method):
def wrapper(*args, **kwargs):
return method(args[0].__class__, *args[1:], **kwargs)
return wrapper
It'd look something along those lines
!e
def my_classmethod(method):
def wrapper(*args, **kwargs):
return method(args[0].__class__, *args[1:], **kwargs)
return wrapper
class Test:
@my_classmethod
def method(cls, var):
print(cls)
print(var)
a = Test()
a.method(10)
@hot cobalt :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | <class '__main__.Test'>
002 | 10
Yep, like i said, it's kinda still odd to see
Guys is there any way to check that a user has voted my bot on top.gg?
Like an api that sends response fastly and my bot knows?
https://docs.top.gg/api/bot/#last-1000-votes You can get the last 1_000 votes for your bot from the api. Looks like their rate limits allow you to check on the results once a minute at most. Pretty reasonable.
But i saw many bots on discord they take only like 5-10 seconds to dm me when i vote them
https://docs.top.gg/resources/webhooks/ probably subscribed to webhooks.
We need to pay for it?
I didn't completely read the docs.
green play button at top and select the main file as startup if that’s the only one
it shows this
select the startup file then
yes
that isnt vsc
same question anyway 🤷🏼♂️
its visual studio code 2019
I'm pretty sure its GUI isnt the same so there would be a different answer depending on the IDE
im staying up all night tonight
You mean visual studio?
im better off not going to bed
but based on the screenshot it’s the same layout
woops
mhm
Not sure how exactly, as VS looks like Microsoft word compared to VSC which looks quite nice
in terms of running a file
not as a whole
But we're talking about the layout of running files between 2 applications which isnt the samw in the sense of GUI
and im finding trouble runnning it, and i dont know how to select the startup file
they both have you select a startup, and they both use a play button?
i can’t tell if i’m missing something or if you’re a stickler for correct naming
What's a play button?

You mean a run button?
Why not use a lightweight feel text editor/IDE like vsc?
since vsc is what i can run on my potato pc
I'm pretty sure VS isnt beginner friendly
im using
vsc is much more lightweight
i mean it’s technically user preference
VS is the fully featured version of VSC, if you want a lightweight feel i would use VSC
do know VSC isnt that lightweight compared to others like vim or sublime text
notepad >
nano😏
ios notes then emailing yourself the code
use Microsoft word👀
i love their syntax options 😫
it's lovely
VS is an IDE for the C family of languages
VSC is a general purpose open-source code editor that you can customize with extensions
They are different
First time using discord.py's slash commands, and the sync function doesn't seem to be working for me.
What's the problem here?
@bot.command(name="sync")
async def sync(ctx):
await discord.app_commands.CommandTree.sync()
Error:
TypeError: CommandTree.sync() missing 1 required positional argument: 'self'
(ping when responding!)
!d discord.app_commands.CommandTree
class discord.app_commands.CommandTree(client, *, fallback_to_global=True)```
Represents a container that holds application command information.
you have to use client.tree.sync()
wait hold on i think you have to assign it manually
basically, you need an instance of CommandTree to work with
how do i download discord.py into vsc
uh
you mean how you install discord.py for python?
use python -m pip install discord.py
that goes into your terminal
not into the python repl
man im confused asf
its my first time coding
ever
then starting with discord.py is the wrong thing to do, you kind of need experience with python
you can start with learning python basics if you want
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
im trying to finish the bot, then i might go into python basics
that's not how that works
🤷♂️
i can't help you if you don't understand what i'm saying
You also need to learn a few paradigms before using the library
can i ask why you're building a discord bot?
So... How would I do that?
Sorry, I'm tired right now..
dms
thats why
unsolicited but sure
i mean again i can't help you because you have no exposure to the terminology we use
nvm
i did it
if you're worn out or tired today, don't beat yourself up. try another day so you don't waste your time stressing about code
here's an example for how to use the app_commands package. ask away if you have any questions.
I wouldnt say terminology is the best word but paradigms is the most suiting
i mean not really
typing into the console and the python repl are two different things
knowing that terminology helps
I wasnt personally referring to that, maybe we arent at the same page
please refer me to your page
I took terminology as in the paradigms used in Discord.py but it wouldnt fit in this context as you were referring to concepts like a terminal
i mean
it's clear who and what i was talking about
hi preocts sorry i'll stop the ot discussion
@primal token and @slate swan , it seems that you two are frequently having a debate over the pedantic meaning of a statement. Could you tone it down a touch?
sure
Can anybody help me with closing/deleting/completely removing a thread whenever the message it was tied to is deleted? I'm using discordpy. Am I missing something obvious?
never took it personal, its quite nice being corrected as i may learn more
this is included in that example
# In this basic example, we just synchronize the app commands to one guild.
# Instead of specifying a guild to every command, we copy over our global commands instead.
# By doing so, we don't have to wait up to an hour until they are shown to the end-user.
async def setup_hook(self):
# This copies the global commands over to your guild.
self.tree.copy_global_to(guild=MY_GUILD)
await self.tree.sync(guild=MY_GUILD)
do I need to copy the global commands over to a specific guild to use them?
can relate
thanks
i'm pretty sure that's done because guild commands sync pretty much instantly compared to global commands, which sync after a while. it's better for development
I'm glad you two aren't holding any stronger emotions at each other. To clarify why I step in; there is a vague line between being constructive and battling out smallest nits. One keeps the conversations flowing, the other tends drown out other conversation. :)
((ot would be a fine place to have a strong convo like that though))
oh lol i just read the comments from the snippet, that seems to have been the reason
global syncing should be instant but if youre referring to locals being faster then you're correct
no, you don't have to sync them to be able to use them, it's just way faster.
i take that back actually, i just know that updates to global commands are sent out slower than guild-only commands
👍
That makes me question why global commands took hours to register before, while now it's instant
seems like a implementation that was done rushed or at 3am🐧
not afaik, ive only really seen it in forms on discord.gg/discord-developers
thats where i found out personally as no news as i can remember where given
oh ic
interesting, discord devs are still discord devs lol
no change whatsoever in their wonky ways
kek, later✌️
ent
Hey!
I have a event where if someone joins a channel it makes them a private channel
Code:
https://hastebin.com/aruveraqet.py
How would i make it so if a vc is vacant for 10minutes it deletes it
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
when someone dcs from the channel check if its empty, create a task to delete in ten mins if nobody is in it still
hw would i do that?
idk maybe time.sleep
or make a event like time.now and annother time event and within those 10 minutes if anyone joins dont delete
you can print the properties of a vc and check, but other than that i wouldnt know
how would i check a category witht he vcs and if a channel is vacant it deletes it
ig before?
@little vector, looks like you posted a Discord webhook URL. Therefore, your message has been removed, and your webhook has been deleted. You can re-create it if you wish to. If you believe this was a mistake, please let us know.
oml
idk ig u can do like a while loop seeing if theyre in vc whilst the timer is running like ```py
#timer
a = True
you can make a var = true whilst bot timer is not done yet
while a == True:
check
#timer done
a = False
Trying to screenshot then send to a webhook, heres my current code.
`import pyautogui
from discord_webhook import DiscordWebhook
while True:
image = pyautogui.screenshot()
webhook = DiscordWebhook(url='example', username="deflationz")
'''webhook.add_file(file=f.read(), filename='hit.jpg')'''
webhook.add_file(image, filename='hit.jpg')
response = webhook.execute()`
no clue
yea but how would i get the bot to check a category
.
or how could i make the bot delete all the channels in that category after a day or so
probably get the id and see what category its in with checking the properties 🤦
id is also equal to channel
u can do this to get the properties ```py
channel = bot.get_channel(id)
print(channel)
im pretty sure u can do that
would this work?
while True:
if len(new.voice_status) == 0:
await new.delete()
break
wouldnt know, i havent rlly messed around with vc channels in dpy, and i dont want to mess up your work lol
lol
AttributeError: 'VoiceChannel' object has no attribute 'set_permisisons'
new.set_permissions(publicmembers, view_channel=True, connect=False)
do not time.sleep lmao thats blocking wtf
Can anyone help me with this?
AttributeError: 'VoiceChannel' object has no attribute 'set_permisisons'
new.set_permissions(publicmembers, view_channel=True, connect=False)
can you show code?
new.set_permissions(publicmembers, view_channel=True, connect=False)
now like whole code lol
new = await member.guild.create_voice_channel(f"{member.name}'s Channel")
category = discord.utils.get(member.guild.categories, name="Private Voice Channels")
publicmembers = member.guild.get_role(1009119229229924404)
new.set_permisisons(member.guild.default_role, view_channel=False)
new.set_permissions(publicmembers, view_channel=True, connect=False)
new.set_permissions(member, view_channel=True, priority_speak=True, connect=True)
weird
why not use overwrites tho
Typo
nice catch
ty
publicmembers = member.guild.get_role(1009119229229924404)
overwrites = {
member.guild.default_role: discord.PermissionsOverwrite(view_channel=False),
publicmembers: discord.PermissionsOverwrite(view_channel=True, connect=False),
member: discord.PermissionsOverwrite(view_channel=True, priority_speak=True, connect=True )
}
await member.guild.create_voice_channel(f"{member.name}'s Channel", overwrites=overwrites)
@slate swan
it was a type
ik im just showing a more efficient way
:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1664519442:f> (10 minutes) (reason: duplicates rule: sent 4 duplicated messages in 10s).
The <@&831776746206265384> have been alerted for review.
Traceback (most recent call last):
File "d:\Data\alpaca trading bot\main.py", line 10, in <module>
cogs[i].setup(client)
AttributeError: module 'bot' has no attribute 'setup'
anyone help
!d discord.ext.commands.Bot.load_extension - Use this to load cogs
await load_extension(name, *, package=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Loads an extension.
An extension is a python module that contains commands, cogs, or listeners.
An extension must have a global function, `setup` defined as the entry point on what to do when the extension is loaded. This entry point must have a single argument, the `bot`.
Changed in version 2.0: This method is now a [coroutine](https://docs.python.org/3/glossary.html#term-coroutine "(in Python v3.10)").
how would i get my bot to move a member from one vc to another?
!d discord.Member.move_to
await move_to(channel, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Moves a member to a new voice channel (they must be connected first).
You must have [`move_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.move_members "discord.Permissions.move_members") to do this.
This raises the same exceptions as [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.edit "discord.Member.edit").
Changed in version 1.1: Can now pass `None` to kick a member from voice.
like this:
for cog in cogs:
bot.load_extension(cog)
?
load_extension is a coroutine
await bot.load_extension(cog)
You need to await it
async def load():
await bot.load_extension(cogs)
load()
but it returns me the same error
How I add slash commands Can some body help me?
explain
First, load_extension only accepts a cog name or path to the cog. Second, your load function is a coroutine, you need to await it
come dm
You can have a look at their basic example here:
https://github.com/Rapptz/discord.py/blob/master/examples/app_commands/basic.py#L41-L44
examples/app_commands/basic.py lines 41 to 44
@client.tree.command()
async def hello(interaction: discord.Interaction):
"""Says hello!"""
await interaction.response.send_message(f'Hi, {interaction.user.mention}')```
await bot.load_extension(cog)
like this?
yesh
but it says "await" allowed only within async function
help please
Are you subclassing the bot? If yes, you can put your load function in the new setup_hook like so:
async def setup_hook(self):
await load()
If not, you'll have to start the bot with some extra code like this:
import asyncio
...
async def main():
async with bot:
await load() # Load cogs
await bot.start('token') # Run the bot manually
asyncio.run(main()) # Run the main function
There might be another way, but these are what I know.
make a prefix
client = commands.Bot (command_prefix = '/')
I think he meant interactive slash commands xd
What library are you using?
You can look at their basic example of slash commands here:
https://github.com/Rapptz/discord.py/blob/master/examples/app_commands/basic.py#L41-L44
Or with even more details here (pins):
https://gist.github.com/Ash-02014/b6f57065f394b54f43666037ade38d32
examples/app_commands/basic.py lines 41 to 44
@client.tree.command()
async def hello(interaction: discord.Interaction):
"""Says hello!"""
await interaction.response.send_message(f'Hi, {interaction.user.mention}')```
yeah? Thats what it does. That makes it possible to do /ban and shi
? :D
And sends interactive, ephemeral messages and etc..?
And converts all existing context commands to slash automatically?
That's awesome if it does, something new to me
What library are you using?
Hi
help
@client.command()
async def select(ctx):
await ctx.send("list", components=[
Select(
placeholder="Choose",
options=[
SelectOption(
emoji="😋",
label="Emoji",
description="Emoji1",
velue="e1"
),
SelectOption(
emoji="😀",
label="Emoji2",
description="Emoji2",
velue="e2"
)
]
)
])
res = await client.wait_for("select_option")
await res.respond(content="Вы выбрали тест"+str(res.component.emoji))
Error:
File "main.py", line 213
res = await client.wait_for("select_option")
^
IndentationError: unexpected indent
Remove a space from line 213
@discord.ui.button(
label="Create Ticket", style=discord.ui.ButtonStyle.green, custom_id="create_ticket:green"
)
async def create_ticket(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.response.send_message("A Ticket Is Being Created...", ephemeral=True)```
why isnt it working
idk im not home
!d discord.ButtonStyle
class discord.ButtonStyle```
Represents the style of the button component.
New in version 2.0.
Not discord.ui.ButtonStyle
Ohhh oopsss
thanks lol
The error-
2022-09-30 13:43:00 ERROR discord.client Ignoring exception in on_command_error
Traceback (most recent call last):
File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 190, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\PC\Desktop\Gal Cohen Bot\main.py", line 229, in setup_tickets
await ctx.send(embed=embed, view=CreateTicket)
File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\context.py", line 841, in send
return await super().send(
File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\abc.py", line 1520, in send
with handle_message_parameters(
File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\http.py", line 187, in handle_message_parameters
payload['components'] = view.to_components()
TypeError: View.to_components() missing 1 required positional argument: 'self'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\client.py", line 409, in _run_event
await coro(*args, **kwargs)
File "C:\Users\PC\Desktop\Gal Cohen Bot\main.py", line 180, in on_command_error
raise error
File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\bot.py", line 1347, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 986, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 199, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: View.to_components() missing 1 required positional argument: 'self'```
the code -
class CreateTicket(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.button(
label="Create Ticket", style=discord.ButtonStyle.green, custom_id="create_ticket:green"
)
async def create_ticket(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.response.send_message("A Ticket Is Being Created...", ephemeral=True)
class Bot(commands.Bot):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.persistent_views_added = False
async def on_ready(self):
if not self.persistent_views_added:
self.add_view(CreateTicket())
self.persistent_views_added = True
print("Persisitent views added")
@bot.command()
@commands.has_permissions(manage_channels=True)
async def setup_tickets(ctx: commands.Context):
embed = discord.Embed(title="Create A Ticket!", description="Click The Create Ticket Button Below To Create A Ticket")
await ctx.send(embed=embed, view=CreateTicket())```
view=CreateTicket() in last line
thank you so much ill try
hi
im uploading my id in stripe for discord bot verification
but discord throws back an error stating that the document type is unexpected
swap the order of interaction and butter in your callback
*button wtf
interaction: ... first, then button: ...
oh thank youuu
can anyone help me please
can you show the whole traceback with that part of the code?
traceback?
dude is sending verification
is it done via code?
nope
not at all
its all right, can you contribute anything to the fixation of my issue?
hi, ive got questions ab a code example using postgres as a db
(ive spent a couple hours learning ab classes before asking questions)
https://gist.github.com/jegfish/cfc7b22e72426f5ced6f87caa6920fd6
my questions are:
-is it normal that its possible to refer to the class before defining it, or is it okay in this example bc they call run() after defining it
-I dont understand the idea of calling run() in a runUntilComplete
(ik this is done to make tasks async, but I dont get it here)
-in this example id have to add the functions start() and logout() inside the class right?
-with the structure of this code id have to put all my bots commands inside of that Bot class? or do i make that Bot class use other classes
whats the extension of file you try to upload
https://discord.gg/discord-developers #bot-verfication
thanks a ton
They would probably have more people who could answer you
i never knew this existed
-
yes, but the function ( run here) should be called after that class's defination
-
run_until_complete was used to run the coroutine, simple as that ( could have used asyncio.run as well.)
-
nope, its already a method of Bot class
-
thats upto you, that is just one way of doing stufd
and I dont think this gist was really helpful anyways
all the database things could have been done within the setup_hook
me late ofc
ok thanks, ill look up what that is
!d discord.ext.commands.Bot.setup_hook
await setup_hook()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A coroutine to be called to setup the bot, by default this is blank.
To perform asynchronous setup after the bot is logged in but before it has connected to the Websocket, overwrite this coroutine.
This is only called once, in [`login()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.login "discord.ext.commands.Bot.login"), and will be called before any events are dispatched, making it a better solution than doing such setup in the [`on_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready "discord.on_ready") event.
Warning
Since this is called *before* the websocket connection is made therefore anything that waits for the websocket will deadlock, this includes things like [`wait_for()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.wait_for "discord.ext.commands.Bot.wait_for") and [`wait_until_ready()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.wait_until_ready "discord.ext.commands.Bot.wait_until_ready")...
nice thanks
here's an example of using it for aiohttp session and cogs, you can use it for whatever you want to do before the bot starts tho
https://gist.github.com/Master326486/6cf48c1ca0509b98e673451e356ba625#setup-hook
very helpful, thank you
You will almost always use asyncio.run instead of run_until_complete here
Probably one of the biggest thing about that is, run will do additional cleanup when it closes compared to run_until_complete
Like, closing async generators
Finishing tasks, etc
class CreateTicket(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.button(
label="Create Ticket", style=discord.ButtonStyle.green, custom_id="create_ticket:green"
)
async def create_ticket(self, button: discord.ui.Button, interaction: discord.Interaction):
msg = await button.response.send_message(content="A Ticket Is Being Created...", ephemeral=True)
overwrites = {
interaction.guild.default_role: discord.PermissionOverwrite(read_messages=False),
interaction.guild.me: discord.PermissionOverwrite(read_messages=True),
interaction.guild.get_role(1009471176264917012): discord.PermissionOverwrite(read_messages=True)
}
channel = await interaction.guild.create_text_channel(f"{interaction.user.name}-ticket",
overwrites=overwrites)
await msg.edit(f"Channel Created Successfully** {channel.mention}")
embed = discord.Embed(title="Ticket Created", description=f"{interaction.user.mention} Created A Ticket! \n Click One Of The Buttons Below To Alter The Settings.")
await channel.send(embed=embed, view=TicketSettings)
class TicketSettings(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.button(
label="Close Ticket", style=discord.ButtonStyle.red, custom_id="ticket_settings:red"
)
async def close_ticket(self, button: discord.ui.Button, interaction: discord.Interaction):
await interaction.response.send_message(content="Ticket Is Being Closed..", ephemeral=True)
await interaction.channel.delete()
await interaction.user.send(f"Ticket Closed Successfully! {interaction.channel.mention}")
class Bot(commands.Bot):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.persistent_views_added = False
async def on_ready(self):
if not self.persistent_views_added:
self.add_view(CreateTicket())
self.persistent_views_added = True
print("Persisitent views added")
@bot.command()
@commands.has_permissions(manage_channels=True)
async def setup_tickets(ctx: commands.Context):
embed = discord.Embed(title="Create A Ticket!", description="Click The Create Ticket Button Below To Create A Ticket")
await ctx.send(embed=embed, view=CreateTicket())```
swap button and interaction order again @slate swan
im noob
thanks
@slate swan wait i cant find where
create_ticket
async def create_ticket(self, interaction: discord.Interaction, button: discord.ui.Button):
like that?
yes
thank you i will try
install the library
Your close_ticket is also the wrong way around
yes
py-cord==2.0.1
class CreateTicket(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.button(
label="Create Ticket", style=discord.ButtonStyle.green, custom_id="create_ticket:green"
)
async def create_ticket(self, interaction: discord.Interaction, button: discord.ui.Button):
msg = await interaction.response.send_message(content="A Ticket Is Being Created...", ephemeral=True)
overwrites = {
interaction.guild.default_role: discord.PermissionOverwrite(read_messages=False),
interaction.guild.me: discord.PermissionOverwrite(read_messages=True),
interaction.guild.get_role(1009471176264917012): discord.PermissionOverwrite(read_messages=True)
}
channel = await interaction.guild.create_text_channel(f"{interaction.user.name}-ticket",
overwrites=overwrites)
await interaction.response.edit_message(f"Channel Created Successfully** {channel.mention}")
embed = discord.Embed(title="Ticket Created", description=f"{interaction.user.mention} Created A Ticket! \n Click One Of The Buttons Below To Alter The Settings.")
await channel.send(embed=embed, view=TicketSettings)
class TicketSettings(discord.ui.View):
def __init__(self):
super().__init__(timeout=None)
@discord.ui.button(
label="Close Ticket", style=discord.ButtonStyle.red, custom_id="ticket_settings:red"
)
async def close_ticket(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_message(content="Ticket Is Being Closed..", ephemeral=True)
await interaction.channel.delete()
await interaction.user.send(f"Ticket Closed Successfully! {interaction.channel.mention}")
class Bot(commands.Bot):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.persistent_views_added = False
async def on_ready(self):
if not self.persistent_views_added:
self.add_view(CreateTicket())
self.persistent_views_added = True
print("Persisitent views added")
@bot.command()
@commands.has_permissions(manage_channels=True)
async def setup_tickets(ctx: commands.Context):
embed = discord.Embed(title="Create A Ticket!", description="Click The Create Ticket Button Below To Create A Ticket")
await ctx.send(embed=embed, view=CreateTicket())```
yes
but i didnt understand how to fix it
u need to add something in the params
OH
I UNDERSTOOD
show ur requirements.txt file
how do you install reqs then
wait i didnt
!pypi functools
There's probably a mistake in some package's requirements
What command did you execute
Ok
how anyone know how i can make my bot send another button once someone clicks a button cause no vids on it or anything
if u create button when making the embed u cant ig
There are no vids (and honestly, there's totally no need to watch them), but there are examples on the repositories
no i want to click a button then my bot sends a button after
Uh what
oh i thought u wanted that on the same message
!status
@commands.command()
async def wanted(self, ctx, member: discord.Member = None):
member = member or ctx.author
wanted = Image.open("wanted.jpg")
asset = ctx.author.avatar.url(size=128)
data = BytesIO(await asset.read())
pfp = Image.open(data)
pfp = pfp.resize((177,177))
wanted.paste(pfp, (120,212))
wanted.save("profile.jpg")
await ctx.send(file = discord.File("profile.jpg"))
``` no errors in terminal but i get no command named "wanted'" found
i have error handler for commandnotfound
use pip install discord.py in terminal you haven't done yet
not working
hmmm
maybe not
pls fix
💀
that's why i shifted to vs community
codecamp tutorial?
mhm
try helping me with this
try using if and elif
@thorny frost do you have various python versions installed?
uh no, just the python with vs and one python 3.10 from windows store
is the cog loaded?
yup
could you try printing bot.commands and see if wanted is in the list
i have "all cogs are loaded" printed after
await client.load_extension("cogs.cogs.image")
was pip list a thing?
it is not
yes it lists all installed libs
a command for some reason
can i see the full cog class, does it have another wanted function?
Veseluxe do pip list and see if discord is there
uh
btw can we make bots using visual basic?
add some print statment in the init of the cog to see if it gets loaded
if it has requests and websockets support, sure
i think it's similar to C++ and people say vb can do anything c++ can do
@zealous jay what to do?
idk 🛌
so in short replit is the best option if ur making discord bots ||jk||
it is printed
not the best imo
unless you get hacker plan
fking cant install a module...'
Check if visual studio is using the correct interpreter
you are saying replit is best cus you have errors in vs for installing module?
uh how?
bottom right you can see which python version is using
oi oi see the spoiler text
._.
ú
me stupid
what
i have an update tho
try to find which python version vs studio is running
ok wait
i have this pyhton installed too
hmm try using the name kwarg in @command decorator
also make sure you saved the file and then rerun the bot
you have 2 versions of python installed, remove one
preferably let 3.19 stay.
*3.10
got no response from the command but it no longer says command not found
I think you can change interpreter with Ctrl + Shift + P
btw @slate swan yk how i can send a message like
shard id 1 is ready in a channel when a shard is ready
yeah but they still aren't sure what namespace are the python versions using and even if their pip is added to path or not
oh
pillow tasks and sending the image might take time... add a print statement in the cmd to make sure it got executed
yes there was for sure an event but I don't remember the name
!d discord.on_shard_ready
discord.on_shard_ready(shard_id)```
Similar to [`on_ready()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.on_ready "discord.on_ready") except used by [`AutoShardedClient`](https://discordpy.readthedocs.io/en/latest/api.html#discord.AutoShardedClient "discord.AutoShardedClient") to denote when a particular shard ID has become ready.
asset = member.avatar.url(size=128)
print("2")
data = BytesIO(await asset.read())
print("3")
pfp = Image.open(data)
print("4")
pfp = pfp.resize((177,177))
print("5")
wanted.paste(pfp, (120,212))
print("6")
wanted.save("profile.jpg")
print("7")
await ctx.send(file = discord.File("profile.jpg"))
``` there's something wrong in these lines
any idea on how i can add it in setuphook?
it wont send both buttons anyone know why
im using nextcord
custom_id maybe?
no
It's an event
i have it set to send a message as soon as ticket is made
try changing name
of what
second button
Because it has duplicate name
oh i mean commands.AutoShardedBot . . . in setup hook
Why do you want to add it there? 
for now i got this
class axn(commands.Bot):
def __init__(self):
intents = discord.Intents.all()
intents.message_content = True
super().__init__(command_prefix = 'a?', intents=intents)
async def setup_hook(self) -> None:
self.add_view(PersistentView())
async def on_ready(self):
print(f'Logged in as {self.user} (ID: {self.user.id})')
print('------')
The indent of the setup_hook is wrong; it wouldn't be called
then where should it be?
In the same level as on_ready
got it
wb this?
@naive briar
It's pretty much the same thing as commands.Bot but just added sharding to it. You can just subclass it like commands.Bot, although using it while your bot is still very small is not recommended
What if I use it on a small bot?
To my knowledge, it could increase resources usage and slow down your bot
While all apps can enable sharding, it's not necessary for apps in a smaller number of guilds.
It will not even shard
^
Each shard can only support a maximum of 2500 guilds, and apps that are in 2500+ guilds must enable sharding.
so the instance would work ig
But to be fair idk why they didn't just include it in bot.
Its name starts with Auto for a reason. It starts with one shard and creates more when the bot is in a lot of guilds (I think each shard manages a thousand guilds)
It doesn't shard at the start it starts with 0 since the bot self isn't a shard.
Well shard 0 is a shard
Well then the first instance isn't a shard
I guess it would be possible to shard across vms
To distribute the load iirc thats what mee6 does
if i type !hello in reply of some message how can i get the orignal message author member object ?
You can speed this up immensely by sending bytes instead of saving and sending the image, that's the slowest part in pillow

!d discord.Message.reference returns a MessageReference object which has a cached_message attribute which may or may not be available. So, you'll have to check if cached_message is not None, and if it is not None, you can access the author of that message using the author attribute. Whereas if cached_message is None, you'll have to use the channel_id and message_id attributes of the MessageReference object to fetch the message. (Note that the message_id attribute can also be None)
The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.
New in version 1.5.
you can simply check if message_id is None in the first place and if it is None, the cached_message will also be None
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
oh
https://paste.pythondiscord.com/ozidebuxal
the add user and remove user arent working
i heard that discord.py is getting discontinued
thats weird
no.
because my code isnt working
!!
ok ok what now
tell me how to fix it
look for a newer tutorial
kk tysm
@faint sapphire
https://paste.pythondiscord.com/ozidebuxal
the add user and remove user arent working
!d discord.ui.View - View only accepts 1 optional argument. Other than that, it'll only accept keyword arguments
class discord.ui.View(*, timeout=180.0)```
Represents a UI view.
This object must be inherited to create a UI within Discord.
New in version 2.0.
Oh
@slate swan you parse unexpected string as first argument of superclass init for no reason
Wtf
OOP
Exception has occurred: TypeError
expected token to be a str, received <class 'NoneType'> instead
File "C:\Users###\Desktop#################\Bot.py", line 36, in <module>
client.run(token)
where
You parsed None instead of string instance, isn't it clear
?
token = os.getenv("MTAyUTDwDDIzMjkyNjUxMTE1Ng.AQ-KJ1.hTRhRPu7gCyK67KA_NLXs9wdR4rerF6shgFLsY") (fake token)
This and that
!d os.getenv
os.getenv(key, default=None)```
Return the value of the environment variable *key* if it exists, or *default* if it doesn’t. *key*, *default* and the result are str. Note that since [`getenv()`](https://docs.python.org/3/library/os.html#os.getenv "os.getenv") uses [`os.environ`](https://docs.python.org/3/library/os.html#os.environ "os.environ"), the mapping of [`getenv()`](https://docs.python.org/3/library/os.html#os.getenv "os.getenv") is similarly also captured on import, and the function may not reflect future environment changes.
On Unix, keys and values are decoded with [`sys.getfilesystemencoding()`](https://docs.python.org/3/library/sys.html#sys.getfilesystemencoding "sys.getfilesystemencoding") and `'surrogateescape'` error handler. Use [`os.getenvb()`](https://docs.python.org/3/library/os.html#os.getenvb "os.getenvb") if you would like to use a different encoding.
[Availability](https://docs.python.org/3/library/intro.html#availability): most flavors of Unix, Windows.
what about it
Enable logic
lmfao
i dont need them?
Yes
u still have 8 errors/warnings tho
"code isn't working" -> Discontinuation of library
uh
min_lengh go hard
me beginner of py, i use vb mostly
lengh 😳
that’s the only reasonable option?
where did you get this code
that was sarcastic smh
what error are you facing?
i wrote it from a tut vid
from what year?
discord module not found
We need a bot that would lock "i am py beginner" ppl out of this channel and only let them back when they "know oop"
this year
restart your ide.
how?
there’s just needs to be a “discord bots: <1 week of looking at an ide”
what do i change
oi oi , i know py, just not discord.py
Just saying
interesfing idea
oop is just to do with classes yh
Here's how to view, open or close recently used apps on your Windows 10 device.
really pulled up with a verizon.com link
Basic oop is just classes and objects, advanced one would be like inheritance, polymorphism and other OOP principles
i see
2022-09-30 17
41 ERROR discord.ui.view Ignoring exception in view <TicketSettings timeout=None children=3> for item <Button style=<ButtonStyle.success: 3> url=None disabled=False label='Add User' emoji=None row=None>
Traceback (most recent call last):
File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\ui\view.py", line 425, in _scheduled_task
await item.callback(interaction)
File "C:\Users\PC\Desktop\Gal Cohen Bot\main.py", line 291, in add_user
await interaction.response.send_modal(AddUser(interaction.channel))
File "C:\Users\PC\AppData\Roaming\Python\Python310\site-packages\discord\interactions.py", line 851, in send_modal
params = interaction_response_params(InteractionResponseType.modal.value, modal.to_dict())
AttributeError: 'AddUser' object has no attribute 'to_dict'
inheritance is still classes from what ive seen
it's really hard. so you gotta cope, right
- Make sure that the IDE is open
- Look at the top-right corner
- You'll see a button that resembles
X - Locate your cursor
- Move your cursor to the top right corner to where the button
Xis "situated" - The
Xsymbol turns red - Left Click.
Why the hell is there instagram emoji
and you can always use that link AKG sent.
same thoughts, but we don't talk about that do we lol
hahah
actually yh weird, zuck prob payed for this
but please can soeone help me w that code
find a better tutorial :| , by the time you fix it you would have been able to rewrite it
okay thanks
ah u mean restart visual studio
reminds me of
,
:o
im dead XD
lmfao
alex is a next-gen thinker you wouldn’t understand
Collecting keepalive
Using cached keepalive-0.5.zip (10 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [1 lines of output]
error in keepalive setup command: use_2to3 is invalid.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
C:\Users###>
using replit?
?
!rule 7
7. Keep discussions relevant to the channel topic. Each channel's description tells you the topic.
._.
Guys how we can loop list items in a discord embed description?
for element in some_list:
...
I want loop that into embed description
Not this way
Can you do an example? :D
huh?
embed = discord.Embed(..., description="")
for element in your_list:
embed.description += element
that?
that's literally string con-........nvm
You tried
contractions

does any one know how to make a command that can be runned only twice by user?
Needs more context
for example
Like never run again?
yea
Use a database.
if he calls it again then the bot says out of attempts
damn ok
It depends on what you want to do.
I mean out of attempts does that mean it can get reset?
by another command yeah
Then you don't need to use a database.
how so?
Did you make the command in a class?
nope every command is separate
im not well used to cogs
I highly recommend getting started with it.
ill look into it
yeah but i have no idea how to fix it
you can't have the same custom_id for two components, reflect about it, it doesn't make sense to have the same custom_id
tried a bunch of things still wont work so came here
okay whats a custom id lets start off with that
you need to change the custom_id kwarg value of the second button
a custom id helps you to differentiate interaction event for your components
Components, aside from Action Rows, must have a custom_id field. This field is defined by the developer when sending the component payload, and is returned in the interaction payload sent when a user interacts with the component. For example, if you set custom_id: click_me on a button, you'll receive an interaction containing custom_id: click_me when a user clicks that button.
custom_id must be unique per component; multiple buttons on the same message must not share the same custom_id. This field is a string of max 100 characters, and can be used flexibly to maintain state or pass through other important data.
https://discord.com/developers/docs/interactions/message-components#custom-id
do you know how i can make it so after they click my button the bot sends another button
guys what can i do now
intents = Intents.all()
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
like that ?
Yup

And it's Intents with uppercase i
And also make sure to select some intents for it, or just use Intents.default() for default intents
anyone know how i can make my bot send another button after i click on 1 of the buttons heres my code so far
what lib are you using
do you know what is that ?
nextcord
you need to enable the message content intent in the discord developer portal
You need to enable some of the intents in dev portal for it to work
lemme check the docs
after i click buy i want it to send another button
so in your button callback you should create a button object
new_button = nextcord.ui.Button(...)
# add the button to the view with
self.add_item(new_button)
# edit the message with the new view
await inter.edit_original_message(view=self)
i did i think
remember that you should reset the view every time the init function is called
send your code
you didn't
i have a dynamic embed that can keeps bringing up errors because its too big discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body In embeds.0.fields.0.value: Must be 1024 or fewer in length. is there a way to add an embed and put the stuff that is making it go over the limit onto that
i see
Pagination.
@slate swan
ellaborate
also 1 more question
!tags
is it the same thing for just normal messages? @glad cradle cause i also want my bot to send normal messages after the button is clicked if that makes sense
@obsidian canopy
2 secs ill show a example
I've made a paginator for disnake if you're interested https://github.com/Snipy7374/disnake-ext-paginator
!tags
» defaultdict
» dict-get
» dictcomps
» docstring
» dotenv
» dunder-methods
» empty-json
» enumerate
» environments
» except
» exit()
» f-string
» f-strings
» faq
» floats
Guys why i am getting syntax error in it?
for i in counter_items:
embed.description += name=f"{self.emo.get(i)}**{i}** - {counter_items.get(i)}x\n"
I don't recommend sending error embeds tough... just fix it.
its a dynamic embed cant just fix it
@slate swan
it can vary from person to person
What the
!d str.join
str.join(iterable)```
Return a string which is the concatenation of the strings in *iterable*. A [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") will be raised if there are any non-string values in *iterable*, including [`bytes`](https://docs.python.org/3/library/stdtypes.html#bytes "bytes") objects. The separator between elements is the string providing this method.
what is a paginator lmao
Ah tf i did name =
@glad cradle where do i put it so it sends a normal message new message after the button click
heres the code
it's an embed that has multiple page, you control the pages with some buttons, paginators allow you to send a single message with "multiples embeds" (though you're not really sending all the embeds in the same moments, you're just editing the original message with the corrispondent embed) you can see it as a book
wdym? I did not understand
shall i invite to u my bot server so u can see?
will make more sense then
if it can help you yes
alright ill msg u the invite
ill look into it thanks
Does it print run?
Oh, you probably need message content intents then
make sure you enable it in your dashboard and in your code by using intents.message_content = True
it's better to only enable the ones you require. otherwise it would be a waste of resources
only enable the features your bot uses
turn off the rest of them to minimize computing power
computing power doesn't grow on trees!!
nor do computers. that's not even hypothetical, Robin
Actually...
yes, pandas grow it
still doesnt print
they probably eat them, like bamboo
it did
not run
it did
well, some pandas can't even digest those
Weak
still locked there
did you enable the intent in your code?
^
^
Intents.all()
can someone help me with reaction roles? i dont understand how to do that
Make sure you enable the intent in your code as Ashley has said
Reset your token
Now you may want to refresh your bot token
oh ok
What have you got so far? What specifically are you stuck on?
Also, any tracebacks?
and there's also an example to reaction roles in the dpy repo. you could refer to that if you haven't started and just need a basic idea ig