#discord-bots
1 messages · Page 527 of 1
Is it?
Haha
well this isn’t related to discord bots so take it somewhere else
oops
#bot-commands
U a mod?
ROFL
no
he really said that
Dont act like one
i don’t have to be a mod to tell you to go to #bot-commands
use your brain for a second
Try that in ur ide not w eval comand lmao
Hi, it's possibl to send a hidden message without slash commands please ?
Try it in ur ide
sum([len(item) for item in iterable])
dude the code you used is not comparable to what we were testing
It’ s not
Ok thanks you
nono i made the code all back into python
print(sum([len(item) for item in iterable]))```
Needs to be interaction
all of these come with python
what do you think that line of code does 🤔
Bro just do len(unsplitted_string)
Yeah oof with ! command
thats not what im trying to do
Its for later
i can do it if i interact with !command ?
Ohh okok
Probably not
Only interaction response object can send that kinds of messages
ok thanks 😄
wait hold up..
what did he define item to???
in len(item)
OH WAIT FOR LOOP, that's why my thing was wrong
it said "from" 🤣
that is basically comparable to the last line
although len(str) would count the whitespaces and that code wont
So now
after i do this
I can pretty just use iter() in a loop to read every list ye?
value in the list*
alr cool
i may have an one liner of it in my old bot , let me check
@commands.command()
async def rolemembers(self, ctx, role: discord.Role):
if len(role.members) > 0:
text = ', '.join(['`' + str(i) + '`' for i in role.members])
if len(text) > 3170:
text = ", ".join(
(text[0:3170]).split(',')[:-1]) + ', And more...'
else:
text = '0 Members'```
something like that but you shouldn't try to copy from this, it might be confusing for you
and it splits the text by , btw
i noticed
and more xD
lol
why spoonfeed
@sullen shoal oh i just realized.. im gonna have to use join to connect them right?
He didnt mean to, i'm not taking any of the code he gave me
just gave him an idea
Im gonna problem solve it
well depends on how you are doing it
well what im gonna do is append each item to a list
then if the chars get to big
we move on to another list
i might be overcomplicating this
pretty sure
what are you going to do to not cut the words in half still make it under 2000 length
so pretty much
if it reaches 2000 or more when im counting the iter
im just not gonna include it in the list
and move on to another list
That was the idea, but im pretty sure thats overcomplicating
:/
hold up lemme do a bit of thinking rq
you can try what ever u want but dont always stick to same kind of solutions like this, try to be better every time
k
ill try
oh wait
i think i got
a way i can make this less complicated
I can "combine" all the previous values and make them 1
so like im editing the list as i go down the for loop
instead of making new ones
well not really less complicated
but like "easier to read the code"
like less clutterd
oh the correct syntax for this is join
just checked the api
so what i can do is, once it reaches the char limit, i can join the pervious list and continue on. Once the list limit reaches its max the loop ends like how it normally should. Then I can send the messages by intering the new list
thats alot of spaghetti tho
aight
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 300, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 254, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\lucas\grass.py", line 37, in <module>
client.run(token)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 723, in run
return future.result()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 702, in runner
await self.start(args, **kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 665, in start
await self.login(args, bot=bot)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 511, in login
await self.http.static_login(token.strip(), bot=bot)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 304, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
Exception ignored in: <function _ProactorBasePipeTransport.del at 0x00000107C8858C10>
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in del
self.close()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon
self._check_closed()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Need help with this, works well on my PC but not working when i run it in a windows dedicated server
Checked the packages all were same version and dowloaded
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized
Exception that’s raised when an HTTP request operation fails. -> https://disnake.readthedocs.io/en/latest/api.html?highlight=httpexception#disnake.HTTPException
maybe the token isnt right?
did u even read the error
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
Regenerate your token back
regenerate it in the developers screen
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
items = rconpayload.split()
currentLen = 0
previousLen = 0
lenLimit = 2000
iteritem = iter(items)
for item in next(iteritem):
currentLen += len(item)
if currentLen >= lenLimit:
items[previousLen:currentLen-1]= [' '.join(items[previousLen:currentLen-1])]
previousLen = currentLen
currentLen += lenLimit
items[previousLen:]= [' '.join(items[previousLen:])]
for item in items:
await ctx.send(item)```
@sullen shoal If this goes first time imma go nuts
wait wtf im dum, i added currentLen += lenLimit for no reason. Oops lemme remove that
wait tf im so slow lmao, I did items[previousLen:currentLen-1]= [' '.join(items[previousLen:currentLen-1])] all wrong. Forgot i need to state the INDEX its in, not the INDEX LEGNTH
hi guys, i'm trying to run my bot code but i have a problem, when i try to run it it gives me the client.run error
it gives me an unauthorized login and a 401 error does anyone know how to fix?
It literally tells u
"unauthorized login"
ok but the token is correct
U sure about that?
yes
yes but it gives the same error
If the code didnt work it would said loginfailure
token*
mb was thinking of the wrong error lol
You getting rate limitted or?
Improper token has been passed. (he tells me that)
yes
yes
fix it then
if its not working regenerate
also make sure u using the bot token not the application id or smth
I have already tried, but it gives me the same error
yes
are u doing client.run(token)?
yes
Is it your bot or?
ok uh
does anybody know how to put that ban command in an embed instead of a normal message i have been trying but i cant find out
@client.command()
@commands.has_permissions(ban_members=True)
async def unban(ctx, *, member):
bannedUsers = await ctx.guild.bans()
name, discriminator = member.split("#")
for ban in bannedUsers:
user = ban.user
if (user.name, user.discriminator) == (name, discriminator):
await ctx.guild.unban(user)
await ctx.send(f"{user.mention} wurde entbannt.")
return
!d discord.Embed
class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
u can create an embed variable and then send it to the channel
!d discord.abc.Messageable.send
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**.
u did context.send but ok
yeah i was looking for the right name for it
@slate swan so, do you understand the problem?
Yes, but what i dont understand is how its not working for you
Is that the only error your getting?
nope
oh?
yes
Send full error
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 352, in _run_event
await coro(*args, **kwargs)
File "/home/runner/bonbons/cogs/events.py", line 13, in on_member_join
member_role = guild.get_role(880030723908722729)
AttributeError: 'NoneType' object has no attribute 'get_role'
``` why?
its telling you
your object is not a discord.Role
guild is None
I also get errors like staticlogin, loginfailure, not autorized etc
discord.Guild*
hm
discord.Guild mb
i did ```py
guild = self.bot.get_guild(880030618275155998)
because your variable guild is None
at the same time?
yes
most probably your bot is not in that guild or your guilds intent is disabled
it can return None if bot not ready
is it in that guild?
I have discord.Intents.all()
Who is doing intents.None?
yes
??
@boreal ravine add self.bot.wait_until_ready() before defining guild
then maybe the first option
!d discord.Intents.none
classmethod none()```
A factory method that creates a [`Intents`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents "discord.Intents") with everything disabled.
wdym
only this one have guild intents disabled
?
isnt get_guild coroutine
no
wait it is?
for some reason my bot cant ban
...
shouldnt be there be an error "object was never awaited" if it was a coro?
i know
!d discord.ext.commands.Bot.get_guild
get_guild(id, /)```
Returns a guild with the given ID.
yes it should be so its not
!d discord.Client.get_guild
get_guild(id, /)```
Returns a guild with the given ID.
wdym?
@boreal ravine oh btw
someone said get_guild was a coro
wasn't sure
But it wasn't so I said there should've been an error like that
@boreal ravine can you just add await self.bot.wait_until_ready() before defining guild?
yes brb
get_guild not need an event, only fetch_guild needs
The guild isnt cached
no
?
it cant be not cached
lol
only if you did some very very weird bad shit
Why not?
should I run a command before re-joining on my alt to make it cached or something?
get_guild gets a guild from cache
try fetching it, it might not have been cached
did you add wait_until_ready and it didn't work?
explain
import discord
from discord.ext import commands
class Events(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_member_join(self, member):
self.bot.wait_until_ready()
guild = self.bot.get_guild(880030618275155998)
member_role = guild.get_role(880030723908722729)
no_pfp = guild.get_role(896697171108327475)
channel = guild.get_channel(880387280576061450)
roles = [member_role]
if member.avatar.url is None:
roles.append(no_pfp)
print(f"{member} joined with no pfp.")
await member.add_roles(*roles)
await channel.send(f"{member} joined!")
def setup(bot):
bot.add_cog(Events(bot))
``` heres the full code
hey i didnt made any help cmd, and i guess its automatically, i want to know that how can i customise it??
If it's cached then why is it returning None?
!d discord.ext.commands.Bot.remove_command
remove_command(name)```
Remove a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") from the internal list of commands.
This could also be used as a way to remove aliases.
await self.bot.wait_until_ready()
awaaait
customize not remove
its a coro??
Yea
oh
you can use the in-built help command customization thingy
!d discord.ext.commands.HelpCommand
class discord.ext.commands.HelpCommand(*args, **kwargs)```
The base implementation for help command formatting.
Note
Internally instances of this class are deep copied every time the command itself is invoked to prevent a race condition mentioned in [GH-2123](https://github.com/Rapptz/discord.py/issues/2123).
This means that relying on the state of this class to be the same between command invocations would not work as expected.
The help command implementation to use. This can be dynamically set at runtime. To remove the help command pass None. For more information on implementing a help command, see Help Commands.
Thanks it worked.
thx :))
@reef shell @sullen shoal @lament mesa
Bot caches guild when it joins it (in any status, to it's cache that can't be cleaned by users)
That's all, if you can imagine some way to not cache it, idk how your brain works)
The only way when bot.get_something not works is when bot is not ready and didnt get it's cache, because that i said to do wait_until_ready
oh 
ho
Where did i say not to cache it?
i thought u meant that it's not cached
^
I said this, and people are using different forks of dpy and some of the forks have Intents.none() by default
yeah, so the bots cache wasnt ready and empty, so it was returning None...
how can i dowload pictures posted from other users with a bot and safe them on a ubuntu server?
How to reply message in on_message event discordpy?
!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.
ok thanks
Can someone help me with a command?
the command is pretty messy
and im making it so that if we react to an emoji it'll delete the message (I have to wait_for thingys I cant get it to work
Hey, I'm trying to make a discord.py music bot. However, it only can play in one server or guild at a time. How do I make it so that it play in multiple places simultaneously? Please help.
Here's the code: https://pastebin.com/wxPpgYnc
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
@bot.command()
async def get_members(ctx,role_name):
role = discord.utils.find(
lambda r: r.name == role_name, ctx.guild.roles)
for user in ctx.guild.members:
if role in user.roles:
await ctx.send(user.mention)
any1 knows how to get 1 random member in the set role
@boreal ravine
random.choice(role.members)
i tried that
but I'm doing wait_for for 2 reactions
so like
await ctx.send(random.choice(role.members))
yes
thanks !
return user == message.author and (str(reaction.emoji) == '👍' or str(reaction.emoji) == '😳') @boreal ravine
check the reaction.emoji
^^^^^^^^^^^^^^^^^^^^^
meaning?
@bot.command()
async def get_members(ctx,role_name):
role = discord.utils.find(
lambda r: r.name == role_name, ctx.guild.roles)
for user in ctx.guild.members:
if role in user.roles:
await ctx.send(random.choice(role.members))
still returns multiple members
use the check or another if statement
@bot.command()
async def get_members(ctx,role_name):
role = discord.utils.find(
lambda r: r.name == role_name, ctx.guild.roles)
await ctx.send(random.choice(role.members))```
ur using a for loop
import random
makes sense
Awesome !!!
Aesomew !!!
awseome!!
he did it
can someone help me with this please
r, u = await bot.wait_for("reaction_add", check=...)
if str(r.emoji) == "something":
await message.delete()
```like this probably
use guild.voice_client's
or pass the str(reaction.emoji) == "something" in the check
should I define reaction.emoji as the emoji I want it to be?
that alone should get it working?
!d discord.Guild.voice_client
property voice_client: Optional[VoiceProtocol]```
Returns the [`VoiceProtocol`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceProtocol "discord.VoiceProtocol") associated with this guild, if any.
my bad, edited it
alr thanks
pass the emoji you want in the "something"
@bot.command()
async def get_members(ctx,role_name):
role = discord.utils.find(
lambda r: r.name == role_name, ctx.guild.roles)
choice = random.choice(role.members)
await ctx.send(choice)
this returns the members name with #1234
how do i get their nickname or name
sorry still kinda new to python
choice.display_name
property display_name: str```
Returns the user’s display name.
For regular users this is just their username, but if they have a guild specific nickname then that is returned instead.
last question verry sorry
guild = bot.get_guild
role = discord.utils.find(lambda r: r.name == 'Vip', guild.roles)
how would i get the guild without ctx cause i want to get the roles of my guild
- use your params
- get guild
you already have that as I see guild = bot.get_guild but pass there ID of your guild, like guild = bot.get_guild(185012745013)
it didn't work :(
why
I did ```py
reaction, user = await self.bot.wait_for("reaction_add", timeout=30.0, check=remove)
if str(reaction.emoji) == "❌":
await send.delete()
@boreal ravine
@client.event
async def on_message(message):
# Do Something
def check(reaction, user):
return user == message.author and (str(reaction.emoji) == 'emoji_1' or str(reaction.emoji) == 'emoji_2')
try:
reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check)
except asyncio.TimeoutError:
# Do Something if 1 minute finished and user didn't press the one of two reactions
else:
if str(reaction.emoji) == 'emoji_1':
# Do Something if user pressed emoji_1
else:
# Do Something if user pressed emoji_2```
specify a guild lol
bot.get_guild(123)
but
im making a ✅ and ❌ type of thing
I'm not sure that works that way
how do the high tier music bots work, like hydra for example when it comes to using spotify songs?
edited @boreal ravine
thanks XD
details = "+".join(location)
r = requests.get(f"https://timezone.abstractapi.com/v1/current_time/?api_key=&location={details}")
res = r.json()
await ctx.send(res)```
Someone please help it just returns empty brackets
what do you enter as location?
Moscow
add a * after ctx
Yup
that wasn't related to the error , but the 2nd line of the code...
try ```py
async def test(ctx, location):
details = "+".join(location)
r = requests.get(f"https://timezone.abstractapi.com/v1/current_time/?api_key=&location={details}")
res = json.loads(r.text)
await ctx.send(res)
maybe that
Lemme check
and try printing the status code, r.status_code
yes he did +.join(location) so its gonna search for +Moscow i think?
or he has no api key
nah it depends, sometimes websites dont reply with json and instead you just get the text ¯_(ツ)_/¯
I have an API key
😑
did you place the api key into the reqiuest
because it seems like you didnt
I did
You want me to send the API key to you lol
You want me to make the API key exposed to everyone?
Huh?
no just wouldve been better to do this when showing code
async def test(ctx, location):
details = "+".join(location)
r = requests.get(f"https://timezone.abstractapi.com/v1/current_time/?api_key=&location={details}", headers= {"apikeywhatever": "then change the actual api key"})
res = json.loads(r.text)
await ctx.send(res)
so we know that you actual do provide the api key
I did enter an API key I removed it from the code
did you place it in a header?
with a request, it would probably want it sent in a header
Not necessarily
can you send the website link? please
1 min
Abstract API | API suite for developers
lemme log in rq
This is what their example suggest
import requests response = requests.get("https://timezone.abstractapi.com/v1/current_time/?api_key=key&location=Oxford, United Kingdom")
print(response.status_code)
print(response.content)```
yup
don't use requests though, it's blocking. use aiohttp since it's async
I ain't..
requests is blocking
IDK how to use aiohttp
it's simple
Tell me
async with client.get('http://python.org') as resp:
x = await resp.text()```
??
thats an example
that is the same as requests, but aiohttp, which is async
look at the documentation
Ok
read through this, https://www.w3schools.com/python/
thxx
https://docs.aiohttp.org/en/stable/client_quickstart.html has everything you need to know
ok, thx for this :))
!d discord
I don't wanna read the whole docs for something so simple
ok, thx for this :))
welcome to programming my friend, you'll need to read docs
anyway it's litrally labelled "json request"
thats not for you, haha but take a look
async with session.get('https://api.github.com/events') as resp:
print(await resp.json())``` not really hard to find
IK but why do I need to learn it when I can use requests
yea ik, but still i wanted to know some more basics :))
cool ig have fun
use requests then but dont come back here crying when your bot stops responding while it's making requests
Pfft!
for some reason i never knew about aiohttp
aiohttp is elite
so thanks aswell, you have taught me something
WHY WHY WHY
yea thx, i am beginner thats y i don't know enough of this...
look through the thing i said first, then advance from there.
lol it's really not hard py async with session.get('https://api.github.com/events') as resp: print(await resp.json()) if you can't use this example for what you need then you should probably learn basic python
ok, i will read that, thx buddy :))
len(guild.emojis)
```is a thing?
All emojis that the guild owns.
ok forgot to edit
this since yesterday can't be the cause why huh?
I have used it before just I don't want to use something I don't understand
Is that top.gg?
try to understand it then, it's better practise
Hmmmmmm
it's pretty much the same as requests, just async
I see
yes
You need to wait for a month
Your project has not been approved yet.
I think I made a mistake, that's why it hasn't been released yet
Hey guys where do I learn wait_for?
top.gg takes time of atleast a week to approve a bot
!d discord.Client.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
Ok thx
ok
explain ?
Which lib are you using
dpy doesn’t have any slash commands support
it have
no
That's totally not dpy
so many peoples told me that it have slash commands buttons and selects
(2) know your lib. name first
(3) know your lib. name first
i know that -_-
No you don't
its discord.py
discord.py don't have any class named SlashCommand
As i said
i searched google
Know your library
....
but i don't know that it have slash commands or not
i cannot use two different libraries together ?
you can use extensions
which ?
like we can use discord.ext.menus which is not a part of the original library
no you have to use a fork or any extension (if exists) that supports slash commands
So far It's all good
idk, that should be known by you
^
As you are using
tis a github page
how do u not know
what lib your using
thats the lib name
say that lmao
No?
i know it is written there
Can you not read
but the code is similar
The readme
who
i told that i saw that
MrinalSparks#8633
its literally a fork
i also installed that
i cannot use fork with it ?
i think you should better ask in their support server..
i've never heard of this fork
I use a fork which have slash cmd support but It's not stable yet
just use edpy
everything so far is it have is good
how i can switch :/
!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.
thx
I want to get the user and tag of the author. But i get only the name(without the tag #xxxx)
@Bot.command()
async def load(ctx, extension):
Started_Time = time.time()
await asyncio.sleep(1)
Bot.load_extension(f'cogs.{extension}')
Task_Embed = discord.Embed(title="Task Completed.", description = f"[-] Succesfully loaded {extension}.py", color=discord.Color.blue())
Task_Embed.add_field(name="More Info", value=f"[-] Command executed by {ctx.author.name}\n[-] Command executed at {date.today()}[-] Command executed within {time.time()-Started_Time} seconds")
await ctx.send(embed=Task_Embed)```
ctx.author.name returns the members username, to get the discriminator use ctx.author.discriminator or str(ctx.author)
property name```
Equivalent to [`User.name`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.name "discord.User.name")
so only ctx.author
no
Yeah
ctx.author.name
yeah
that returns the hash though? (kayle#000)
str(ctx.author) or {ctx.author.name}#{ctx.author.discriminator}
yeah
as they said^
already using that
oh
name is only the username
yeah, use ctx.author
ye
I thought he asked how to remove the hash my bad.
I have to use discord.py like a year lol
if ctx.author didnt work, add str as sir @odd pendant said
it's ok
isnt it already a string
ctx.author == ctx.author.name + "#" + ctx.author.descriminator
True```
it is but just in case
k works
what even is this
!e
print(type("Radium8844#2160"))
@boreal ravine :white_check_mark: Your eval job has completed with return code 0.
<class 'str'>
dont even need all this
I just explained how it works...
that wont work
Discord does not add # in the middle of the string that defines the author name
and the discriminator
hm not documented
It does not work like that
I mean this method doesnt work like that
that code makes no sense regardless so dont post garbage please
The hell happened
I should explain it like this?
member: discord.Member
print(str(member) == member.name + "#" + member.descriminator)``` or what?
Hi. I deployed my bot into heroku and when I open it's domain, it shows application error. What does it mean? (Bot works correctly)
stickers = str(len(guild.stickers))
```is not a thing?
why though
IT does not add 2 seperate things
If the bot works correctly we cannot help you here sorry
The author.name is one thing
Why?
just say that str(ctx.author) is the same as member.name + "#" + member.discriminator
doesnt combine the name and discriminator
I mean isn't sth wrong with host?
im here to get help to make a discord bot, is this the right channel?
heroku is not designed for discord bots
Because sometimes when I say "hello" to bot, it replies me with two hello
Something wrong?
it's a web host, nobody should recommend heroku for this purpose
can somebody help me?
But I deployed it.
just ask
What is good for bots?
idk then, i am not very good with the4 hosting stuff
uh, so im stuck. i've installed python 3.10 and im stuck
AttributeError: 'Guild' object has no attribute 'stickers'
yes but you're using it for an unintended purpose, we can't really help you with it
we are all ears
So what do you suggest for hosting it??
did you update dpy to 2.0 version?
This channel is related for discord.py
? idk what to do now
Where do I have to go?
i'd recommend just paying for a cheap vps and hosting it on a proper os
aight
help channels
did you make sure you added python to PATH?
now tht...i shall check
uh no
do i delete it and try again?
re-tinstall and make sure to add to PATH
just run the installer again
What's your problem?
have you tried to write any code yet?
are you stuck making a script or?
okay, ill ping u when im done
no im installing it lol
aight take ur time
thanks :)
...Np i guess?
aight
@slate swan
open your CMD
from start? or from a file
ok
how?
github i think
a channel #guild-news
there is info about how to install it
@slate swan
do it
thats just a warning
its nothing
thenks
dw
oh
so what do i do
happy coding!
then learn
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
oh
Lol
Could I be able to get my bot working in like less than a day
With like 5 commands
wdym?
you could get a bot working in about 5 seconds
do you know Python?
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix="!")
@bot.command(name="ping")
async def command_ping(ctx: commands.Context) -> None:
await ctx.send("pong")
bot.run("bot token")```
How long u think it'll take*
depends
I know literally nothing
2-3 months usually
not even python?
Nothing
Please learn python before discord.py
No coding, scripting
bruhhhh
You literally have to
name**=**"ping"
discord.py is not a easy lib, if you don't understand Python you will be in a lot "pain"
it is easy lib
So it's gonna take 3 months to learn the thing that will only get me started
oh yeah lol i pressed it but i guess my keyboard just wanted to say no
@weary galei suggest you first start by reading python for dummies
discord.py isn't hard at it's basics lol
yes
well yes, but for complete new one it will be a bit hard
Is there no faster way
you have to learn
Learning is not fast always
some people learn faster than others
@weary gale read Python for Dummies, learn a few libraries like asyncio, tkinter and OS. Then you will be able learn dpy in no time as well as have a good backround
why tkinter
But if you decide to just jump into discord.py, you will not be able to make a proper bot.
wth is tkinter, never used it
it's a gui lib lol
for windows and UI
I considered myself intermediate until starting discord.py. The concept of asynchronous programming hurt my brain
uh windows, i am an ubuntu user)
kinda same
i started python with discord bots, no prior python knowledge
python for dummies
yes
now it's really easy but I wouldn't call discord.py an easy lib, depending on what you're doing
dpy is easy, databases and classes hard
I do not recommend that. You'll be confused whether while working on Discord bots or any other thing using Python. Please learn at least the basics before jumping into Discord bots.
They are not if you have learnt Python first.
Literally nothing in python is hard if you learn it in a good order and step by step
super secret information: everything is not hard when you learn it
python is an extremely easy language but everyone should still start from print("hello world")
this applies to every single activity in existence actually
100%
i started with print('Bye my life!')
could u dm me a link pls? i dont even know which thingys to thingy
!e
class cons():
def log(self, value):
print(value)
console = cons()
console.log("Hello, world!")
@dapper cobalt :white_check_mark: Your eval job has completed with return code 0.
Hello, world!
thx
=
print("Hello, world!")

PythonScript, haha.
wanna see java-python?
no
😦 my bad python huh
yes
no, im not talking about the implementation
ill dm it
sure thing
PHPython, lol.
static void print(String value) {
System.out.println(value);
}
public static void main(String[] args) throws Exception {
print("Hello, world!");
}
That?
oh gwad
I think we're going pretty off-topic tbh.
shall dm it?
Sure.
I hate you.
You have ruined python
Then don't check #bot-commands.
He hates you
LMFAOOO
I am crying on the inside
It’ s so funny
this better https://pastebin.com/FETQmseQ
Make a bot in CSS and I will pay you $500.
!e py open(1, "w").write("Hello World!")
@bright palm :white_check_mark: Your eval job has completed with return code 0.
Hello World!
xD
!e
class Cheese():
def __init__(self, Aamount):
self.amount = Aamount
self.holes = Aamount-1
def getFinalAmount(self):
return self.amount - self.holes
#prints if less cheese is equal to more cheese
print(Cheese(1).getFinalAmount() == Cheese(4).getFinalAmount())
I just realized I messed up the logic
meh
i really thought i can be paid by making bot in something like C, but when I remembered what is CSS I understood xD
if the reward is high enough, someone out there will find a way to exploit a a browser renderer from within CSS to execute code and then use that to make a bot 😂
Well you can execute external JS code from CSS, but then it's no longer a pure CSS bot
In everyone's eyes, what would be your favorite third-party discord py slash command libraries
hello guys, i have a channel that is cloned when someone enter and it is moved on other category based on member's role
there's some command to set channel permission as the category the channel is moved in?
that still works well with dpy
discord-py-interactions
!d discord.TextChannel.edit
await edit(*, reason=None, **options)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the channel.
You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.
Changed in version 1.3: The `overwrites` keyword-only parameter was added.
Changed in version 1.4: The `type` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
Depends on your IDE
If your using vsc should be vsc .
If your using nvim should be nvim .
Not sure then, the only thing I use now is nvim
Maybe you don't have it to path or whatever
do i need to add anything to the file i opened cmd from?
Oh wait try doing code .
i have
new_channel = await after.channel.clone(name=f'Dungeon di {member.name}') await new_channel.edit(category=categoria) await member.move_to(new_channel)
should i set like
``` new_channel = await after.channel.clone(name=f'Dungeon di {member.name}')
await new_channel.edit(category=categoria, sync_permissions = True)
await member.move_to(new_channel)```
or
new_channel = await after.channel.clone(name=f'Dungeon di {member.name}')
await new_channel.edit(category=categoria)
await member.move_to(new_channel)
await new_channel.edit(sync_permissions = True)```
yes i did and i did that but nothing worked
first one
tried with new app, regen nthing works
ooook i try thank
how do I make my discord bot send a dm but what to say and the userid will be provided by a webhook
!d discord.User.send
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**.
but how do I connect the webhook and the bot?
!d discord.Webhook
class discord.Webhook```
Represents an asynchronous Discord webhook.
Webhooks are a form to send messages to channels in Discord without a bot user or authentication.
There are two main ways to use Webhooks. The first is through the ones received by the library such as [`Guild.webhooks()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.webhooks "discord.Guild.webhooks") and [`TextChannel.webhooks()`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.webhooks "discord.TextChannel.webhooks"). The ones received by the library will automatically be bound using the library’s internal HTTP session.
The second form involves creating a webhook object manually using the [`from_url()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Webhook.from_url "discord.Webhook.from_url") or [`partial()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Webhook.partial "discord.Webhook.partial") classmethods.
For example, creating a webhook from a URL and using [aiohttp](https://docs.aiohttp.org/en/stable/index.html "(in aiohttp v3.7)"):
the webhook will say the id with <@> in the channel and I want the bot to see the ID and than send DM to the person
terminal yes
ok
I have a discord bot that depends on the Quart API that i have written myself. I'm running the API in a different thread but the problem is that the bot became very slow. It takes at least 20sec for the bot to respond to the command
didnt work
Does anyone have suggestions for improving the performance ?
Show me your console
Type python file_name.py or python3 file_name.py
quart has app.run_task, which is an async function, and use client.loop.create_task to run it
it will run it in the background
lol
still comes up with an error
do python file_name.py and replace file_name with your file name @weary gale
yeah i did
show me what you did
i did
and dont know how to use it
he did
what is your file structure?
uh
like this
they started just like 1-2 hours ago with zero experience (iirc) and decided to jump right into dpy
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
already sent that to him
im trying to follow a video
videos are most likely outdated and don't teach
the point is, it's super annoying to have to help someone with zero knowledge
please learn python
xD
you do a favor for yourself as well
yes
bruh
you should use cogs (recommended)
client, =, no cogs
do i replace that with commands
im very confuse
When i do it like this the API is only up for like 5 seconds after that it doesn't respond
and commands.bot is a module, it should be commands.Bot
@weary gale just an example of something not outdated
oh
if you really don't want to learn Python then at least take a look at this tutorial about dpy https://vcokltfre.dev/
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
ok
are you even using d.py? or am i jus tripping
yes I am using discordpy (2.0v)
is there any critical changes yet? (in API)
i mean you should move your bot over to slash cmds
they will all take effect in april 2022
so you have time to switch over
well I'm the only user of the bot so I wait till a good wrapper.
It's only for verified bots though
yeah
oh so i literally do these first two commands?
but still, my bot in 80+ servers rn so its kinda useful
main bot is in 18k
that's just a part of tutorial, yes you have to do that as well. But read the tutorial with time
thx
import discord
from discord.ext import commands
from pathlib import Path
import json
cwd = Path(__file__).parents[0]
cwd = str(cwd)
print(f'{cwd}')
secret_file = json.load(open(cwd+'/config/config.json'))
bot = commands.Bot(command_prefix = '!', intents = discord.Intents.all())
bot.config_token = secret_file['TOKEN']
@bot.event
async def on_ready():
print('Bot Is Now Ready')
bot.run(bot.config_token)```
basic bot using a secret file to hide things such as a db key and token
!d os.getcwd
os.getcwd()```
Return a string representing the current working directory.
oh damn i didnt know that existed lmao
whats that
learn python
bot.config_token = secret_file['TOKEN'] is impossible at least because bot is referenced before assigment
Can somebody please help me out with running a Quart server in the background of a discord bot
how can i actually run the command
shush my bad im not gonna try for an example lmao

with space?
python nissan_bot.py
install an IDE such as Visual Studio or Pycharm and you can run it thru there or go to ur directory and open a cmd and put what master32 said into it
yes with space
it would be python "nissan bot.py"
in quotes
^
i do that in terminal?
yeah
yes
in quotes
didnt work..
whats the error msg u get
that should work mate
IN QUOTES
no such file or
IN QUOTES
OH
just copy and paste what i said 
python "nissan bot.py"
ok
Is there someone with experience of using Quart + Discord.py ?
uh
@weary gale send me a screenshot of this panel
Damn what r u coding lmao @tough wagon
this?
framework as you see
Click the green play button at the top right
Cool
Laravel ?
im making my own framework
what
Laravel's structure is much more complex 
im doing that to know what am I working with
@weary gale open the terminal and send a screenshot of all your screen
@weary gale
Laravel looks more like that
you use bot.run even you did client = commands.Bot().
there should be a playbutton up there that is green
Can someone help me out
I try use to use role name for command access and how to make error for it when user don't have a require role sorry for bad grammar
Anyone ? 😢
ive never used quart
What is even Quart
thats not on mine
ok in there
what
@weary gale first do client.run(token), not bot.run(token), second do python bot.py in terminal
hehee)
Something similar to flask that you can use to make a API or webserver
^
So why not using Flask?
hm
LMAOOOO why you pay for winrar 😭
Can someone please help
It's much more popular and probably has a bigger community behind it
in quotes
we would help if we understood what you said
@commands.has_role('RoleName')
Before your command definition
?
no
no
doesnt work
show error
show a screenshot
...
OH
I am pretty bad at grammar
Sry
Because Quart is async
wait a min i might be able to fix on my own
lol ok
lol k
Pretty sure Flask also supports async
!pypi quart
congratulations xd
now i need to do everything else
now use cogs
whats that
he is not ready i think
Makes sense.
i used them after 1 year i started)
@weary gale did you read the tutorial I linked?
Yeah but they say that Quart is better to use with discord.py
At first i tried this
I started nearly immediately with cogs, was a bit confusing for a few days but I got used to it very quickly
(Don't use if you can) Run a Flask app and a discord.py bot in one program using threads. - webserver_and_bot.py
still on the first couple things
still reading tho
But this absolutely killed the performance of my bot
This is not how Flask's async function works XD
