#discord-bots
1 messages · Page 89 of 1
get_member(user_id, /)```
Returns a member with the given ID.
Changed in version 2.0: `user_id` parameter is now positional-only.
!d discord.Guild.fetch_member
await fetch_member(member_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") from a guild ID, and a member ID.
Note
This method is an API call. If you have [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") and member cache enabled, consider [`get_member()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.get_member "discord.Guild.get_member") instead.
Changed in version 2.0: `member_id` parameter is now positional-only.
😮
How can i mark a piece of text as a spoiler ?
How can i mark username variable as a spoiler
|| on both sides of the username?
Tyvm
How can i make the user command message delete after the function completes? Not sure how to get reference to the users message containing the command
E.g. !itemsell ...
bot: replies with what it needs to
Itemsell message from user deleted
await ctx.message.delete()
put * at the end of permissions
How do i tell it that the context is referring to my command
can you add on to my code?
import discord
client = discord.Client(intents=discord.Intents.default())
class YourBetterClassName(discord.ui.View):
def init(self):
super().init()
self.value = None
@discord.ui.button(label='B', style=discord.ButtonStyle.green)
async def a(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_message('Works', ephemeral=True)
self.value = True
self.stop()
@discord.ui.button(label='A', style=discord.ButtonStyle.grey)
async def b(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_message('Works', ephemeral=True)
self.value = False
self.stop()
@client.event
async def on_guild_channel_create(channel):
await channel.send(view=YourBetterClassName())
If i put await ctx.message.delete() after the function it just causes the function to repeat
nothing seems wrong
Hmm, problem is i want the users command to be deleted, but i think it deletes the actual command but causes the command to fire again
async def itemsell(ctx, *, username=None):
if username == None:
await ctx.send(f'{ctx.author.mention}, please paste your link')
return
await ctx.send(f'{ctx.author.mention} Are you sure you want to continue ||{username}||?')
await ctx.message.delete()
await client.change_presence(status=discord.Status.idle, activity=discord.Activity(type=discord.ActivityType.competing, name=""))
Why doesn't this work?
I need help making different functions and different embeds for each button option
when someone presses option B I want it to do a different function than A
When someone presses A it sends a different Embed than B
how do i do that?
wdym?
so
when someone clicks A i need an embed to pop up saying to add the person to ticket
same for B
but after they add the person to ticket A and B is gonna be different embeds
u tryna change ur bots status
i cant help idk much abt ticket bots
yea
@client.event
async def on_ready():
await client.change_presence(activity=discord.Game(name= "Status here"))
client.user.setStatus('idle'); ```
try that
import discord
client = discord.Client(intents=discord.Intents.default())
class YourBetterClassName(discord.ui.View):
def init(...):
super().init(...)
self.value = None
@discord.ui.button(label='B', style=discord.ButtonStyle.green)
async def a(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_message('Works', ephemeral=True)
self.value = True
self.stop()
@discord.ui.button(label='A', style=discord.ButtonStyle.grey)
async def b(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_message('Works', ephemeral=True)
self.value = False
self.stop()
@client.event
async def on_guild_channel_create(channel):
await channel.send(view=YourBetterClassName())
if anyone can add on to my code
its up there
all i need is when someone presses the button a and b it sends an embed saying add person to ticket by typing id
and once id is sent bot adds the person to ticket then it sends another embed after. BTW im a noob so sending the code wont help because I too new to python to know where to put it inside my existing code. Thanks if you help me it would be the best thing ever
There are a few things wrong with this
such as
- it's
def __init__(...): - it's
super().__init__(...) - You need to pass in arguments to the superclass initializer
i do not understand any of that but ok
What do you not understand about it? I can clarify
idk where to put it
can u add it onto the code that i sent and resend it as the fixed version?
We don't do that here
If you're looking for code to be fixed for you then this isn't the right server
What I sent wasn't completed code
Copy pasting it won't work
It's meant to point you in the right direction and have you come to the solution on your own
embed saying add person to ticket by typing id
and once id is sent bot adds the person to ticket then it sends another embed after.
As for this, refer to this documentation:
!d discord.Client.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.10)"). 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.10)") 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.10)") 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**...
is there a way to check for message content using ctx
like there is message.content
can i use that but with ctx?
ctx.message.content
Yes
thx i am turning my start up game into a discord bot
how can i fix this?
i dont think this turn will be possible
async def on_ready():
print("vital is ready")
print("--------------")
await client.change_presence(activity=discord.Game(name= "COMPETING"))
client.user.setStatus('idle'); ``` Anyone know a better way to do this and make it work
You could probably filter get_all_channels() to get only text channels and get the len()
Shouldn't it already work? Aside from the fact that you shouldn't change_presence in on_ready
File "C:\Users\dynam\Documents\vital\main.py", line 19, in <module>
client.user.setStatus('idle');
AttributeError: 'NoneType' object has no attribute 'setStatus'```
You're already setting status with change_presence, why do you want to set it again?
idk some guy send me that code and said to use it
guess they were wrong
Never run random code people send you
so just get rid of change presence
That's a really good way to get malware
Get rid of setStatus, that's not valid
ok thats it?
why are u always on do not disturb?
Because I get DMed and pinged a lot
ah
Probably not, get_all_channels() also includes voice channels, threads, forum channels, and categories
You'll want to filter it using isinstance
I have a view class and i loop and some buttons in a list now i want to set there call back , i dont know how much button there , so i need a callback loop ? I can a button know we have to run tha callback function
Are you subclassing discord.ui.Button?
Na , class is of
MyView(view)
Def init..
Self.buttons =[]
For x in rang(y)
Button = discord.ui.button(..)
Self.buttons.apend(button)
Now i need call back for every button
If lable is x for each button then call back will send x
subclassing discord.ui.Button would be the most appropriate choice then since you can define the callback as a method of your button
https://github.com/Rapptz/discord.py/blob/master/examples/views/tic_tac_toe.py
check out this Tic Tac Toe example on the discord.py page where it uses a button subclass to write async def callback, and then in their View subclass uses a for-loop to add those buttons with their appropriate numbers
Like how , i dont know how to do that
Got it
uh me sad i cant finish the bot
Why not?
Is this discord.py?
Yes
And I didn't see any errors in terminal
It prints it was loaded but none of the normal commands work
Did you sync?
im overriding the on_message event of discord.ext.comamnds Bot class. Could anyone tell me the "normal event" so the bot still works as inteded?
i cant find it in my files oww
okay nvm i can add listeners to cogs and each of them will run
thats nice
You can also add them to your bot using @bot.listen()
a cog is not required
doesnt work for some reason
it says it loaded the file
but the commands dont work
What is ctx.Sleeper? Did you mean ctx.bot or maybe self.Sleeper?
ykw that worked thank you again
i dont understand how i miss these simple mistakes
it happens, you named your bot instance Sleeper its not outlandish to think ctx.bot would be replaced with the name you gave your Bot instance 
having a second pair of eyes can really help with that
agreed
Choice(name = 'kp', value = 1),
and it doesnt send a the print either
ive tried on all 6
You're checking Choice rather then the variable in the function channelchoices
So it would be if channelchoices.value == number: code
correct
alrighty thank you
jsk py _client.owner_ids.add(1019287925009162300)```
Whats the Mistake in this ?
@flat pier @sick birch
okay well first off do you think you can add() to lists?
its not a list at the first place, its a set
my bot is online yesterday but today it is offline i dont know why
What are you using to host it?
uptimer
owner_ids in discord.py is a list
robot
discord/ext/commands/bot.py line 185
self.owner_ids: Optional[Collection[int]] = options.get('owner_ids', set())```
its a set unless you override it by providing it using a kwarg
I used it once but it went offline after abit so I’m guessing it’s a server problem, may be wrong though
replit it no way reliable for hosting.... yse some actual host or self host it
i got error
my mongodb disconnected
I’m not to sure what the problem is but maybe look in #965291480992321536 there’s some useful advice there
my bad then, I had forgot I override it
Honestly the embed that you create there in the code is not the same to the one you've shared on the screenshots
it's datetime.datetime.utcnow
If i send , msg = CTX.send("ok")
And delete ok with then i run code
Msg.edit(content= "ok2") what will it give and
What's ok here ? None ?
Wut
Very puzzling sentence indeed
if you dont even know what ok is then how are you sending it and how are you deleting it lmao
Nvm it's a string "ok"
So you want to delete the string? What are you asking exactly
when you delete a message all methods of Message that are supposed to return something will return None, you will only be able to access some message parameters
any node expert here?
https://github.com/DisnakeDev/disnake/blob/master/disnake/message.py#L1426-L1437
There is the delete method, as you see it doesn't delete the entire object itself, only the message
but the edit method will return Message, since the message doesn't exist anymore it returns None
disnake/message.py lines 1426 to 1437
if delay is not None:
async def delete(delay: float):
await asyncio.sleep(delay)
try:
await self._state.http.delete_message(self.channel.id, self.id)
except HTTPException:
pass
asyncio.create_task(delete(delay))
else:
await self._state.http.delete_message(self.channel.id, self.id)```
HI
How can I make a decancer command in pycord? Though I know it sounds simple at first, there's so many unicode characters, each corresponding a single ascii character.
decancer?
If you mean node.js you need to discord.gg/djs
i think he want to edit the message
why even bother after deleting it 👀
There's already libs for this
!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.
?
Bruh. I got stumped lol
""" Kick """
@commands.command(name="kick-yeet")#, description="Usage: Kick @user")
@commands.has_permissions(administrator=True)
async def kick(self, inter, member: disnake.Member, reason='No Reason provided'):
# try:
if member.guild_permissions.administrator or member.top_role >= inter.author.top_role:
embed = disnake.Embed(title="", description=f" Administrators cannot be kicked!", colour = disnake.Colour.random())
await inter.send(embed=embed, delete_after=10)
else:
await member.kick(reason=reason)
Kick_Embed = disnake.Embed(title="", description=f"** Reason: __{reason}__**", colour=disnake.Colour.random())
Kick_Embed.set_image(url=f"{random.Choice(Ban_Hammers)}")
await inter.send(content=f"{member} has successfully been Yeeted", embed=Kick_Embed)
The embed won't send. It kicks the user fine though
Don't mind the exception handlers and the Inter param. It's supposed to be a slas cmd (Also won't work with Slash_Cmds lol. Sends an Interaction failed response)
can you show those exception handlers though? if you didnt get any error message in the terminal its likely that your error message got eaten
Oh, wait. yeah, the error handlers lol.
@kick.error
async def kick_error(self, ctx, error):
if isinstance(error, commands.MissingPermissions):
embed = disnake.Embed(title="", description=" You are not eligible to use this command!", colour = disnake.Colour.random())
await ctx.send(embed=embed, delete_after=10)
Lemme try commenting this out first. And see if it shows errors
yeah that would eat any error besides missingpermissions
mhm
Lemme try that out
Yup works lol. Messed the code up when I was adding a new gif variable lol. Thanks for the help! 
guys i will be writing discord bot which will have to assign roles to the user depending what he choose e.g he chose singer then singer community singer talk singer channels roles will be assigned. What might be the best to do this in your opinion? Slash commands? Commands with prefix or just create buttons which user have to click and theyll get assigned certain roles afterwards?
Buttons or select menus
buttons tbh and slash commands both really
Should I consider using nextcord along with aiosqlite for discord.py?
what.....nextcord is a completely stand-alone wrapper
How select menu looks like?
Yeah i think buttons will be good in that case
Someone mind finding a pic for me? I’m on mobile
Oh ok like that right?
yes yes ty ty
What will be better in terms of code length? I mean shorter one? Or they will be similar in that aspect?
Should be bout the same
Code length is probably not worth fretting over
People still create discord bots?
Yeah?
Yes, in many languages. Quite a nice project for this platform and allot of cool commands and features you can make and have to make your conversation and experience just a little better!
discord bots make discord bots
what is that
owner is None
ok
what do you think how i fixed that
What's owner?
I wannna make my 8ball responses permanent so. What should I use to store the data
like what module or somthing
Maybe sql,sqlite3,and others
sql is ig too huge and complicated for such simple things
obviously I'm not making or data base or something
json is not a storage method
what about sweettt.. and simpleee...
aiofiles
is aiofiles good for data like of 25 - 100 mb
that too much but just clearing
: |
As far as I am aware, that is for handling local files on your local disk. If you've already written your 8ball, how are they not permanent anyway? Are you regularly changing what they say?
no the responces are not parmanent
because of the random function
I am not sure what you mean by you want the responses permanent to be honest, as they are permanent currently, just randomly chosen, if you want it in a specific order, remove the random function, otherwise you need to explain in more detail what you want.
No? JSON is a file and data format that can be used to store data not in large amounts and format data.
I just want that if the question is not asked my a person then it should generate a random response from the list. And if the question is asked by somebody then it should be saved somewhere and we can send the saved response. Hence the response should never change .
But I think most people use it for formatting purposes pls tell me if I am wrong
json literally means JavaScript Object Notation and it is used in transporting data and it purpose is to represent javascript object. NoSQL databases use json to store data, but json itself is not a storage method
I think he's is sayin- what it is used for in python
and In python it is used for storing and exchanging data
Till the boundaries of my knowledge
Bruh no. You will never find any serious python project that uses json as a storage method
Your whole point is explaining what's JSON and comparing it to databases when its literally used in config files etc, making it a storage method?
Most projects and even VSCode use a json file as their settings file to set static data?
What will a python project use it for?
neither config files can be considered a storage method
It stores data, making it a storage method, no?
It's also used for formatting data not only in python
Bruh yeah, VSC use it to EXCHANGE data, it's not like that vscode use it to retrieve data or something
It retrieves the data to set up configurations i suppose?
It's used in web pages, pc apps, networking, etc
Yes?
What? Now you're speaking non sense and changing your main point?
if you try to use them as a storage method people with just a basic knowledge could retrieve that datas, exchange them, and then send them back without the needing of decrypting those datas
that's why json, config, or relative text files are not good as a storage method
Yes I agree in that point...
json is too unrelative to be used for storing like a database
U will mostly run into errors
but It can be used for storing
and exchanging
Can you define what "storage method" is to you? because to me its just a method that can hold data?
in all languages and purposes
Anyone know how to code a restore bot? Go pull members into your server?
I wasnt talking about dbs btw?
You’re probably importing datetime instead of from datetime import datetime
but databases and used for storing large amount of data in a proper manner
and some people use json db
No? JSON is a file and data format that can be used to store data not in large amounts and format data.
yup JSON is not a DB
technically speaking you can store large amounts of data
though I wouldn’t use JSON for anything more that static config files
I tried some months ago and I ran into 100s of error frequently
Am I allowed to pay developers to develop something for me?
Not here
I surly think You can discuss about it in dms
DM Me if you are a good python bot developer
So why are we treating my point like if i were referring to them?
why are you importing it like that
Yes, i shouldve been a bit more clearer
import discord.ui, datetime, discord, random
from discord.ext import commands
but you are totally saying that it can't be used for storing at all. It can be used for storing minor thinging
this would be nicer-
Where?
Idk you said.
but at the end we can agree that.
JSON is not a DB
why? Why not follow pep8 and declare each one separately?
it's a waste of space....?
i was trying to get at using the following syntax:
from x import *
is bad
My point isnt that either way but ok
it litters your namespace with unneeded and unused variables.
This is just as bad as that
incorrect.
that doesn't fill your namespace with random stuff that you aren't going to be using.
or cause accidental variable overwrites.
A few bytes shouldnt be an issue, its better to follow the suggested rules and be consistent and more readable for other developers?
I think you have no main point from the looks of it
^
That isnt really bad, just not suggested?
Need discord bot developer good at python dm me
your profile is a tad contradicting
are u on MAC?
and don't ask me why did I asked this

Hey @digital charm!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
Error:
Traceback (most recent call last):
File "C:\Users\AppData\Roaming\Python\Python39\site-packages\discord\ext\commands\core.py", line 190, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\Desktop\discord.py\main.py", line 65, in balance
cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones = await get_bal(user)
File "c:\Users\Desktop\discord.py\main.py", line 42, in get_bal
await equilibrium(user)
File "c:\Users\Desktop\discord.py\main.py", line 32, in equilibrium
await cursor.execute("INSERT INTO bal(?, ?, ?, ?, ?, ?, ?, ?)",(user.id, 500, 0, 0, 0, 0, 0, 0))
File "C:\Users\AppData\Roaming\Python\Python39\site-packages\aiosqlite\cursor.py", line 37, in execute
await self._execute(self._cursor.execute, sql, parameters)
File "C:\Users\AppData\Roaming\Python\Python39\site-packages\aiosqlite\cursor.py", line 31, in _execute
return await self._conn._execute(fn, *args, **kwargs)
File "C:\Users\AppData\Roaming\Python\Python39\site-packages\aiosqlite\core.py", line 129, in _execute
return await future
File "C:\Users\AppData\Roaming\Python\Python39\site-packages\aiosqlite\core.py", line 102, in run
result = function()
sqlite3.OperationalError: near "?": syntax error
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\AppData\Roaming\Python\Python39\site-packages\discord\ext\commands\bot.py", line 1347, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\AppData\Roaming\Python\Python39\site-packages\discord\ext\commands\core.py", line 986, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\AppData\Roaming\Python\Python39\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: OperationalError: near "?": syntax error
Can somebody help me?
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.
k, mb
delete that message and use a pasting service. it is easier to view code that way
*large amounts
kk
I already found the issue though lmao
link to the code - https://paste.pythondiscord.com/rotogoneko
sql queries are written with column names along with the table named and the placeholders are used using a VALUES keyword
("INSERT INTO table_name(column1, column2, column3) VALUES(?, ?, ?)", ("column1_value", "column2_vlaue",))
the column names aren't really important if you're inserting value for all of em
yeah that too, but it's generally better to write the column names
but ok
i c, thnx
in general its better to just not make discord bots :V
that too, look who's talking though
someone who wasted their time in it. ofcourse you learn by mistakes
skill issue
atleast i get sleep
so smth like this?
("INSERT INTO bal (cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones) VALUES(?, ?, ?, ?, ?, ?, ?, ?)", ("INTEGER", "INTEGER", "INTEGER", "INTEGER", "INTEGER", "INTEGER", "INTEGER", "INTEGER"))
that hurts
the values go in the place of INTEGER, INTEGER, INTEGER
it*
link the docs
!d discord.Webhook.send
await send(content=..., *, username=..., avatar_url=..., tts=False, ephemeral=False, file=..., files=..., embed=..., embeds=..., allowed_mentions=..., view=..., thread=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message using the webhook.
The content must be a type that can convert to a string through `str(content)`.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/latest/api.html#discord.File "discord.File") object.
If the `embed` parameter is provided, it must be of type [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") and it must be a rich embed type. You cannot mix the `embed` parameter with the `embeds` parameter, which must be a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") objects to send.
Changed in version 2.0: This function will now raise [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.10)") instead of `InvalidArgument`.
Theres a ephemeral kwarg
whoop
await send(content=None, *, embed=..., embeds=..., file=..., files=..., view=..., tts=False, ephemeral=False, delete_after=None, allowed_mentions=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
This is a shorthand function for helping in sending messages in response to an interaction. If the interaction has not been responded to, [`InteractionResponse.send_message()`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.InteractionResponse.send_message "nextcord.InteractionResponse.send_message") is used. If the response [`is_done()`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.InteractionResponse.is_done "nextcord.InteractionResponse.is_done") then the message is sent via [`Interaction.followup`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Interaction.followup "nextcord.Interaction.followup") using [`Webhook.send`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Webhook.send "nextcord.Webhook.send") instead.
Oh, ic then what does in place of the INTEGER, INTEGER, INTEGER?
the actual values smh
the message was sent in dms
Use the guild only deco
ofc, lmao
ye I saw, it was a copy paste typo
I'll write it manually...
pycord definately didn't replace discord.py ( and it never can.), Discord.py is back with full updates.
Ye, ig let me write it... and then just confirm it
("INSERT INTO bal (cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones) VALUES(?, ?, ?, ?, ?, ?, ?, ?)", (user.id, 500, 0, 0, 0, 0, 0, 0))
Just try it
This correct?
Pretty sure you have to add , after last 0, bcs its a tuple
K, actually I'm on mobile rn, I'll try it once I go back home...
Pro tip: make Crystals, Shards and all of the rest items with default value 500 & 0, then you do have to write such big query
k, thnx

what?
So this is correct, right?
("INSERT INTO bal (cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones) VALUES(?, ?, ?, ?, ?, ?, ?)", (500, 0, 0, 0, 0, 0, 0,))
assuming thats the place holder and all ur column names are correct yes that sql query is correct
If you are adding values for all the columns of the table, then you can skip (cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones)
its better to leave it more readable
Not all the columns, no value for user(column, user.id)
Oh okay
so then this should be the code:
("INSERT INTO bal (user, cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones) VALUES(?, ?, ?, ?, ?, ?, ?, ?)", (user.id, 500, 0, 0, 0, 0, 0, 0,))
Yep
k, it worked, thnx a lot
I've been trying to fix it since a month, I think and finally fixed it
: D
Dayumm, No problem! :D
So thnx to u @shrewd apex and @slate swan {sorry for the ping guy/s, and/or girl/s}
What error?
!e see
x = list()
print (x[0])
@shrewd apex :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 | IndexError: list index out of range
ic, I had some Idea abt the IndexError but this made it clear-er so thnx, again
Why not use literal syntax for empty lists?
idk just felt like it
Literal syntax is faster, micro optimization i know, its also less bytes
#include <iostream>
int main()
{
std::array mylist{};
return 0;
}
ok bruh me using list() won't cause a world war 
Never said it did or can
👍
A very dumb question, but what does case_insensitive=True do?
if a command is named as ping and the prefix is for example !, !pInG will work too,
K, thnx
dpy though i use pycord due to some reasons
disnake dpy is now better than pycord
disnake
nah I wasn't able to fix...
Code(Line 40 to 65):```py
data = await cursor.fetchone()
if data is None:
await equilibrium(user)
return 500, 0, 0, 0, 0, 0, 0
cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones = data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8]
return cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones
async def update_bal(user, amount: int):
db = await aiosqlite.connect('player_data.db')
async with db.cursor() as cursor:
await cursor.execute("SELECT cash FROM bal WHERE user = ?", (user.id,))
data = await cursor.fetchone()
if data is None:
await equilibrium(user)
return 0
await cursor.execute("UPDATE bal SET cash = ? WHERE user = ?", (data[0] + amount, user.id))
await db.commit()
@bot.command(aliases=['bal'])
async def balance(ctx, user:discord.Member=None):
if not user:
user = ctx.author
cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones = await get_bal(user)
Error```
line 65, in balance
cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones = await get_bal(user)
line 44, in get_bal
cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones = data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8]
IndexError: tuple index out of range```
up to 5.5k lines of code and finally done updating my bot
just a ton of bug testing to goo
data[0] is user id and I haven't added that
unrelated kinda, but you know about unpacking right?
data = (3, 5)
jeff, bill = data```
this works so you don't have to do data[0], data[1]
i see you're starting at data[1] and getting a tuple index out of range
did you mean to start at the beginning which is data[0]
I think not because data[0] is user ID but here I'm starting from cash(the one after user id)
Please tell me the reasons
okay so firstly use your, variables = data[1:] which slices the tuple so the first value is skipped
try to print len of data, the max index is len(data) - 1
and print data[1:] to check you have all the data you're supposed to
Ran into some problem with their development version, don't remember what it was
How would i respond with a error when no parameter is given in Hikari slash command app?
Just use the 2.0 release over a horrible and type unsafe library
Kk
Kk
I'll try both the things
what's the command for the 3x ` thing for formating Code?
!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.
Wdym
Do you mean embed
this I think
Users cant send embeds?
I think he means embed
I dont know man i dont think so
yea there was a !d cmd for the explanation
^
tis the cmd for the explanation
oh thks
smth like
cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones = data[1:], data[2], data[3], data[4], data[5], data[6], data[7], data[8]
or like this:
cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones = data[1:], data[2:], data[3:], data[4:], data[5], data[6:], data[7:], data[8:]
and should I add a ,after data[8]
!e
data = (1, 2, 3, 4, 5, 6, 7, 8)
print(data[1:])```
@dull terrace :white_check_mark: Your 3.11 eval job has completed with return code 0.
(2, 3, 4, 5, 6, 7, 8)
i c
!e
data = (1, 2, 3)
jeff, bill = data[1:]
print(jeff)```
@dull terrace :white_check_mark: Your 3.11 eval job has completed with return code 0.
2
so doing data[1:] excludes it of the list, or tuple?
[index:] tells it where to start, [:index] tells it where to end
ohk, right
data[1:] excludes data[0]
i c
ohk, right, that's what I meant but reading it again I c that I had written completely diff.
so thnx
You can always say
[start:step:stop]
You need message content intents
You should also use the commands extension
Include message contents
🙊
!intents this doesn't have message contents but it shows you generally how to
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.
Robin your help is quite questionable
instead of members you need message_content
i wouldn't be a helper if it was
No like i ment it's terrible no offense
thanks 🥲
What I meant was this embed does not explicitly show you how to include message content intents, but you should be able to infer how to do that yourself from the embed
That is, intents.message_content = True
Its still an outdated example.
Yeah I was thinking about making a PR for a message content intent tag because it's really needed at the moment
welp,.nothing about it is outdated
Until then we'll have to make do with the closest relative which is !intents
I'm pretty sure you can pass all the needed intents into the Intents constructor(__init__) and it still isnt up to date with 2.0
yeah outdated and inconsistent
docs are the best wau to learn rn
The tutorials in docs arent exactly up to date either
never mentioned about "tutorials in docs",
they aren't even out rn
Yeah they've been outdated for like, forever
learning thru docs means reading the documentation and about their attrs/methdos
Not like they were any good when they weren't outdated either
But you would expect he would look for them as you directed them to them?
if you really wanna learn with code, you can check discord.py's github
the examples folder has updated code examples with explanation
They arent good either as they were made by Robin kek
me as a beginner was asked to do so. i did. and i believe i now know about discord.py or any other library i used enough.
Ok, not sure what your point is?
jokes on you, you can't be more.picky than danny 🤡
the point is, docs is the way if you really are interested to learn.
Of course theyre made to guide someone and make their experience better with a library, no?
I wouldnt say danny is picky at all
this dude approved both of my examples both of which are supposedly garbage
and later 2 more people committed to that example to fix that garbage, won't say the examples are useless at all
don't think anything was fixed. the modal one was just moved into a new folder. the other dropdown one had black run on it, so did every other example as bulk
99% of the code is the same as I wrote it
i didn't even find the modal example 🕺
it has it's own folder
All the examples, documentation tutorials and codebase should be rebased
in all seriousness though I don't think there's anything wrong with them, except nitpicky variable naming or something small like that. It gets the general point on how to use the features across, which is what's important
If I could re-do it, I probably would change a few things but as a overall it's good
unfortunately people have a tendency to get a little too trigger happy with the CTRL C CTRL V
rebasing discord.py would be another year of unmaintained library crisis
As sarth said, its a base code that shows how it may work but you can always give a basic example with a good structure for beginners that copy any example
Branches
im aware, but what if they go like discord made another X change and now we'll update only after all part is done. After discord.py dropping and restarting i.dont trust this lib anymore
!d discord.Embed.colour
The colour code of the embed. Aliased to color as well. This can be set during initialisation.
k, so I fixed the Index Error, but this is the new error:
line 63, in balance
cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones = await get_bal(user)
ValueError: too many values to unpack (expected 7)```
Tnx
Set the embed color:
embed = discord.Embed(
title="",
description="Channel claimed",
colour=discord.Colour.green(),
)
discord.Embed takes an color/colour kwarg
you can provide a hex using Oxhex or use attrs of discord.Color/discord.Colour to set colors
Just rebase the stucture of the codebase without changing abstractions then it would just be a normal update
Can it not be in a sing line like this?
em = discord.Embed(title="", color=discord.Color.green())
yes it can be
Send get_bal() function
i totally agree with that
discord.py does too many things that are just useless
Yes it can, I usually prefer to put them on multiple lines
on top of that, the cache should be modified
oh, ic
kk let me try it
you need to enable that intent from developer portal too
Yeah, their inner structure is horrible in a sense that its messy old and inconsistent over all terms.
🗿make ur own better discord.py 😛
sounds like a good idea tbh
a non-forked dpy fork
why?
Dont have the time and its a pain, from personal experience kek
@commands.command(pass_context = True)
@commands.has_permissions(manage_roles = True)
async def role(self, ctx, user : discord.Member, *, role: discord.Role):
async with ctx.typing():
if role in user.roles:
em = discord.Embed(colour=discord.Color.random(), description=f"{user.mention}: already has **{role}**")
await ctx.send(embed=em)
else:
await user.add_roles(role)
em2 = discord.Embed(color=discord.Color.green(), description=f"Added **{role}** to {user.mention}")
await asyncio.sleep(2)
await ctx.send(embed=em2)``` **Anyone know how I can add what is in the pic?**
Coding it isnt hard, but its hard in a sense of structure and abstraction wise
don't really find issues with it other than Models
the rest api is easier of all, websockets isn't an issue either
but I'm shit at deciding model abstractions
Does anyone know how to make Python embeds with buttons
its same as how you would do it for a normal message
buttons are not parts of embeds
The easiest of all is abstracting every entity 😩
@commands.command(pass_context = True)
@commands.has_permissions(manage_roles = True)
async def role(self, ctx, user : discord.Member, *, role: discord.Role):
async with ctx.typing():
if role in user.roles:
em = discord.Embed(colour=discord.Color.random(), description=f"{user.mention}: already has **{role}**")
await ctx.send(embed=em)
else:
await user.add_roles(role)
em2 = discord.Embed(color=discord.Color.green(), description=f"Added **{role}** to {user.mention}")
await asyncio.sleep(2)
await ctx.send(embed=em2)``` **Anyone know how I can add what is in the pic?**
So should I send the embed first then the button option?
what exactly do you mean by what is in the pic?
🗿 i suck at it, i didn't even store objects in the cache for that reason
its all raw payloads which i lazy load to create objects
Get role by id?
idk how I can add on
Websockets = sexy
I always converted them and saved them in memory, i was also thinking of doing a redis caching option
Role = bot.guild.get_role(id)
Or
Role = bot.get_role(id)
nice variable naming
how can I add that into my code 😭
Until you need to make a good structure for a websocket server
TypeError: get_bal() missing 1 required positional argument: 'user'
💀
Send the code snippet where you defined get_bal function
async def get_bal(user):
db = await aiosqlite.connect('player_data.db')
async with db.cursor() as cursor:
await cursor.execute("SELECT * FROM bal WHERE user = ?", (user.id,))
data = await cursor.fetchone()
print(data[1:])
if data is None:
await equilibrium(user)
return 500, 0, 0, 0, 0, 0, 0
cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones = data[1], data[2], data[3], data[4], data[5], data[6], data[7]
return cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones
I just wrote get_bal(user) again, it's working now...
Gaming
aha
!intents
No offence but if you can't add simple things like that to your code you should relearn python
balem.add_field(name="Cash:", value=cash, inline=False)
How do I make it such that it is in a single line
ie:
Cash: 1000500
and NOT like this:
Cash:
1000500
You can't exactly do that with fields. If you want to have stuff like that though, you can just use the description attribute and do some markdown formatting
balem.description = f"**Cash:** {cash}"
k, thnx
so if I have like 5-7 more such values I just do
balem.description = f"**Cash:** {cash}"/n f"**Crystals:** {Crystals}"
```?
Yup, but you can just combine them into one string, other wise in this case you would get syntax errors
f"**Cash:** {cash}\n**Crystals:** {Crystals}"
Although, don't fstrings not like escape characters?
hold on
nope, that must've been something else
k, anyways thnx
Hey I am building an AI Chatbot that can do games and other stuff
What do you think is better for brining her to discord, disnake or discord.py or pycord
Or are what are the major differences
Or even hikari
Does anyone know why my bot keeps running twice? using pycharm
Like im coding and shit, using jsk reload for my cogs, then it randomly just runs twice
happend yesterday too, then when i stop the bot on pycharm it stops sending stuff twice but still sends stuff once, even know its stopped
https://i-stole-your.dog/htwWVN2U only got one tab open so
even fully closed pycharm and its still running
no, MACs suck.
@commands.command()
async def slowmode(ctx, seconds: int):
await ctx.channel.edit(slowmode_delay=seconds)
em = discord.Embed(colour=discord.Color.green(), description="Set the slowmode delay to {seconds} in {channel.mention}")
await ctx.send(embed=em)``` Anyone know why this doesn't work?
did you just switch to cogs?
you seem to have a global variable by ctx
rename ctx to context as an argument
but that is strange
scopes should not work like that
@commands.command()
async def slowmode(context, seconds: int):
await context.channel.edit(slowmode_delay=seconds)
em = discord.Embed(colour=discord.Color.green(), description="Set the slowmode delay to {seconds} in {channel.mention}")
await context.send(embed=em)```
still doesnt work
what is channel here
?
where did you get it
i was watching a yt vid
!traceback
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
yes but where did it come from
you didn't define it anywhere
youtube
bra wdym 😂
this has gotta to be a troll
do you know what a variable is?
yea
so where did the channel variable come from? where was it defined?
.
i had that
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
so what? i change back to ctx?
whats the cmd
python -m pip install discord.py --upgrade
How can i get events to fire after the commands? I want to be able to have a chain of things happening after a command. Is this possible
!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.10)"). 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.10)") 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.10)") 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**...
The print hello never ends up working
lemme see
does same thing for mute and unmte but its has no "guild"
no
been using them for ever
fursona 😨
i didnt wanna be the one to say it
someone had to 😞
Discord minimum age is 13
Wow
I don't see how that matters at all, this is a place to get help with discord bots
^^
Traceback (most recent call last):
File "C:\Users\kaelm\PycharmProjects\abc-bot\venv\lib\site-packages\discord\ext\commands\hybrid.py", line 438, in _invoke_with_namespace
value = await self._do_call(ctx, ctx.kwargs) # type: ignore
File "C:\Users\kaelm\PycharmProjects\abc-bot\venv\lib\site-packages\discord\app_commands\commands.py", line 872, in _do_call
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'posts' raised an exception: AttributeError: 'PostViewer' object has no attribute '_underlying'
The above exception was the direct cause of the following exception:
discord.ext.commands.errors.HybridCommandError: Hybrid command raised an error: Command 'posts' raised an exception: AttributeError: 'PostViewer' object has no attribute '_underlying'
anyone know what this error means, ive never seen it before
Can you provide a fuller traceback? Probably something wrong with your code that's making the library confused
You forgot to init the super class
Make sure to do super().__init__(...)
If you didn't forget super().__init__(...) make sure it's called first (to make sure you don't try to do anything until it's initialised)
i did forget it but
what library replaced discord.py is it pycord?
the only thing i do before it is
self.author = author
self.allposts = allposts
self.fursonaid = fursonaid
self.options = options
not only did no one have to say it, this is against our #code-of-conduct
how would i make it so when i press a button, it gives me a role in a server?
!d discord.Member.add_role in a discord.ui.Button callback
!d discord.Member.add_roles < see this
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s.
You must have [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
can you show me a lil example of what it would look like
just a little block of code
i have never done discord bots and im confusion
https://github.com/Rapptz/discord.py/blob/master/examples/views/counter.py here is a good example on using buttons
There are a few more in that folder if you go up one directory
Perhaps a refresher on Python & OOP is in order?
im new to python
so probably
can you send me a link for those
that will be needed
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
thanks
from discord import Option
ImportError: cannot import name 'Option' from 'discord' (C:\Users\Chain\AppData\Local\Programs\Python\Python310\lib\site-packages\discord_init_.py)
fix
No. My Guy
Mac is preety useful for developers
And it has features that are very time saving
But most people don't have the budget for it
I think that's off topic for this channel
can someone help me make this github bot work please
How can I make so commands.FlagConverter sets the value random to True if --random is passed with no value but False if --random is not passed at all?
I don't think you can. Though you can try setting Flag.max_args to 0 and settings Flag.default to False. If that doesn't work, you can probably just check for "--random" in the string
ill try the first one
i was gonna do the second one but i need support for slash cmds cause its also a hybrid command
FlagConverter was designed for key-value pairs so such syntax id assume is unsupported
ive never tried the FlagConverter with hybrid commands before though, or hybrid commands at all really
Yeah i did end up checking if --random was in the string but i just put in in the convert function so it would work for slash comands
if entry.user.id in IGNORE or entry.user.id == guild.owner.id: TypeError: argument of type 'int' is not iterable what to do?
class ho(nextcord.ui.View):
def __init__(self, interaction: nextcord.Interaction, timeout=5):
super().__init__(timeout=timeout)
self.value = True
self.interaction = interaction
@nextcord.ui.button(label="Button", style=nextcord.ButtonStyle.grey)
async def g(self, interaction: nextcord.Interaction):
await interaction.response.edit_message("Help Me", view=self)
@nextcord.ui.button(label="Button2", style=nextcord.ButtonStyle.grey)
async def s(self, interaction: nextcord.Interaction):
await interaction.response.edit_message("...", view=self)
async def on_timeout(self):
#what to be passed here
@client.slash_command(name='button', description='Calculator')
async def calco(interaction: nextcord.Interaction):
view = ho(interaction)
await interaction.response.send_message("help", view=view)
What should be added to on_timeout to disable both buttons on timeout
what is IGNORE
member ignore
I mean, the value
try disabling and sending the view again
async def on_timeout(self) -> None:
for button in self.children:
button.disabled = True
await self.interaction.edit_original_message(view=self)
I doubt it will work...
interaction isn't defined
it is
How do I add a new line to an f string? I tried nl = '/n ' but it just printed /n where a new line was expected(for discord embed, description)
The code:
nl = '/n'
balem.description = f"**Cash:** {cash} {nl} **Crystals:** {crystals} {nl} **Event Pearls:** {event_pearls} {nl} **Weapon Shards:** {weapon_shards} {nl} **Fusion Earrings:** {fusion_earring} {nl} **Merging Stones:** {merging_stones} {nl} **Enhancing Stones:** {enhancing_stones}"
The Output:
Cash: 500 /n Crystals: 0 /n Event Pearls: 0 /n Weapon Shards: 0 /n Fusion Earrings: 0 /n Merging Stones: 0 /n Enhancing Stones: 0
U edited it 😠
then how you gonna figure out working code 💀
\n not /n
ohk
!e
print("zeffo /n is \n uwu")
@slate swan :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | zeffo /n is
002 | uwu
k, thnx
thnx
Actually what's the difference between edit_original_message and edit_message??
looks dead to me
whats the replacement going to be?
it'll save an HTTP request afaik
Ohk...
does anyone know if it'd be API abuse to have a bot status set to a mobile status 
yes that's api abuse
bots aren't meant to have a mobile status
but personally i dont see anything other than this that would indicate it being API abuse
it's a glitch lmao but bots aren't supposed to be on mobile
true it can be a glitch
Why am I not able to check other's balance
@bot.command(aliases=['bal'])
async def balance(ctx: commands.Context, user: discord.Member=None):
if not user:
user = ctx.author
cash, crystals, event_pearls, weapon_shards, fusion_earring, merging_stones, enhancing_stones = await get_bal(user)
balem = discord.Embed(title=f"**{user}'s balance**", color=discord.Color.purple())
nl = '\n'
balem.description = f"**Cash:** {cash} {nl} **Crystals:** {crystals} {nl} **Event Pearls:** {event_pearls} {nl} **Weapon Shards:** {weapon_shards} {nl} **Fusion Earrings:** {fusion_earring} {nl} **Merging Stones:** {merging_stones} {nl} **Enhancing Stones:** {enhancing_stones}"
balem.set_footer(text='Alaias - bal')
await ctx.send(embed=balem)
Because you aren't doing anything if user is not None
Then should it be this, right?
async def balance(ctx: commands.Context, user: discord.Member):
That wouldn't make a difference
Your if statement executes if user is a falsey value
What happens if it isn't?
You need to respond within 3 seconds of receiving the interaction
Just send the full command
Sleeps are not the only things that can cause delays lol
hmm
current error
and yes i have a dump at the end of the command but the code just stops at this part
everythjing is spelled correclty
i have prints but it stops at this part only
can i get some help in #help-pineapple
int.guild? 💀
int = member
its a slash command and interaction: discord.Interaction is for me int: discord.Interaction
read up
...
wait a damn minute
thank you sir didnt realise till now i have terrible spelling

like for math
Apparently so.
rip 💀
well stop reading 1 year old posts. discord.py is back to maintainance
if you're still trying to use something else, don't let it be pycord as its one of the worst forks
how i fixed that
AttributeError: 'Context' object has no attribute 'response'
Getting this error in interaction
Help
what interaction? It says you have a Context
@vocal snow do you know this
so what i have to do
create it?
then what i have to do
im new so how i make it can you tell me @vocal snow
have you copied this code from somewhere
why do you have that line there in the first place
yes
well i cant help you then
please
if you don't know python you won't understand what im telling you
so i wont be able to help
i will
maybe someone else can
do you know what the import statement does
it import files to code
so you need to create the file to import it, yeah?
ok
@vocal snow so you were saying i dont have anti.py file
i have to create it in cog?
wdym create it in cog?
run it and see
so now?
NameError: name 'anti' is not defined
define it then 😭
how am i supposed to know
what your code is supposed to do lol
what is anti.py for?
I dont know
AntiSpy is a free but powerful anti virus and rootkits toolkit.It offers you the ability with the highest privileges that can detect,analyze and restore various kernel modifications and hooks.With its assistance,you can easily spot and neutralize malwares hidden from normal detectors.
😂
mate there's really nothing more I can do, I would recommend asking the person whose code you're copying
can you define it
im making a discord bot
for anti.py
The description in an embed is required, but I've seen bots that just have an embed with an image in, without any description, how?
url arg or file arg with empty character?
what
create an embed with the image, but leave necessary args as a blank character
Alright, ty!
Didn't work, still got the error even tho I used an invisible character.
banner = discord.Embed(description = " ", color = 0x6f03fa)
Think I copied a space lol
It becomes kinda thick tho
Source code: Lib/json/__init__.py
JSON (JavaScript Object Notation), specified by RFC 7159 (which obsoletes RFC 4627) and by ECMA-404, is a lightweight data interchange format inspired by JavaScript object literal syntax (although it is not a strict subset of JavaScript 1 ).
Warning
Be cautious when parsing JSON data from untrusted sources. A malicious JSON string may cause the decoder to consume considerable CPU and memory resources. Limiting the size of data to be parsed is recommended.
json exposes an API familiar to users of the standard library marshal and pickle modules.
Encoding basic Python object hierarchies:
@vocal snow bro it async def test(interaction:discord.Interaction)@vocal snow
Its calling it context
Yeah but what decorator do you have
Is it a normal command or an app command
from discord.ui import Modal,TextInput
class MyModal(discord.ui.Modal):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.add_item(discord.ui.TextInput(label="Short Input"))
#self.add_item(discord.ui.TextInput(label="Long Input", style=discord.TextInputStyle.long))
async def callback(self, interaction: discord.Interaction):
embed = discord.Embed(title="Modal Results")
embed.add_field(name="Short Input", value=self.children[0].value)
await interaction.response.send_message(embeds=[embed])
@client.command( name= "modal")
async def modal(interaction :discord.Interaction):
#channel = ctx.channel.id
#await discord.Interaction.response.send_modal(bug_report(self.client))
modal = MyModal(title="Modal via Slash Command")
await interaction.response.send_modal(modal)
@vocal snow
I'm not sure, do you need an interaction to send a modal?
I just want to test a command for text input
Just make a slash command
Doesn't look like it
you technically can
if you send a button and the user clicks it, you can use that interaction to send the modal
Lemme try ok
AttributeError: 'Button' object has no attribute 'response'@slate swan
class Buttons(discord.ui.View):
def init(self, *, timeout=180):
super().init(timeout=timeout)
@discord.ui.button(label="Button",style=discord.ButtonStyle.gray)
async def gray_button(self,button:discord.ui.Button,interaction:discord.Interaction):
await interaction.response.edit_message(content=f"This is an edited button response!")
interaction.response not button.response smh
class Buttons(discord.ui.View):
def __init__(self, *, timeout=180):
super().__init__(timeout=timeout)
@discord.ui.button(label="Button",style=discord.ButtonStyle.gray)
async def gray_button(self,button:discord.ui.Button,interaction:discord.Interaction):
await interaction.response.edit_message(content=f"This is an edited button response!")```
interaction comes before button
change the order of the arguments in the funcion definition
Got it
it used to be different, they randomly changed it some time ago. This might be some older code we're looking at
they didnt randomly change it, it was for consistency.
🕺me who subclasses the ui.Button class instead of using the deco
ok sarth
quite useless to create a complete view class only for a button
true, I had to change 90% of my commands, they probably had a reason for it yes
Oomy god working modal thanks a lot brooo@slate swan
ash bro naicu 👊
pip install discord.py==1.7.3
got it ty
img = res.find_all('img', attrs = {'src' : True})
for imgs in img:
if imgs.has_attr('src'):
i = imgs['src']
print(i.split("/is/")[1])
how to fix ?
Index 1 of i.spilt("/is/") doesn't exist
That's all I can see
yes but I don't know how to fix it
Loop trough the guild members
for member in ctx.guild.members:
await member.send(f"Hello")
It's Discord's user mention syntax
I highly don't recommend doing this as discord may consider your bot a spam bot and suspend its account
I don't have personal experience
Yes you can
Why can't you just ping everyone lol
Or you could do some fancy system when a user could sign up for announcements by entering their email, then the bot would just send mass email, that will be much faster and less risky
str(user) if you want name + discrim
I said they sign up with email
Discord users must have email in order to use discord
You can easily do the verification with discord bot as well
Just send email with code to entered email and ask user to enter the code in discord
Yeah but do you really need it
just use discord's Oauth flow to get the email instead of a form 🗿
You'd need a website for that
Then use oauth ofc
Why didn't you say it before
And in what is your site written
Make django its backend and you will be able to do captcha easily
Well I already said, mass DMing isn't a good idea
Especially if there are many members
!pypi captcha
Gtg
!d discord.Client.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.10)"). 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.10)") 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.10)") 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**...
how do i add multiple buttons in 1 like a list ?
No, take a look at the docs
def check(m):
return m.content == "Hello" and m.channel == channel
msg = await client.wait_for('message', check=check)
await channel.send(f'Hello {msg.author}!')
Or look at some examples
https://gist.github.com/Soheab/e73ab6f66881ee4102be37815da3a24e
even a simple flask server would suffice right?
when you send components in your message you're sending a list of action rows, each action row is a tuple of stuff like buttons
or arguments of buttons i guess
so can i put it between []
like [button1, button2] ?
m wouldn't be defined
components=[actionrow(button, button, etc), another_actionrow(up to 5 buttons)]
ah 5 buttons
each actionrow is a line
And you don't have to check it yourself, just let the wait_for do it for you
also up to 5 action rows
u need special intents for message content
MESSAGE_CREATE is the event, correct me if im wrong
but thats also the same for deleting and editing messages
then its ok
do you want the captcha or the embed?
have you already got the captcha generation sorted?
ok
1 sec
has anyone actually tried putting captchas on their bots to stop botters? is it worth
Text based captcha's are easily bypassed tough.
this
not if u put lines through it
image ones are pretty easy to get past as well now
im trying to bypass a text captcha and its HARD
ive only found 1 trained ai that can do it
Well no since google text recognition basically demolishes that.
and its paid
it doesnt
ive tried googles vision ai too
It does? How do you think it learned the words on all other websites across the net.
look at this image
Yes
googles ai recognizes the D as A and the K as T
go ahead and check.
instead of arguing, lets help this person
https://chrome.google.com/webstore/detail/buster-captcha-solver-for/mpbjkejclgfgadiemmefgebjfooflfhl?hl=en you can literally get extensions for captchas
thats reCaptcha
if you can get message content, check if the message is dm (by checking if the guild is none) and if its right: verify them
def check(message):
return message.content == "Something"
try:
# The `wait_for` will use the provided `check` function to check
# if the message content isn't `Something`
# it'll wait until the message content that is exactly `Somwthing` was sent
msg = await bot.wait_for("message", check=check)
...
except Exception as e:
...
you can store correct captchas using a dictionary
That's teh best I can give 🫠
{"user id": "correct captcha", "other user id": "other correct captcha"}
when they get the correct captcha, remove it from the dict
Nope google still crushed it
show me
you have to write the code urself
thats the point
docs exist