#discord-bots
1 messages Β· Page 996 of 1
Ok wait, I forgot the func name
Ah shi π
Wait.
uh
!d inspect.getfullargspec
inspect.getfullargspec(func)```
Get the names and default values of a Python functionβs parameters. A
[named tuple](https://docs.python.org/3/glossary.html#term-named-tuple) is returned:
`FullArgSpec(args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults,
annotations)`
stdlib
Ok
Oop
I have another problem, how could I get the function name from the command
Or the function object
function.__name__
Thatβs not the point π
Iβm getting a command from its name
Ok
How do I get a function by its name
Uh
:loading:
globals()```
Return the dictionary implementing the current module namespace. For code within functions, this is set when the function is defined and remains the same regardless of where the function is called.
Or do you need command object by the function name?
I need a function object by the function name
The bare function
uh then yeah, globals
How can I use that :MoyΓ I:
It returns a dict
Of?
globals()[func_name]
Would that return a function object
yes
is there a way to check if someone is a server owner or the bot owner?
!d discord.Guild.owner
property owner```
The member that owns the guild.
I forgor the property for second one.
uhh
Bro
ids
!d discord.ext.commands.Bot.owner_id
The user ID that owns the bot. If this is not set and is then queried via is_owner() then it is fetched automatically using application_info().
O
id when one owner
is there a way to combine it into one check?
π© haven't made discord stuff since a while
but how?
the inspect thing isnβt getting the args I want π
return ctx.author.id in (ctx.guild.owner.id, ctx.bot.owner_id)
ty ty
FullArgSpec(args=['self', 'context'], varargs='args', varkw='kwargs', defaults=None, kwonlyargs=[], kwonlydefaults=None, annotations={'return': 'T', 'context': 'Context[BotT]', 'args': 'P.args', 'kwargs': 'P.kwargs'})
its returning this
See! You have the arg names!
Let's gooo gg
LMAOOOO
Fuck idk if im being a dumbass
FullArgSpec.args
is latency in ms or something other?
ms
async def cmd (ctx, *, tags: str = "")
``` I'm trying to get the (ctx, *, tags: str = "")
so my bot has a ping of 0.9ms? Thats sick
900 ms wtf
The lurking gods have communicated with me, they are saying that you may have passed wrong function in getfullargspec()
what u hosting on π
prolly laptop
it's a german vps service
i have parsed the right function ;-;
Bru
im using a 2009 pc and i have 75ms ping .
@narrow grail just get the free Oracle VPS
i don't have paypal
Yes!! Pass correct function
How u paying for hosting then
Yes
Ah okay
How did u know tho
One of the piss colour gods in here
Lmao
Totally not @elfin island
π
evening
Evening
Evening
Evening
ive put everything in correctly and im getting the wrong shit
Yes, so ja ab.
show your code

