#discord-bots
1 messages · Page 829 of 1
@slate swan tried it again
still doesnt work
i dont think you can run the thing more than twice from here idk
to locate the dictionary value of the plant tray
thats not the point, i want to make 2 multiple tasks
and it's not undefined
but that doesnt seem to work
thats not the issue like i said, your going over the real issue
I said i want to make 2 multiple tasks but that wont work
hikari&rin lover got me to do plant_growth.start() at the end of my task which made the 2 seperate tasks but returned RuntimeError: Task is already launched and is not completed.
use create_task()?
yeah so the idea wont always come out exactly like you wanted it to and btw discord had a api outage again
What's the format?
how am i supposed to specify the interval or count?
i never saw create_task in the docs
unless thats a async version thing
It belongs to asyncio
oh
The one you sent
But how come in an embed for me it didnt embed
Seems like it's fixed now XD
smh its like monthly
Could you show the code and what it send on discord
you use create_task() on bot.loop
hey!
@commands.command(name="check")
async def check(self, ctx, type:str, id=None):
if type in index:
if type == "id":
for i in range (0, len(Json_Items)):
for x in Json_Items[i]:
if int(x) == int(id):
print(Json_Items[i][x]['P Method'])
print(Json_Items[i][x]['P '])
print(Json_Items[i][x]['User IGN'])
print(Json_Items[i][x]['Discord_Name'])
else:
print("User not found")
this prints "User not found" every time it doesn't find a user when the command is run, how do I make the loop only print this phrase once instead of doing it for every item in the json file which is not the user
Not for pc till now
yes but is that how you specify the interval or count?
On PC it embeds
Yo raven I’m also raven
I don't even understand the question
You're overcomplicating
discord flags github links now as files lmfao
I sent the image but as for the code I used disnake.utils.format_dt
tasks got intervals until it loops again or counts for how many times it should loop, i dont get how thats overcomplicating
you define that in the task itself?
just use the alias src lol
how do i dm a member?
not for me
like seconds=10?
!d discord.Member.send
ah alr
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
thansk!
python slow smh
!d discord.ext.tasks.loop
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
yw
you said create_loop doe, i tried doing tasks.loop but it registered my thing as a function and wouldnt run
appearently its a decorator
oh
so do i create the task and variable it then use it in tasks.loop(seconds=1,loop=task_variable)
like
task_variable = bot.create_task(plant_growth(args))
f = tasks.loop(seconds=1,loop=task_variable)
?
@cold sonnet or do i cretae the task in loop=?
The command does not work and does not display an error in the console, why? the command worked a few days ago
just access the file
isnt a paradox a cicle or repetition
show ma plant_growth
its a bit big but ill simplify it
not really a paradox
I thought he made a loop about a variable he made from the loop he just made
lol
@tasks.loop(seconds=10.0)
async def plant_growth(self,ctx,trayid,number):
i put the params as args because that was a demonstration
so what you wanna do is
The command does not work and does not display an error in the console, why? the command worked a few days ago.
var = bot.loop.create_task(plant_growth())
kk
atleast big github music bot maker said this
yes i did what you asked me to do
what's args there
self, ctx, trayid, number
you gotta pass something to that
did so
I don't think you can patch out args like that tho 
let me see
vars smh
Help me please.The command does not work and does not display an error in the console, why? the command worked a few days ago
and if i wanna stop it or interval it i use
task_ = tasks.loop(seconds=10,loop=var)
fuck wrong guy
and then do task_stop
async def choice(): how do i call this choice function?
no
you don't do that
I guess so too
well that was easy and it took me 3 hours to figure that out
but your decorator takes count for your interval
async def choice(): how do i call this functikon
pip uninstall discord
and then
pip install discord.py
oh
so i had to use that for my interval?
no
you don't have to, you can...
right
the wrapper has nothing to do with your api auth token
so just like this then huh?
or using whatever it says in the docs
change_interval()
@cold sonnet
@bot.event
async def on_member_update(before, after):
entry = list(await after.guild.audit_logs(limit=1).flatten())[0]
user = entry.user
if after.bot:
return
if before.display_name != after.display_name:
channel = bot.get_channel(935160414965211179)
emb=discord.Embed(title="Изменение ника", description="**__Информация:__**", color=discord.Color.from_rgb(255, 128, 0))
emb.set_footer(text="© Все права защищены The Greatest", icon_url=before.avatar_url)
emb.set_thumbnail(url = before.avatar_url)
emb.add_field(name="**Пользователь ника:**", value=f"**{before.name}**", inline=False)
emb.add_field(name="**Ник до Изменений:**", value=f"`{before.display_name}`", inline=False)
emb.add_field(name="**Ник после Изменений:**", value=f"`{after.display_name}`", inline=False)
emb.add_field(name="**Сменил:**", value=f"**{user}**", inline=False)
await channel.send(embed=emb)
Command doesnt work
that's not a command either
just say you need to change the bots token to your actual token
you need intents if it doesnt work at all
no, that won't work
!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.
change_interval()?
if it exists
you said after you reinstall dpy which makes it look like the wrapper logs your token or something
it does
then sure
ok thanks
lol
A few days ago the command worked, now it has stopped, it does not give errors
and to stop it i just do plant_growth.stop()?
yes
epic
something probably has changed tho
maybe on discord
or you updated dpy
traceback 
!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.
-it does not give errors
-traceback
lolllll
you could've atleast said maybe you made an error handler
have youve been listening to me??????????
REINSTALL DPY
NOT LIKE IM EXPERIENCED WITH THE LIB
definitely not
😠
noob
pip install disnake
lmaoooo
noob
why you bully me
did you make an error handler?
do you have intents
I'm just kidding homie I love u
on a a event?
me too😳
!d discord.on_error
discord.on_error(event, *args, **kwargs)```
Usually when an event raises an uncaught exception, a traceback is printed to stderr and the exception is ignored. If you want to change this behaviour and handle the exception for whatever reason yourself, this event can be overridden. Which, when done, will suppress the default action of printing the traceback.
The information of the exception raised and the exception itself can be retrieved with a standard call to [`sys.exc_info()`](https://docs.python.org/3/library/sys.html#sys.exc_info "(in Python v3.9)").
If you want exception to propagate out of the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") class you can define an `on_error` handler consisting of a single empty [raise statement](https://docs.python.org/3/reference/simple_stmts.html#raise "(in Python v3.9)"). Exceptions raised by `on_error` will not be handled in any way by [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
@cold sonnet this day keeps on getting better '_asyncio.Task' object has no attribute 'change_interval'
jokes on u homie, again
oh that
shhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
i thought you mean a custom error handler🏃
pretty sure change_interval is a non-asyncio thing so it doesnt know what that is
change_interval is for discord's tasks
Yes
yes and you told me to do something like var.change_interval()
for the new task i created
pip install disnake
oh cuz create_task made it an asyncio task
do that
oh then what do i need to do
var = self.bot.loop.create_task(plant_growth(self, ctx, trayid, number))
var.change_interval(seconds=10.0)
how did it not work
I'm looking at asyncio docs
k
yo bee you won't believe it
?
show
it probably says the same error since youre running it with dpy
just replace everything with disnake since its a fork of dpy
it probably will
well try to convert this to your code
well sure
how do you do random thing like you give multiple things and it give 1 randomly each time you use the command
the random module
you can use .choice
what's that
a module
its a builtin module that has random methods
so .choice which gets a random element from a list randint which gets a random int from a given range
etc
wdym by weights
mr.andy
!e ```py
import random
for _ in range(4):
print(random.choice(["foo", "bar"], weight=[100, 0]))
@pliant gulch :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 4, in <module>
003 | TypeError: Random.choice() got an unexpected keyword argument 'weight'
like chances?
OK holdon let me look at it again
seems to work but one small problem
to have an off chance
it doesnt repeat, i put the change interval at the start of the code
https://mystb.in/NewlyCaptureStrip.python
why the logs won't send
even tho the channel is set
10 seconds to be exact but it doesnt seem to run after its first been ran
Help me please.The command does not work and does not display an error in the console, why? the command worked a few days ago!
andy
!e ```py
import random
print(random.choices(["foo", "bar"], weights=[100, 0]))
@pliant gulch :white_check_mark: Your eval job has completed with return code 0.
['foo']
bro.
There we go
so chances as said
But yea, in here foo is always chosen
@slate swan
^^
For each element in the sequence I give at the first argument
which if set by default it should all be equal
you know much about asyncio tasks don't you, homie
uh maybe
andy does
You'd use it for running coroutines or whatever
yes andy does
You want to actually use the exts.loop from discord.py
andy probably uses Trio
Trio?
it only works on numbers?
thats how cool he is
Oh, you're talking abut that library
and how would that work really?
yes
https://discordpy.readthedocs.io/en/stable/ext/tasks/index.html?highlight=tasks Read this quickstart rq
It will get you through the basics
i know how tasks work, well the basics. what i want to do is create multiple tasks, like only 2 at a time
ofc
But you aren't even using discord.py's task, wdym
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
You are using asyncio.AbstractEventLoop.create_task
no one will click a random url
i was told to use create_task, originally i was
Then just use the discord.py's task framework, if you want to create multiple just create another task
You can have N amount of tasks, you just need to use the framework
thats the problem, it wont let me create another task
You're gonna need to show the code you had trouble with
It shouldn't be blocking you from creating the second task
@pliant gulch so are you gonna accept novas core pr🏃
for the random module can i do rand = (randit(<emoji>,<emoji>))
what core pr
plant_growth(self, ctx, trayid, number) #params already defined
@tasks.loop(seconds=10.0)
async def plant_growth(self,ctx,trayid,number):
wait nvm that was mooncell
wait
the rin pfp confused me
i forgot to put start real quick
@pliant gulch Task is already launched and is not completed.
You seem to have started it else where already
Perhaps it was the call you did earlier?
Not sure exactly what you mean, but do keep in mind, plant_growth isn't a function anymore. It's a dicord.ext.tasks.Loop
Why are you calling it, E.g plant_growth(...)?
hydrotray() is the function that calls the plant_growth
because its what the name implies. to simulate plants growing by their stats depending on what you do to them
Yes, but it isn't a function anymore
for the random module can i do rand = (randit(<emoji>,<emoji>))
the decorator makes the plant_growth into a Loop instance
so it chooses random emoji
im not talking about that, the function that calls and starts the plant_growth loop is called hydrotray() which is once again mentioned in a command
Well, I'm just trying to see where else you are starting the task from. You could you know, actually show the hydrotray function to give more context
And Loop implemenets __call__ but as a coroutine. Your call is just gonna create a coroutine object
its not that important other than to check a few things, and to start the loop
so whats the best thing for me to do?
The context here is pretty important
I'm not you, I can't see your code unless you send it
Will Somebody help me?
i know that but its really not that important other to check if the bot has a random seed generated, which it plants (starts the loop) but ok
Help me.The command does not work and does not display an error in the console, why? the command worked a few days ago
async def hydrotray(self, ctx,number,trayid):
if plt.endswith("Plant"):
try:
plant_growth.start(self, ctx, trayid, number)
except Exception as e:
await ctx.send(f"ERROR: {e}")
else:
return
How many times is hydrotray presumed to be called?
As you know, are you mentioned earlier this runs after a user runs a command
I think, at least. But you never stop the loop afterwards
once per the command is runned
So if the user ran the command twice, it would attempt to run the loop twice
You can see the issue there perhaps
thats what i want it to do
Then help me with it.
Not working
@bot.event
async def on_member_update(before, after):
channel = bot.get_channel(942917598079762492)
if before.display_name != after.display_name:
await channel.send("nickname edit")
print("work")
Yea, but you need to gracefully stop the loop first, then you may run it again
Is there a reason you need to overlap the loops?
yes because i got 4 trays for the users to experiment with
maybe if it's for multiple guilds
1 tray for per user usually
then it would be a requirement
It doesn't make sense to use multiple loops here
You should just have one genesis loop, which starts at the beginning, then making the command append a data to a mutable object inside of the task, which then checks it
E,g a dictionary, then having the commands append new data to the dictionary, then when the interval comes around you read it, parse it, etc
what does it report then, what happens instead?
It would be a lot easier, and safer then what you are trying to do
thats what i tried to do but my brain started to suffer from brain failure and i backtracked alot
As the behaviour your gonna get is pretty much undefined
mk
check if the event gets triggered
Ok
Nothing. The command worked a couple of days ago, now it does not work, there is no error in the console. (Before that, there was an embed in the team, but I removed it, and the command still did not work)
^
How?
printing something
As here?
@bot.event
async def on_member_update(before, after):
channel = bot.get_channel(942917598079762492)
if before.display_name != after.display_name:
await channel.send("nickname edit")
print("work")
no rn its inside of an if statement just on the start of it
so no matter the condition it will get triggered
so bascially , to fix it you need to identify there the problem occurs
at which step
then why
just do a few prints in between steps
to check from where it stops working
how can i check if a member created discord account at least 7 days ago (using if else estructure)
docs for disnake looking crispy since menudocs collab
whats the exception that gets raised when a bot cant dm a user forbidden or a http?
And how do this?Console doesnt output anything.
Forbidden is a subclass of HTTPException
then youre missing intents
step 1. read docs
step 2. think
step 3. extract awnser from thoughts
step 4. recreate the awnser in your IDE of choice
ah so an http
i mean forbidden raises a 403
yeah
just print a few random strings between every step, if one doesnt show up then you know where the problem is
Ok
It almost looks exactly the same other than some utility stuff
Between what steps?
@bot.event
async def on_member_update(before, after):
print("shite 1")
channel = bot.get_channel(942917598079762492)
if before.display_name != after.display_name:
print("shite 2")
await channel.send("nickname edit")
print("work")
something like that
Ok,Im going to try now
show tb
[!] shanghai bot initialized | version: 2.0
> Guilds: 1
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\jackr\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 690, in _parse_arguments
next(iterator)
StopIteration
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\jackr\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "fear.py", line 85, in on_message
await client.process_commands(message)
File "C:\Users\jackr\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 976, in process_commands
await self.invoke(ctx)
File "C:\Users\jackr\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\jackr\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 855, in invoke
await self.prepare(ctx)
File "C:\Users\jackr\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 789, in prepare
await self._parse_arguments(ctx)
File "C:\Users\jackr\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 693, in _parse_arguments
raise discord.ClientException(fmt.format(self))
discord.errors.ClientException: Callback for about command is missing "ctx" parameter.
Console doesnt output anything
Can you run print(dict(bot.intents)) inside of your code, outside of a command. Like above the bot.run call?
Ok
Send what it says as well 
Yes,doesnt work.Will be find mistakes.
when do what andy says, the intents may be the issue
Bot say.'Bot' object has no attribute 'intets'
intents
...
Console does output.{'guilds': True, 'members': True, 'bans': True, 'emojis': True, 'integrations': True, 'webhooks': True, 'invites': True, 'voice_states': True, 'presences': False, 'guild_messages': True, 'dm_messages': True, 'guild_reactions': True, 'dm_reactions': True, 'guild_typing': True, 'dm_typing': True}
What is it?What i am doing wrong?
Can you show the spot where you added the on_member_update event? Like where it is in the code
Wait
@bot.event
async def on_member_update(before, after):
print("B 1")
channel = bot.get_channel(942917598079762492)
entry = list(await after.guild.audit_logs(limit=1).flatten())[0]
user = entry.user
if before.display_name != after.display_name:
print("B 2")
await channel.send("nickname Edit")
print("work")
I mean where it is in the code
Ok

When running paginator how do you tell it how many commands per page you want?
It would depend on your code
I'm trying to split it so there are 6 commands per embed, with 1 field each. Then appended to embeds which paginator will run through.
why
PEP8
okay
So is there a way to fix that?
pep8 is just a style guide, improves readability, it's not something holy, but still recommended to follow if it improves your code readability
It is holy
it is holy
in Python terms
follow it or else
you will be hunted down
Can the discord bot reply to a message with an embed?
How would you use paginator to split commands into groups of 6, each command having a field in an embed. This embed is appended to embeds which paginator will automate.
I changed it the screenshot is from before
If this helps you at all, the new edited version
It does help
!d discord.Message.reply
await reply(content=None, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").
New in version 1.6.
yeah
you can use discord-ext-pages to do that
It keeps giving me this
Use the embed kwarg
await reply(embed=your_embed_variable_here)
k
I tried
wait did I/
alright whatever, it's not necessary but I will need it in the future
the example is a bit long.... and i dont understand much of it lol
ok
then use the paginator you have right now
make it split stuff every 6 items/commands)
is this of any use for me?
idk
What are u trying to do?
this
@pine crypt
how would i do that? append to a different list in groups of 6?
U can count iterations and on every 6th iteration you do whatever u gotta do, but there is probably a better way
Are you making a help command?
yes
!d disnake.ext.commands.Command.help
The long help text for the command.
!d disnake.ext.commands.MinimalHelpCommand preferably use this though since .help is a kwarg of commands
class disnake.ext.commands.MinimalHelpCommand(*args, **kwargs)```
An implementation of a help command with minimal output.
This inherits from [`HelpCommand`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.HelpCommand "disnake.ext.commands.HelpCommand").
why disnake
!d disnake.ext.commands.DefaultHelpCommand you can also use this if you only want to add pagination
class disnake.ext.commands.DefaultHelpCommand(*args, **kwargs)```
The implementation of the default help command.
This inherits from [`HelpCommand`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.HelpCommand "disnake.ext.commands.HelpCommand").
It extends it with the following attributes.
Subclass HelpCommand class
.
I dont use disnake what is it?
It’ s a fork
Replace disnake with discord and you got the same result. I just use disnake.
Dont bother
bad library
Disnake is currently along with nextcord the best maintained fork of discord.py
I prefer disnake
Do I have to go learn disnake because I want my command to be as simple as possible
no
You alr know it
Well if you know discord.py you know disnake.
Also It’ s a fork
ffs use the correct documentation
So It’ s almost the same
Dw It’ s pretty much the same
they said this
use the proper documentation
stop misleading people
Dw they know now
He/she hasn't even told us what library their using.
It’ s all good
Hmm?
ye
Just make a class that inherits from HelpCommand class and help urself with the docs to make ur own help command
You can make confusing commands with disnake, so, no
Wdym
Does anyone know why I no longer receive error messages to my logs in pycharm>
so I can't see the error
like only when a command fails
Do u have error handler?
Yes, it wont display in the console if you have a handler
Is there a way to do it with discord.py because I understand that more
Disnake is a clone of discord.py so you can use same stuff in both
What I told u to do works with both
Imma go watch yt tutorials
hey panda
Hello
💀
bad way of learning how to use d.py
^
hyd 
If you have on_error event or smth. You can put an else clause where you log the error into console
Everyone has their own way of learning.
Yes
Fine rn wby?
No, use docs
im better now
How so?
cuz youre here
:3

Dpy tutorials on YouTube makes me gotta shit
how would you split groups of commands into 6
then go bro
whos making you not
I’ m not watching em dw
ok good
Well this isn't even discord.py related this is just splicing a list.
its for my bot
ok
!e ```py
print(list(zip(*(iter(range(100)),) * 6)))
@cloud dawn :white_check_mark: Your eval job has completed with return code 0.
[(0, 1, 2, 3, 4, 5), (6, 7, 8, 9, 10, 11), (12, 13, 14, 15, 16, 17), (18, 19, 20, 21, 22, 23), (24, 25, 26, 27, 28, 29), (30, 31, 32, 33, 34, 35), (36, 37, 38, 39, 40, 41), (42, 43, 44, 45, 46, 47), (48, 49, 50, 51, 52, 53), (54, 55, 56, 57, 58, 59), (60, 61, 62, 63, 64, 65), (66, 67, 68, 69, 70, 71), (72, 73, 74, 75, 76, 77), (78, 79, 80, 81, 82, 83), (84, 85, 86, 87, 88, 89), (90, 91, 92, 93, 94, 95)]
could this be done with numpy?
Idk i don't use numpy.
But as long as it is iterable i don't see why not
Nice
what does that even do
button.callback=button_callback may be what you mean
!e ```py
print(list(zip(*(iter(range(100)),))))
@cloud dawn :white_check_mark: Your eval job has completed with return code 0.
[(0,), (1,), (2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,), (10,), (11,), (12,), (13,), (14,), (15,), (16,), (17,), (18,), (19,), (20,), (21,), (22,), (23,), (24,), (25,), (26,), (27,), (28,), (29,), (30,), (31,), (32,), (33,), (34,), (35,), (36,), (37,), (38,), (39,), (40,), (41,), (42,), (43,), (44,), (45,), (46,), (47,), (48,), (49,), (50,), (51,), (52,), (53,), (54,), (55,), (56,), (57,), (58,), (59,), (60,), (61,), (62,), (63,), (64,), (65,), (66,), (67,), (68,), (69,), (70,), (71,), (72,), (73,), (74,), (75,), (76,), (77,), (78,), (79,), (80,), (81,), (82,), (83,), (84,), (85,), (86,), (87,), (88,), (89,), (90,), (91,), (92,), (93,), (94,), (95,), (96,), (97,), (98,), (99,)]
hi i wanted to create some kind of users private channel but text channel is there a way to allow them to add members to this channel but to not allow them break anything
and i dont know what permission it would be if thats possible
It creates an iter object that gets unpacked then packed into * x
you need channel name
you should be able to fix that.
!e
print(",".join([str(n) for n in range(100)]))
@slate swan :white_check_mark: Your eval job has completed with return code 0.
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99
!d discord.Interaction.user
The user or member that sent the interaction.
!e ```py
print(",".join(map(str, range(100))))
@pliant gulch :white_check_mark: Your eval job has completed with return code 0.
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99
A faster way of doing what you did
show code
what does map do
jeez you impress me everytime
no button_callback takes the argument interaction. then use interaction.user
oh ik now
Map just runs a function on all elements in a sequence
yeah i just saw
thats really good
does vsc have that function😔
Yo guys!
I want to include a font. I've done this like that. The font-file is in the same dir as the bot but I want to access to the file if it is in a fonts folder. How I have to change that?
Idk, I'm using ipython's magic functions
😔 sed
List comp and map are usually around the same speed, it depends on what you are using as the function in map that determines the speed other than the element amount
so in interaction.guild.create_text_channel make the the first and only arg interaction.user
If it was a lambda I'm sure the list comp would've been faster in this case
But since we can construct a str via str it would be faster
thats cool
so you get the user object with interaction.user. YOu pass that as the argument for interaction.guild.create_text_channel so it would be await interaction.guild.create_text_channel(interaction.user)
oh maybe try interaction.user.name
You can't put objects in a file
no
str(interaction.user)
what do you mean by "didn't work"
I said str(interaction.user)
I don’t see the str()
put it inside the await interaction.guild.create_text_channel()
With interaction.user inside the brackets for str
how do i handle a timeout error
await ctx.send("stuff")``` i tried this but it doesnt work
what does async def mean
Specifying a function to be run asyncronously
ok
It's asyncio.TimeoutError
i mean
i can send in dms
its an rps command
Traceback (most recent call last):
File "C:\Python310\lib\asyncio\tasks.py", line 456, in wait_for
return fut.result()
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\nikit\PycharmProjects\test\venv\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\nikit\PycharmProjects\test\main.py", line 481, in rpsco
msg = await bot.wait_for("message", check=check, timeout=5)
File "C:\Python310\lib\asyncio\tasks.py", line 458, in wait_for
raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\nikit\PycharmProjects\test\venv\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\nikit\PycharmProjects\test\venv\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\nikit\PycharmProjects\test\venv\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TimeoutError:
```gives me this
hello im trying to make a random emoji command and i get this error saying discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: can only concatenate str (not "list") to str and i dont know what to add or remove
here's my code
rand = [':smile:', ':smiley:', ':grinning:']
@client.command(name= 'mood')
async def mood(ctx: commands.Context):
await ctx.send("your emoji is ".format(random.choice(rand)))
async def mood(ctx):
rand = ["emoji1", "emoji2", "emoji3"]
randemj = random.choice(rand)
await ctx.send(f'your emoji is {randemj}')```
you can do it like this
just replace bot with client
@naive spoke
oh ty
you can just do
@bot.command()
async def mood(ctx: Context) -> None:
await ctx.send(f'your emoji is {random.choice(["emoji1", "emoji2", "emoji3"])}')
its the same thing really
um
i still get the error
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: can only concatenate str (not "list") to str
yeah but memory efficiency
i dont think its the command then
show full traceback
why people use .format stuff when f strings exist
It could be useful in applications where otherwise f-strings wouldn't work
Imagine having placeholder text and formatting that
Can be easier to read if the var is complicated, and also you can use the same var multiple times
E,g a on member join message that the user can set
You wouldn't use f-strings for that, rather keep it as a regular string and call .format
You have a point but still, most of the times you would want to use f string over format and in his case is not really necessary .format
Sure, most cases you can use f-strings but in your message you asked why people still use .format when f-strings exist
I agree on that part, that you wouldn't really use .format often
Although it does keep backwards compatibility as well for older version of python
!e say you had this
user = "Anonymous4045"
message = "lol"
#you wouldnt do
print(f"Message from {user}!/n{user} said; {message}”)
#instead, you would do
print("Message from {0}!/n{0} said {1}”.format(user, message))
O
!e say you had this
user = "Anonymous4045"
message = "lol"
#you wouldnt do
print(f"Message from {user}!/n{user} said; {message}")
#instead, you would do
print("Message from {0}!/n{0} said {1}".format(user, message))
@oblique laurel :white_check_mark: Your eval job has completed with return code 0.
001 | Message from Anonymous4045!/nAnonymous4045 said; lol
002 | Message from Anonymous4045!/nAnonymous4045 said lol
not following pep8
atleast make code that follows pep8
I dont see how that’s relevant lol
if you question pep8 then question python as well
I question why the frick u care man lol
pep8 is a code guide which every developer should follow if you dont, dont think youll get a job or will succeed
👍
youll get bullied for it and allot
print ("got it")
most devs do care about it @final iron aka my friend here
Just a matter of preferences, if you can type {0} you can just also say directly {user}
backwards compatibility
Im giving u reasons why ppl do it, not syaing theyre logical lol
try to read text from a five year old that doesnt know about grammar
pain isnt it?
But the var also could be smth like guild.fetch_member(id).roles or smth long
code efficiently not fancy
Simple is better than complicated
and?
PYTHON ZEN!!!!
No, not in this case. It's actually the other way around. f-strings are faster than .format
A good case would be templating
Wdym by faster tho
its quicker
!e ```py
placeholder = "Hello {0}, welcome to {1}"
def fmt(name: str, place: str) -> str:
return placeholder.format(name, place)
print(fmt("Andy", "Home"))
@pliant gulch :white_check_mark: Your eval job has completed with return code 0.
Hello Andy, welcome to Home
By like how much tho lol. Doubt its very significant for smth like this
most companies do care about ms differences
This is abt discord bots fam lol
and?
Doesn't mean you shouldn't be aware of stuff like this
U seem to rlly like that word ngl
your point is irrelevant just saying
"Doubt its very significant"
The difference in time is huge actually
send it
In [3]: name = "Andy"
In [4]: place = "Home"
In [5]: def func() -> None:
...: return f"Hello {name}! welcome to {place}"
In [6]: placeholder = "Hello {0}! welcome to {1}"
In [7]: def func2() -> None:
...: return placeholder.format(name, place)
In [8]: %timeit func()
81.9 ns ± 1.05 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
In [9]: %timeit func2()
206 ns ± 4.38 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)
125 nanosecond difference
wtf
Doesnt seem like much lol
I'm looking at the total to the very left
bro
oh i thought i was just dumb
🏃
does anyone here have a discord bot that does auto-roles
hmm
Right here .
!e
!eval [code]
Can also use: e
*Run Python code and get the results.
This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*
dms
no
@hoary cargo why i cant get it
Get what
!e
print("what")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
what
oh
🗿
@candid maple :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 'bot' is not defined
!e
print("hi binds")
@slate swan :white_check_mark: Your eval job has completed with return code 0.
hi binds