Ok
from discord import Client, Intents, Embed
from discord_slash import SlashCommand, SlashContext
from discord.ext import commands
client = commands.Bot(command_prefix="!",intents=Intents.all())
slash = SlashCommand(client, sync_commands=True)
guild_ids = [924381291804258324]
@slash.slash(name="test", guild_ids=guild_ids)
async def test(ctx):
await ctx.send("test")
client.run("")
Terminal:
-discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
missing ending ]
e = discord.Embed(title=f"{self.values[0]}", description=f"{bot.get_command(self.values[0].split('/')[0]).description}")
e.set_author(name="Requested by " + interaction.user.display_name, icon_url=interaction.user.avatar.url)
print(self.values[0].split('/')[0])
e.add_field(name="Arguments", value=inspect.getfullargspec(globals()[self.values[0].split('/')[0]]))
await interaction.message.edit(embed=e)
How did that not syntax error
ops, in the real code have ]
u r missing another bracket somewhere
what is self.values
the dropdown (select) selected values
the list shows ['cmdname']
Print that among us after global()
Lmao
aha, i droppped discord bot dev right about when interactions came out π
what π
BTW is it normal for an API to return a JSON this big?
and now, whats the problem?
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
@tacit token
print the stuff after global()
yeah
Ah cool
π³
Then I am safe
only 600k lines?
discord.py isnt working for me
What's happening
its legit a simple ping pong bot
how?
the bot turns online it can use the on_message event but not do anyting to commands
Don't say like that, the JSON file is taking like 14 MB space
Ah that process_command bullshit
add await bot.process_commands_message at the end of the on_message
Nothing changed π
@maiden fable do you know what tracemalloc is? I need to enable it so that my ping command could work
no show us the output lmao
( im not using on message rn i just used ti to check if bot was recieving content ) @maiden fable
u forgot an await in that line
how
in the invite url
from where
add %20application.commands at the end
Its just the command name again
5head oof
Hahaha an API I am making for my website
damn
What's the command name printing
Well, tensorflow and nltk do be generating b i g JSON
what 
with what
need help
rst?
Use generator pipelines if you are scared about resource usage
Eh, I am storing it in a JSON file directly and sending the JSON path to the frontend, so idc
The command name being printed
wym
Ok
with what lan are you making the api?
Yes the command name is being printed, the command name is gelb
FastAPI
mhm nice
Is this gelb@slate swan
@maiden fable btw I did a mistake. I have a ping of 90ms. It's 0.09 not 0.9
Lol cool
yes, i changed the command name because its somthing sexual
but what does 0.09 means?
0.09 seconds
its taking 0.09 seconds to send the json to the API
:loading: it shud work.
well it doesnt π
isn't it the time it takes for discord to respond?
after a heartbeat
Eh, its actually the time bw heartbeat ack and heartbeat send (or smth)
Its the ws ping not the HTTP
yeah not api
It still comes under API tho
Prolly I am wrong too, but eh
so the bot latency is the ping of the web socket right?
yes
nice
Yea ws is also api
but how to get the other ping when sbot.latency is only websocket?
u cannot
you can get the command function easier with bot.get_command instead of messing with globals and all that odd splitting and slicing
cmd = bot.get_command("<command name>")
argspec = inspect.getfullargspec(cmd.callback)
argspec.args # --> this is your list of parameter names; omit self if it exists
Just make a random http call and measure ping, lolol
sure? the ygg bot can show to different pings: websocket and other
wish someone said that earlier
π
did you π
no nova we get your point lmao
@maiden fable
Nova told u. U need to send unneeded request to the API, which isn't recommended
π₯Ί
@grim oar I relate to u π«
shit i missunderstood that sorry
π smh
sorry nova π
It gud
there was a time when i wasnt yellow too π
Anad is my joint bff
and i have to keep all the splitting bullshit
piss role :(
we smoke together
There have been many instances when the same thing has happened and the Helper said the literal same thing I said before
What.... do u both smoke π
!ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
Ok
anyone made anything interesting with slash commands/interactions in general? some inspiration would be cool
I wish people also understood this
Anything anyone makes, is always copied by the popular bots and used in their name, so I don't think anyone really makes anything innovative anymore
Who else needs help I will help
π© let's not be so pessimistic
Just like u did, now? =D
Just stating the reality
Yes, I help in variety of ways
when exactly should i run CommandTree.sync?
Never. Just use disnake/hikari
When you want to synchronize the command tree, you know
Lmao
The tree of commands need to be synchronized to work well
insightful
Thanks
db[f'lb{num}'] = role.name
await ctx.respond(f"Set {num} to {role.name}")
how would i interate through the db and check if their is a value for each number?
e.g i assigned a role to number 1 and i assigned a number too role 3
@grim oar π
I am a bit busy
is that replit? just use a for loop on the db items
global name
name = None
global id
id = None
global authorid
authorid = None
class Dropdown(discord.ui.Select):
def __init__(self, client):
self.client = client
options = [
discord.SelectOption(label="1", description="rolletje", emoji="π’"),
]
super().__init__(
placeholder="Select an option...",
min_values=1,
max_values=1,
options=options,
)
async def callback(self, interaction: discord.Interaction):
print("Callback hiero")
if self.values[0] == "1":
await client.add_r(authortje, "drol")
class DropdownView(discord.ui.View):
def __init__(self, client):
self.client = client
super().__init__()
self.add_item(Dropdown(self.client))
@client.slash_command(guild_id=[959432789164437604], name="selfrole", description="Take your roles")
async def selfrole(ctx):
global name
name = ctx.author.name
global authorid
authorid = ctx.author.id
global authortje
authortje = ctx.author
global id
id = ctx.guild.id
view = DropdownView(client)
await ctx.respond("**Selfrole menu**", view=view)
Hi guys! How can I add a role to someone, using the dropdown menu? I have this.
u need to use utils.get to get the role object with the name
Hello, someone can help me with API Request, I need to get data from this json file :
[
{
"a": "a",
"b": "b",
"c": "c"
},
{
"a": "a",
"b": "b",
"c": "c"
},
{
"a": "a",
"b": "b",
"c": "c"
}
]
I need to catch every "a" data
After async def line make a new line and say '''Idk'''
Not sure
Not sure, test it out i'd say π
slash?
Like this
@client.slash_command(guild_id=[959432789164437604], name="suggest", description="Make a suggestion for the bot/server")
No idea how you can choose an account, sorry!
Dropdown like this?
Yeah
if its valid python code, u can use it in any IDE
yo how do I get the id of the command message?
eg. the id of !help
Anyone know how I'd respond to a button interaction by just editing the message?
The user clicks on a button, the message gets edited.
Like I just want to use :
class Buttoning(View):
def __init__(self):
super().__init__(timeout=None)
@button(emoji=myemoji, custom_id="button1", style=discord.ButtonStyle.grey)
async def Button1(self, interaction: Interaction, press: Button):
await interaction.message.edit("new msg")
However I get the "This interaction failed" msg on discord, is there any way I can like continue an interaction without actually having sent a response msg?
(I'm using the latest version of discord.py v2 btw)
interaction.response.edit_message(...)
Wow I must have overlooked that in the docs, I literally did not see a way of doing this. Thanks! this worked
interaction.response calls the InteractionResponse class, look for that
Great, thank you very much sir.
:)
I got 1 more question, how do you disable a button?
property disabled```
Whether the button is disabled or not.
how can I run my bot online 24/7
Would it be possible to change that after a button has been clicked? So that for the next view the button will be disabled
ya when its True the button is disabled, when its False its not, it can be changed anytime
async def Button1(self, interaction: Interaction, press: Button):
in this case u would type press.disabled = True
huh
im not really a web developer
neither me :>
glad to see my example is helping people π₯²
Only matters if you're making a dashboard or something similar. Just need to get a VPS
u wrote that?
yup. was my first contribution iirc
π sick
Uh how do I get that π
You have to be willing to put down an initial investment
Most good VPS aren't free
Ah so they costly, uh are there any free vps?
There are but they all suck
It does not work for me, mind seeing if I overlooked something? This is my code simplified:
class Buttoning(View):
def __init__(self):
super().__init__(timeout=None)
@button(emoji=myemoji, custom_id="button1", style=discord.ButtonStyle.grey, disabled=False)
async def Button1(self, interaction: Interaction, press: Button):
await interaction.response.edit_message("new msg")
if this == that:
press.disabled = True
view = Buttoning()
await ctx.send("hi", view=view)
await view.wait()
Laughs in Oracle
Many reputable providers also have free tiers
Ah..
I don't really count that as "free" though
Like hunter mentioned, oracle has a good free tier. So does AWS. Google cloud might as well
Well im just 14 so I don't think I can pay for a vps π’
if this == that:
is this condition satisfied??
Oracle free tier does take $1 out of your CC to make sure its valid
AWS you just need a CC they don't take money
it isn't really relevant the point is I want to put the button as disabled when something happens.
They refund it
Yeah
it kinda is because if that condition is not satisfied, the button wont be disabled, so make sure that is first
more like if the condition is true
!e
print(1 == 1)
if 1 == 1:
print(1)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | True
002 | 1
Ah you mean it like that. Yeah it is 100%
I think I might be doing wrong with the view.wait() since im not doing anything after that. I'm not sure though, I just recently switched to this version
yea π
hmm maybe remove that and try it out
whats the problem?
the button is not being disabled apprently
he probably forgot to edit the message with the current view lol
If I don't give a view when editing doesn't it stay on that view?
no
idk the default value of the kwarg but its probably falsey and would remove the view
you just need to send the view with the current state of the instance so it would be view=self
Ah that was where I went wrong. Thanks! π
youre welcomeπ
is guild.categories in order of where they appear on the list for users? ie for this server would it be [information, news, lobby, ...] (As category objects ofc) or just in a random order?
They're listed from top till bottom (pretty sure)
Aighty, thanks
@slate swan do you by any chance know if it's possible the change the disabled value from 1 button while another button is clicked? (In the same view)
yes
!d discord.ui.View.children
property children```
The list of children attached to this view.
just index the list which has button objects and use the disable property
!d discord.ui.Button.disabled
property disabled```
Whether the button is disabled or not.
This worked, thanks for helping me with my problems man
anytime!
how do i make sure it checks if the reaction is not from the bot
reaction, user = await bot.wait_for("reaction_add", check=lambda reaction, user : reaction.emoji in buttons, timeout=60.0)
How to download all images from a channel? If that in the channel only images
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/master/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
How can I add a image like this at the bottom of the embed
!d discord.Embed.set_image or smth
set_image(*, url)```
Sets the image for the embed content.
This function returns the class instance to allow for fluent-style chaining.
^
else:
season = db['season']
week = db['week']
keys = []
hk = db.keys()
try:
for ke in hk:
i=0
i+=1
keys.append(ke)
embed=discord.Embed(title=f"{ctx.guild.name} Season {season} Week {week}", description='\n'.join(keys), color=ctx.author.color, timestamp=datetime.datetime.utcnow())
why am i getting invaild syntax?
If you use try: you do need to provide an except statement.
For sending content to webhook is the ratelimit per webhook or per channel of that webhook destination
i don't think webhooks have rate limits
Webhooks do have a ratelimit, it is per channel
I believe about 30/min, but I could be wrong
Integrate your service with Discord β whether it's a bot or a game or whatever your wildest imagination can come up with.
how do i parse a channel ( #discord-bots like that) in a command argument?
What library? For discord.py, you can use type annotations I believe
@commands.command()
async def my_command(ctx, channel: discord.TextChannel):
...
K thanks
hk = db.keys()
for ke in hk:
i=0
i+=1
keys.append(db[f'lb{i}'])
``` why does it only return the value of #1
you aren't returning anything?
Hi I've got a question about finding things in strings. I have this small mockup. py tags = { "{user_name}": "(name tag)", "{user_tag}": "(tag tag)", "{user_id}": "1234", } text_b = "Hello World {user_name}:941314754851524639: It's almost my birthday" split_b = text_b.split(":") b = "" for string in split_b: b = b + string for tag, val in tags.items(): out_b = b.replace(tag, val) print(f"split_b: {split_b}") print(f"string_b: {b}") print(f"out_b: {out_b}")
What I want to do is find any place one of my tags is in a given string.
Then next to the tag there will be two colons with a number between them, this number will be a ID of a member/role/channel/guild.
I will know what type of thing the ID is based off of what tag was used in front of it,
Then I will need to grab that number and convert it into the type of thing it is
Then once I have converted it then I need to replace the tag in the string with the thing I just converted.
I hope that makes sense, I think the code mockup will help explain it
in th embed it would only show the value of # 1
maybe the db.keys only has one value?
Hey does my above question make sense?
How does everyone store their access tokens?
do you keep it in the same script, or a plain text file or what
activity = disnake.Activity(type=disnake.ActivityType.listening, name="pooping")
await client.change_presence(activity=activity)```
i assume it's the same with discord, just replace disnake with discord and client with bot if that's what you use
configuration files (json, .env, yaml, toml)
is that enough security is what im trying to get at
Just a small question:
I have a main.py file, and a cogs folder which contains:
economy.py
events.py
fun.py
games.py
help.py
info.py
marry.py
moderation.py
roleplay.py
test.py
utility.py
Is my file organization okay like that, or should I change something?
don't see anything wrong with that, but my organisation is terrible
rip, clear it up Ig
Itβs great donβt worry
hi
Is there any kind of annotation that I can do for a message in a hybrid_command?
like
async def delmsg(self, ctx: commands.Context, message: discord.Message):
``` (Except it doesn't work) Using discord.py
that message argument typehint isnt correct btw
hybrid_command?
(Except it doesn't work)
?
huh what / use for in asyc func
you mean in params?
Denotes the end of positional params iirc
and in paramters it means the arguments before it are positional only while * means all arguments after are keyword only
!d discord.ext.commands.hybrid_command new stuff
@discord.ext.commands.hybrid_command(name=..., **attrs)```
A decorator that transforms a function into a [`HybridCommand`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.HybridCommand "discord.ext.commands.HybridCommand").
A hybrid command is one that functions both as a regular [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")
and one that is also a [`app_commands.Command`](https://discordpy.readthedocs.io/en/master/interactions/api.html#discord.app_commands.Command "discord.app_commands.Command")...
tbh that seems like a bucket of errors and a half
nah not really
of hybrid commands?
Yeah
are you trying to delete the message whose id Is provided?
devs took care of it for us, for example
ctx.send
Is either ctx.interaction.response.send_message or ctx.channel.send, depending how to command was called
is there more things that i don't know?
not really
No, I'm curious if there's any builtin annotation / menus for messages like there is for Literal, Member, etc.
just check src if you want to check types
ok
best way imo
its not possible to convert an argument into a message using annotations
there are converters for some annotations which help it in workin ( https://github.com/Rapptz/discord.py/blob/master/discord/ext/commands/converter.py#L1137-L1159)
Why
that sound Interesting, is there an exmples and explains?
Did someone order again
order what?
Yes, they ordered our 4th tier
The largest tier available
Wasn't that a joke
No, they really did.
Will they pay
well, this is used mostly for parsing the arguments for commands py async def command(ctx, member: discord.Member): here the discord.Member which is a typehint tells the parser that it needs to use MemberConverter for the member argument
same goes for other annotations listed there too
!d discord.ext.commands.MemberConverter
class discord.ext.commands.MemberConverter(*args, **kwargs)```
Converts to a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member").
All lookups are via the local guild. If in a DM context, then the lookup
is done by the global cache.
The lookup strategy is as follows (in order)...
you can use it directly too
Thanks for explaining
@bot.command()
async def nspic(ctx, *arg):
link = "https://images-api.nasa.gov/search?q={0}".format(*arg)
url = requests.get(link)
data = url.json()
await ctx.channel.send("ΔΓ£ tΓ¬m thαΊ₯y {0} kαΊΏt quαΊ£, bαΊ‘n nuα»n tΓ¬m kαΊΏt quαΊ£ nΓ o (tα»« 1 ΔαΊΏn {1})".format(len(data['collection']['items'])-1, len(data['collection']['items'])-1))
try:
s = bot.wait_for("message", check=lambda m: m.author == ctx.author and m.channel == ctx.channel, timeout = 30.0)
except asyncio.TimeoutError:
await ctx.channel.send("ΔΓ£ quΓ‘ hαΊ‘n cho phΓ©p, mα»i bαΊ‘n thα» lαΊ‘i.")
else:
if str(s).content() in range(1, len(data['collection']['items'])):
await ctx.channel.send(data['colletion']['items'][s-1]['links']['href'])
```
Im trying to use wait_for for the command
Can anyone help
The error is discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'content'
/usr/lib/python3.8/asyncio/events.py:81: RuntimeWarning: coroutine 'wait_for' was never awaited
self._context.run(self._callback, *self._args)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
just await the wait_for
Oh
@bot.command()
async def nspic(ctx, *arg):
...
s = await bot.wait_for(...)
...
it must look like something like that
I've changed the code, thanks
no problem : )
How can I change the type of message to int
The type is "discord.message.Message"
type of msg?
you want to get the id of the message?
what's better for a database, aiosqlite or sqlite3?
Oh
you can do that
Wait, so I dont have to include the () for content
no you don't need that. it will return an str not a func
Oh
Thank you
no problem make sure to make error handle cuz maybe the user will input unconvert int
Thanks, I will handle that
feel good helping you
Thanks for the help
>>> string1 = "1420p"
>>> string2 = "1420"
>>> int(string1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '1420p'
>>> int(string2)
1420
>>>
as you see it raise ValueError
Oh
else:
if int(message.content) in range(1, len(data['collection']['items'])):
await ctx.channel.send(data['collection']['items'][int(message.content)-1]['links']['href'])```
It throws an error
show me the error
TypeError: list indices must be integers or slices, not str
Isnt int(message.content)-1 an int
message.content is a string, you cant convert it to an integer unless there is a number in the message content
yes i am sure the problem in the code not in int(message.content) only if you didn't code this intents.message_content = True. i am not sure but it must work that make sense to me
Hmm ok
show me the test
maybe you enter an string
Wait it seems like I forgot to add the [0]
its works fine now
Thanks for the help guys
hm, if I got it right, you are waiting for a number to be input by the user, right?
that is exicly what she doing
well, it should be checked if the message was a number or not since you cant convert letters to integers
You mean like if the user inputs a string, the bot should tell them that they need to reinput it?
yeah, add a and m.content.isdigit() to your check
Thanks
it returns bool, right?
you can π³
hey hey
thats why you dont
only if the content is 3 certain letters
not helpful smh
!e print(type(float("nan")))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
<class 'float'>
uh
nan stands for not a number btw
hm i figured that out but what does it stand for then
what
not a number
wow
π§
i always think i know but i always don't
every programmer brain
i dont have a brain
whos Brian
LMAO litrey your a cat
what
you only know about python as far as I know
cats have a brain π
i know about cats does that count?
not being offend bro, just take it as funny joke π
!ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
im very offended πΏ
Can I ask for code help here?
Yes
if its related to bot development yes you can
Oke!!
I'm having a problem with storing my token in a .env file
My bot runs perfectly when I put the token in the main file but if I try with a .env file it bombards me with errors
!e
print(None.strip())
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | AttributeError: 'NoneType' object has no attribute 'strip'
is it this?
Nu
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 precisely
were did you took the token from?
Did u hide the token in this pic?
tokens in a diff file
no like in the developer portal
it has to be a string
Ahh
Ye
Are there any ways to use multiple arguments in python
Yes
I got a different error this time!! :D
in function ?
Yep
Thanks guys I can take it from here <3
you can specify them or just use *args or **kwargs for an unknown amount and this question falls in to #python-discussion
Oh
..
Sorry
its ok!
Just found it in discord.py docs so I thought it was related to this channel
ah
and other python revelant libraries
How long is a rate limit
Nuke bot?
Iβve been rate limited for like 2 hours lol
uh sad
Because people were using a lot of commands at once
Add cooldown
2-3 sec
Yea Iβll need to, how long is a rate limit gonna be tho
Its in console
Just says temporarily
What's this then
U know but u dont know wtf?
Thereβs a message in console every time someone tries to run a command
βYou are being temporarily rate limitedβ etc etc
i dount thats the issue
..
Ye same
the wrapper wouldve handle the bucket
nah it was basically command spam
No
a bunch of people spamming at once?
Bot cannot get ratelimit
I mean I wasnβt doing anything else
This bot has been running for a whole year and Iβve never had this issue
In that case
So I just assumed itβs getting too many users
it can
@slate swan sleep it's early in the morning
Maybe u added a spam command something
its 8
its just the wrapper calculates the bucket and locks the command
with
Early
Oh sry
!d asyncio.Lock
class asyncio.Lock```
Implements a mutex lock for asyncio tasks. Not thread-safe.
An asyncio lock can be used to guarantee exclusive access to a shared resource.
The preferred way to use a Lock is an [`async with`](https://docs.python.org/3/reference/compound_stmts.html#async-with) statement:
```py
lock = asyncio.Lock()
# ... later
async with lock:
# access shared state
```...
Its late tho i wake up at 5 when there are schools
i kinda find it useless that dpy calculates the bucket but whatever
you do know how the api works right?
Does anyone know how long Iβll be locked out though?
yes
its mostly like an hour
kk
depends on cloudfare
@slate swan which cmd the ppl were spamming?
well thereβs a command which adds something to a database
uh what?
Itβs a specific bot that modifies save files for a certain game
Hard to explain out of context
..
ok
I dont ;-;
Iβve been locked out over an hour but hopefully itβll end any time now
right
its quite complex especially when making a wrapper for itπ
Idk what is wrapper ;-;
discord.py is an api wrapper
oh
so thats how u define wrapper
API wrappers areΒ language-specific kits or packages that wrap sets of API calls into easy-to-use functions. The wrapper programmatically calls multiple API calls without requiring user interaction, further automating projects.
You can just imagine it as ```py
await channel.fetch_message(123) -> GET /channels/{channel_id}/messages/{message_id}
discord.py "wraps" the API, and exposes a method you can use instead of using the endpoint itself DIRECTLY
Cool
Hence, the term "wrapper"
Okay
can custom_ids have spaces in them?
an api wrapper is just something that makes basic commands
iirc, no
fuck
..
User underscore
Pretty sure custom_id's can accept strings with spaces
right
its like python it has the len function so you dont need to write the whole binary script for the lenght of something
As long as it's unique and not exceeding the 100 char limit
the way i set things up means im gonna have to insert an underscore then take it back out later
what's that replace thing
string.replace(" ", "_")
!d str.replace
str.replace(old, new[, count])```
Return a copy of the string with all occurrences of substring *old* replaced by *new*. If the optional argument *count* is given, only the first *count* occurrences are replaced.

cats come to my house for eating my parrot π’
No ot its the end
The documentation says nothing about not allowing spaces
not their fault you have a delicious parrot
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.
π
πΌ
thats all they mentioned
Yea, so I'm pretty sure it allows spaces
Otherwise they would've mentioned it
Like in a few other places they do say they don't allow spaces
Can't remember for which though
Ok
Is this the right way to get my token from the .env file?
wait wait nvm
It's working now just didn't save the files
@bot.event
async def on_member_join(member):
if member.guild == bot.get_guild(960516503613079582):
button = Button(label = 'Verify', style = discord.ButtonStyle.green, emoji="β
")
guild = bot.get_guild(960516503613079582)
member = member
this_role = discord.utils.get(guild.roles,id=int(961235844704919562))
async def button_callback(interaction):
await interaction.response.member.add_roles(this_role)
guild = bot.get_guild(960516503613079582)
member = member
this_role = discord.utils.get(guild.roles,id=int(961235844704919562))
button.callback = button_callback
view = View()
view.add_item(button)
await bot.get_channel(960516503613079584).send(f"{member.mention} has joined the class ! Bhak bsdk pehle May I come in ma'am bol ", view=view)
Hi can anyone tell me whats wrong with this code? im trying to create a verification system
Is there anyway for me to get all the IDs of people who have access to a specific channel?
Elaborate and then people can actually help.
its showing AttributeError: 'InteractionResponse' object has no attribute 'member'
I want to create a button that gives people a role when clicked
What line....
And on this line:
this_role = discord.utils.get(guild.roles,id=int(961235844704919562))```
doing int(961235844704919562) is useless as 961235844704919562 is already an int
ok but that won't help in this error
And you've done that twice, try be a bit more efficient and your code can run faster
AttributeError: 'InteractionResponse' object has no attribute 'member'
What line...
ive deleted that now
...
π
await interaction.response.member.add_roles(this_role)
yo hack
huh?
Doesn't look like interaction is defined
depending on your lib it would be author or user
Where's interaction on that code
Ohh
!d discord.Interaction.user
Sorry
The user or member that sent the interaction.
cant it be interaction.author.add_roles()?
I haven't defined interaction before too but it works
if its disnake yes
disnake has aliases of user and author while dpy doesnt
Nah it was on
async def button_callback(interaction):```
it went right over my head
ok i'll try that
which lib ur using
disnake
The user or member that sent the interaction.
.
I wanna fetch the name of the server my bot joins so it prints to the terminal "EggwuhBot has joined 'server'", how do I call the name of the server?
Is there anyway for me to get all the IDs of people who have access to a specific channel?
Also sorry I can't send embedded I'm working with a vm
The guild name.
print(f"{client.name} has joined {guild.name}")
ty ty 
The userβs username.
uh ok
Is there anyway for me to get all the IDs of people who have access to a specific channel?
!d discord.TextChannel.members
property members```
Returns all members that can see this channel.
cool
property id```
Equivalent to [`User.id`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.id "discord.User.id")
im speed
π₯
i accidently opened my bot folder with vlc media player
It only fetches by bots info
?
code
It only prints this
[<Member id=932589533071200702 name='Test' discriminator='2477' bot=True nick=None guild=<Guild id=963264462117407764 name='Test Bot Server' shard_id=None chunked=False member_count=3>>]```
code?
channel = client.get_channel(payload.channel_id)
print(channel.members)```
@slate swan 
!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 the Members and Presences intents, which are needed for events such as on_member 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.
I have intents
..
then your bot is the only one that can access the chat
...
this is the 2nd time
...
I can access it too
have u already helped him?
I can access it too
also why ur bot name is test :?
nah, stuff related to intents
he seems to be missing member intents but simply says "i have intents"
ohh
@slate swan can u pls show us the code of intents
It was my school name I changed it for privacy
oh
.
intents = discord.Intents.default()
client = commands.Bot(command_prefix = bot_prefix, intents = intents)
intents.members = True
client.remove_command('help')```
bro
we not gon hack ur skool lmao
see, clearly you dont have them.
sarth was right
the intents.members=True line must be above client defination :)
Ok
π
that fixes your old issue you were facing that day as well
It works
But is there anyway to just fetch the IDs?
it looks like a bunch of junk.
.id
print(channel.members.id)
@slate swan
How would that work
AttributeError: 'list' object has no attribute 'id'```
idk
use for loop
Yes
or a list iteration
im bad at that ;-;

Huh?
i have a short list comprehension for doing that "id only" stuff but its like playing with the internals..
!list-comp
Do you ever find yourself writing something like this?
>>> squares = []
>>> for n in range(5):
... squares.append(n ** 2)
[0, 1, 4, 9, 16]
Using list comprehensions can make this both shorter and more readable. As a list comprehension, the same code would look like this:
>>> [n ** 2 for n in range(5)]
[0, 1, 4, 9, 16]
List comprehensions also get an if statement:
>>> [n ** 2 for n in range(5) if n % 2 == 0]
[0, 4, 16]
For more info, see this pythonforbeginners.com post.
this is what they mean
its quite easy its syntax is [expression for element in iterable]
you can have if statements as well
ids = [ mem_map[0] for mem_map in channel.guild._members.items() if channel.permissions_for(mem_map[1]).read_messages]
π³ don't do this
you cant call print in the list comp lol
uh
Bruh im still confused

!e ( print(a) for a in (1,2,3)) # why not?
@slate swan :warning: Your eval job has completed with return code 0.
[No output]
see how i said list comp
im bad at list compe
and thats a generator
Why
never learned it
i did a tuple comp
!e ```py
[print(i) for i in range(10)]
@pliant gulch :white_check_mark: Your eval job has completed with return code 0.
001 | 0
002 | 1
003 | 2
004 | 3
005 | 4
006 | 5
007 | 6
008 | 7
009 | 8
010 | 9
I am grouping commands correct yes?
How do i get their ids
you are basically being asked to use a for loop ```py
ids = []
for member in channel_members:
ids.append(member.id)
well i probably got confused with another problem
lol
list compre
because one time hunter said about something about that you cant call print dynamically in something but i forgot
Works thank you
never name your command functions "help"
Lmk please.
Why?
Oh
!e print(*((a)for a in (1,2,3))) # isn't this supposed to be the right one
@supple thorn :white_check_mark: Your eval job has completed with return code 0.
1 2 3
I thought it was like
its a built in python function.
$help daily
Even if I removed it?
do u have a help command?
Yes
then add in it
you can use the name kwarg in @command decorator alternatively ```py
@bot.group(name="help")
async def my_help_group(ctx):
...
@my_help_group.command()
... ```
..
nah, oki said that we cant print something "inside" a list comp
Okay
skev u said u have esoteric python
isnt that esoteric
smh
i got confused because of something elseπ‘
Is it
nah
π but i got u nah
its just unpacking a tuple comp
..
i got confused because of a problem long ago i had and hun hun corrected meπ‘ π
alr ill continue with my giv cmd
definitely not a simple selectmenu callback π€‘
I forgot sarth uses hikari
i just realised i added an and instead of ==
hun hun is uwu
fun.bot
hes mine
fun being an instance of lightbulb.Plugin ( cogs kinda thing)
Hun hun got 2 boys fighting over him π³
nasty
not like he dms me everydayπ©
Which problem?
you gonna implement a rest client in your wrapper or not ?
i forgotπ³
still havent finished my gatewayclient
cause they are more handy than working with objects most of the time
and you see how my hun hun appears and responds to me
lmao
Stop it oki
Hunter ignore okimii now kek
i still havent started entities
"hun hun"
Don't give the satisfaction
ugh fineπ
ohhh ic
I hate that name
atleast it doesnt uwu-fy you
I'm not sure what I'm doing wrong, it's saying guild isn't defined
guild isnt a thing lol
Error happens when I try to change my bot's prefix
!e a
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | NameError: name 'a' is not defined
^^
Ping me
define a
π
also, don't use json as a database
Agreed
i wont
What should I use?
example sparky im not that of a noob
Trying to get my notifs back up to 20k+ again
ik lol
postgres
Playing clash royale?
hog rider!!!!
sqlite as a local database is a good option, you'll just need to learn 4-5 statements
for better databases in bigger production you can go for remote dbs like postgresql, mysql or mongodb ( mongo is json type)
maybe
I like xbow
ah okok
i like hog rider
I saw your bio suddenly show clash royale
So that would be for having diff prefixes for diff servers?
https://sqlbolt.com pretty useful
SQLBolt provides a set of interactive lessons and exercises to help you learn SQL
I was not stalking your account π
hmm
i hate that website
π€
no tutorial found there
.
basically, storing guild id and prefix pairs inside a table
the whole website is a tutorial?
kat
Yea that sounds way better
i got stuck somewhere
Thank you <33
in what joins?
ability_to_read_and_do_what_it_says.exe stopped working
wait
brain.exe stopped working
noice
get flash bang
seems like a "you" issue
no way
bad wifi moment
nah i reloaded its fine
cool
they added the next button
I like trains
i like ||you||
π
the next button was not there
in the past
advancd talk π³
and its always been there
ive always seen that hyper link there
idk since i learned sql from school
ew

which standard
im self taught π
12th
oh
im on 9th π
same
they teach basic python
like prinitng
var
they teach java c++ and python in 10th in my school
Dropper π
they'll keep teaching you file reading operation until class 12th π€‘
wow cool
when i heard python in the course i smiled because i know my group is gonna suffer next year
even if it is basic pyπ
in 8th there was a chap called visual basic ;-;
πΏ
flex
me with 1 year of python experience π³
Why "suffer"?
because they dont know english or basic programming
3 years 
with open("logs.json") as f:
logs = json.load(f)
should i add it inside the function like !setlogs
or outside cog class or in cog class
(json no comments)
outside
ok
inside or the values wont update when you read it
..
π’ why
so you wont need to be opening the file on each command invocation and you should be using aiofiles because it would be blocking
wait
thats why i changed now
he meant cog and not command oopsie
well yes it should be in the cog sorry
πΏ
the sucka fish~
Lol I thought this was ot
indian def
probably add it as an attribute for the cog
well yea, my username suggests that already doesnt it
sarth and hunter are my lovely indian bros
it kinda does
:<
guys this is getting a bit off topic now
yes
Robin mad he arena 3
!ot
Off-topic channel: #ot2-never-nesterβs-nightmare
Please read our off-topic etiquette before participating in conversations.
:skull:
challenger 1 π¦
Yall mad yoy guys dont have hog rider
i have
ot
and still no gold hair hog rider
you guys can be max arena but i got golden hair hog riderπ
.topic