!e
!eval [code]
Can also use: e
*Run Python code and get the results.
This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*
anyways #bot-commands
!e
print(“hi okimii”)
@slim ibex :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | print(“hi okimii”)
003 | ^
004 | SyntaxError: invalid character '“' (U+201C)
wtf
Mobile moment
“” what are thoseeeeeeee
how to create a box like tat
“”
Cant relate
!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.
!code hi
this is a certified iphone moment
!src eval
Run Python code and get the results.
!code
'“”' != '""'
fucking mobile
fact
Hold down on the ‘
though some people still code on mobile for some reason
Pain
^
@hoary cargo i dmed you..
ares if you spoonfeed i swear
big pain
I was joking when I said right here
sadge
!e !code print (12
@candid maple :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | !code print (12
003 | ^
004 | SyntaxError: invalid syntax
i think he ment the channel
!e
!eval [code]
Can also use: e
*Run Python code and get the results.
This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*
that's one of the reasons dm help is usually discouraged because 1. we don't know if they're being taught something wrong, and 2. they could spoonfeed and we would be none the wiser
#bot-commands 😠
!e
!eval [code]
Can also use: e
*Run Python code and get the results.
This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*
- tos
Yea, most of the times people selfbotting will want low-key help
!e !code print (90)
see how i didnt follow the number🏃
@candid maple :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | !code print (90)
003 | ^
004 | SyntaxError: invalid syntax
You can usually tell right away someone is self botting by the print stattements, E.g a lot of Fore.RED etc
It's hilarious
You could be put at risk for assistance someone to break TOS so it's discouraged
!e print(2)
or the dang name of the module
I mean
Speaking of colours, I should add an ANSIBuilder to rin that just makes ANSI code blocks
Didn't discord.py at one point allow you to use your own token?
Since discord supports ANSI escape codes
//sd//
havent learned them still lol
They are pretty handy to know, you should take a look at the wiki https://en.wikipedia.org/wiki/ANSI_escape_code
ANSI escape sequences are a standard for in-band signaling to control cursor location, color, font styling, and other options on video text terminals and terminal emulators. Certain sequences of bytes, most starting with an ASCII escape character and a bracket character, are embedded into text. The terminal interprets these sequences as command...
Very informative
what is ansi?
read the above 🗿
[0;35mthis is ansi
bro the term
😭
i know now tho
and the raw text tho
check the pins
cool stuff
yes but i still dont know them lol
same
🏃
someone good at python discord bot pls dm me fr
i need to add a role when bot starts
i know discord ID and role ID
how i do it ? please help
It's @bot.event not @bot.command()
OK ty
and the rest please?
Wait
no bro
i got autoban from my server
ive no idea how
just need to do that when my bot starts
or how do i unban on on_ready?
with my bot
!d discord.Guild.unban
await unban(user, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Unbans a user from the guild.
The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to do this.
!d discord.Client.get_guild
get_guild(id, /)```
Returns a guild with the given ID.
Utilise these
wdym you got auto ban from your server
is that possible
bru
I NEED TO CHECK WHAT HAPPENED MAN
i ve never opened python
but ive this bot with perms
on the server
so basically you know nothing about python nor discord bots
Because pep8 is holy. On a more serious note, it really helps with readability and if you ever work on a team, not following it can really fuck you over
Do you know any python basics?
just smth bro
but i watch on yt
its easy to do with add_role thing
learn python first, then make a bot.
atleast the basics.
just need to add to a specific member a specific role
ITS A ONE TIME THING
i will enver need python again
Anyway
just help if u can pls
My command won't work when I use @client.event to auto delete message
Why do you need python for that
my bot is in the server
this is strange af
Change .event to .listen() for the on_message event
just help idk why i explained why i need it
Oh okay thx
just ask someone to unban you no?
he sleeping
the only support
im sacred i got hacked
pls no.
but doesnt seem
so if u can
ive my ID
where do i put it
you need the server's id too
ok ive
but the bot already start
on the server when i run it
it logs just fine
Hii everyone, just a basic question... So, actually i was wondering is there any discord bot which can be integrated with Google Calendar or any Calender and then could be used to notify give friendly reminder to members about upcoming meetings and just 5 min prior to the event if it could share the Google meeting link automatically?
its my member id
will work?
You don't have a context
does Google have an API for that?
No
what it means
can u just tell me the command pls pls?
ctx stands for context.
Yaap
bro u will help me so so so a lot if u tell me the full command
pls help a poor guy
well then you might like integration the API with your bot and use tasks.loop
we won’t spoon feed
just wait for your friend to come online
BUT MAN u really cant?
Idk how an owner gets banned from his own server.
ME EITHER
THATS WHY I WANNA MAKE IT FAST
what if you are not the owner
because it's impossible to get banned from your own server
Late but me or the other dude? Lol
Even if you use ban command to ban yourself
not you, person with the server ban
haa😅 haven't tried building any discord bot... So, far I am only working as Web & Flutter Dev
It's impossible
No because you cannot get banned from your own server
Are you the owner or just have role "owner"
I wasnt the server amding
the account got termed
i was a second account with owner perms
bruh
what
So you aren't a owner. You just have administrator perms
Only one acc can be the owner
I am the owner my SErver admin account got termerd
termeddddd by discord

I could guess why
XD
So you do have an experience with programming
You would have to utilise the Google's Revalent Api endpoints, and use the discord python Library
It has a tasks module using which you can check if the meeting is starting every second
if yall help me ill let u know how i got ban
looking at register
How do i set avatar url as variable?
owner_avatar = bot.get_user(owner_id).avatar url #uhh????```
I don't understand the documentation
Not interested in knowing it.
ok then just help
lmao what is this discord for
just to say "there is google"
Let's clear this up. Were you the owner of the server or not
yes
Need an _ after avatar instead of a space?
That is impossible
That works, with py avatar.url # if v2.0+ or py avatar_url # if 1.7.3=/-
just tell me the command
we are not discord police or something
A server owner cannot get banned
I KNOW THATS IMPOSSIBBLE
SERVER OWNER ACCOUNT WAS TERMED
I WAS JUST OWENR WITH PERMS
Yeah I'm not helping you. You're sketchy at best
so you were not the owner

So what does he want lol
I'm out.
man this really gives me vibes from yesterday
theres no way
I have tried some things but all it does is produce attribute error
File "D:\SoftDev\Discord Bots\emilia-me\core.py", line 22, in on_ready
owner_avatar = bot.get_user(owner_id).avatar.url #uhh????
AttributeError: 'NoneType' object has no attribute 'avatar'```
Every second 🙈 I feel it might be quite redudent... but, yaa possibly 5min
You don't have member intents
these statements doesn't add up 
bro
i forgor
and python haave lib for bots I didn't knew that thanks
There are like 10 of them atm lol
Theres a lib for everything
🤨
why can't this chat ever be clean.
legit
Idk
cuz u cold have helped me hour ago and i was out
Yea theres always smth goin on
😅
Whats your problem?
you sell accounts and you want to be helped?
Y u even selling accs if u cant program lol
you're too sus for someone to help you
Because F.U.N.

come dm
<@&831776746206265384>
cause I can't help you with that.
- I won't spoonfeed
- I provided you with the docs
- Why would someone help you in getting unbanned from a server you claim to be your's and you don't want to share the reason for getting banned
- "This would be the last time I'll be using python" if that's only to get yourself unbanned wait for the friend to wake up?
if u dont believe me
come dm ill proof
Please read our #code-of-conduct, that behavior is not appropriate here.
bro do u know smth python?
dawn is a pythonisto 🙃
just do it here.
Curse us out then ask for help, smh
Th
@slate swan DM advertising is not pog champ
add me then u will come here and say everyone to apologize with me
@slate swan Calling people "useless bitches" is not acceptable here and will not be tolerated.
ok bro sorry do u know python discord bot?
If you expect we do lol
I do not
nice grief , but please stay calm mate
come dm ?
u will tell everyone sorry
someone ban this dude 💀
Alright, what's the matter here?
I doubt that's going to happen after what you said, I suggest you calm down and ask your question with a level head
Looks like dude is tryna sell accs
In which case that's in direct violation of rule 5 and we can't help you with that here
thats not true
Judging by this lol
That is very true, feel free to read #rules for yourself
could u accpet friend req pls it will legit take 5 mins
thats not true im trynna sell accs
what is happening in this chat 💀
Which is against Discord's terms of service
You pass in a snowflake, not an int
could you show more of you code
And please don't use words like that even for yourself :)
Or it could be the fact
You can construct your own snowflake like so:
discord.Object(id_here)
You trying to use context in on_ready
hey dont worry.... I believe everyone is say right it would be bto wait for your friend to come back
Don't use on_ready for much except printing, it has the tendency to get called multiple times for seemingly no reason
And you have parenthesis on on @bot.event
bro i legt never used python thats the probem
Is your bot on the server you got banned?
no its no
Then maybe you shouldn't be making bots with discord.py, it's by no means a beginners library and you should consider getting a firm understanding of the language first
Then it can't be
!resources has some excellent guides
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
its just a one time thing i wont ever need it
No hard feeling with saying the r word on myself
anyways,
import ...
owner_id = int(settings["owner"])
intents = discord.Intents.default()
intents.members = True
bot = Bot(command_prefix=settings["prefix"], case_insensitive=True, intents=intents)
@bot.event
async def on_ready():
print('Hey, I have connected to the internet.')
await bot.change_presence(activity=discord.Game(name='Bot Testing'))
owner_avatar = bot.get_user(owner_id).avatar_url #uhh????
bot_avatar = bot.user.avatar_url
bot_name = bot.user.name
bot_id = bot.user.id
onreadyembed = discord.Embed(description=f'I am now online as {bot_name}.', color=0xF44AFF)
onreadyembed.set_author(name="Status Report", icon_url=bot_avatar)
onreadyembed.set_footer(text="by Circle", icon_url=owner_avatar)
onreadyembed.timestamp = time
await bot.get_channel(channel_cmd).send(f"||<@{owner_id}>||", embed=onreadyembed)
it's in this
