#discord-bots
1 messages Β· Page 961 of 1
4 line await ctx.send(f'Successfully delete {amount} messages')
Literally already answered
He already fixed it an hour ago
webhook_list = []
for webhooks in webhook_list:
try:
book=Webhook(webhooks)
print(book)
book.send("Hello!")
except:
print("Invalid Hook")
pass```
I did not pay attention to time
This For method is taking much time what to do
I want to send it in like a sec!
As long as your internet is fast enough and ping is low, that should happen in a second or smth (not taking into account, the ratelimits tho)
Isn't webhook.send a courotine
!d discord.Webhook.send
await send(content=..., *, username=..., avatar_url=..., tts=False, ephemeral=False, file=..., files=..., embed=..., embeds=..., allowed_mentions=..., view=..., thread=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message using the webhook.
The content must be a type that can convert to a string through `str(content)`.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object.
If the `embed` parameter is provided, it must be of type [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") and it must be a rich embed type. You cannot mix the `embed` parameter with the `embeds` parameter, which must be a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects to send.
Changed in version 2.0: This function will now raise [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "(in Python v3.10)") instead of `InvalidArgument`.
That too
You're missing a paranthesis
Whole error plz
Above
coroutines = [channel.send(embed=embed) for channel in fetchedchannel]
await asyncio.gather(*coroutines)
Probably
Uh

this is for channels
but i though it can work for webhook too

Can you help please with eg how can i do it?
using coroutines
How do i make sure it prints when an option is chosen in the dropdown?
Subclass SelectMenu
he can't subclass Bot how do you pretend he can subclass SelectMenu π
But euh, Discord.interaction doesnt exist it sais
Bro, nothing to laugh at, here
!d discord.Interaction
class discord.Interaction```
Represents a Discord interaction.
An interaction happens when a user does an action that needs to be notified. Current examples are slash commands and components.
New in version 2.0.
because it doesn't 
i am on 2.0, so why isnt it working?
and another fun fact
respond doesn't exist too 
It's Interaction, not interaction
see the capital i? yeah, when you code lowercase and uppercase matters
Also doesnt work

yeah, but its the interaction that gives an error
capital I or not, still the same error
yup still lowercase i
if the error is still there with the capital I then you're not using d.py 2.0
They might be using some lib that monkey patched interactions into dpy
Because
on_button_click doesn't exist
can i update it by using the terminal?
hello, im trying to make it look like this (with the persons avatar and on the bottom say who typed the command) but its only doing this (no avatar and it doesnt say who did the command on the bottom)
what do I have to type in the terminal
this is the code
hey, I have a quick question. Is the @task.after_loop run after every loop or after the loop is completed (as in after is stops/gets cancelled)
you are setting the embed thumbnail and footer after sending it
it sounds so simple but I don't get it how to do that
i didnt realise this, its not saying like Ronan!#2137
U forgot an f
Before string starts
f"{1}"
Hunter is smart
ahhh yeah, today is just full of brain farts lmao
heya Skev
Hello
hi
Hello
How do i install discord py 2.0.0 via terminal
nice
pip install git+https://github.com/Rapptz/discord.py @little ivy
Yes
okay
why though
and how do i do that? lol
Because it π΅ patches dpy
pip uninstall discord-components
ppffftttt and dont ever use that term like that
Lmao
Back to trying to learn js the way i did with python
nim > js
What is nim
I have these :/
Language
Sorry cap
most of the people are using the outdated version who are waiting for 2.0 lmao
Hello yerlikaya how is the disnake community treating you
Yeah, it cant find GIT
I can bet if he sets an anime pfp, then he's gonna get a few DMs lmao π
Lmao i also left the dpy server
you miss the f string
After seeing your encounter i searched for encounters like yours in the server
Lmao nvm
I found a ton
Also i'm in like 89+ servers
I don't even talk there or go there
So i might as well leave
yeah i got it ty
Yerlikaya about to go on a fishing spree
y e s
I'll be the first one to DM I would love to see who DMs u the first π
A virtual environment
nope
they do
but,
a dropdown or buttons wont work without that v2 version or what?
yeah i know, but how is it possible i still can sent button and dropdown messages than?
buttons are components too
so i can send those, but cant respond to the interactions?
discord-components is bad since it uses a wait_for and is a third party library which isnt optimized
so yeah, the problem isss: when i install the v2, my whole script wont work anymore
well yeah, there are a lot of breaking changes in dpy 2, and....you will have to eliminate everything written with discord-components and write it with dpy 2
i dont really understand that but....is your git version outdated or smth
your favourite server uwu
@hushed galleon minigame has not an attribute "bot"
could you just type git in your terminal? if it says that the command is not found you dont have it added in your PATH variable
what do i need to type in my terminal?
git
it means that git is not added to your PATH
and how do i fix that
idk how to do that in windows but have this
https://www.answerlookup.com/how-add-git-windows-path-environment-variable
Steps to set Windows PATH Environment Variables for GIT
how do uninstall git π
Control Panel
Mhm
Where
select "you" ticket..
She dk the context
...
install git ||maybe||
tbh i'd just suggest installing github desktop
it installs git along with it easily
didnt you already download git though?
Do you want me to find one for you
from cgi import print_form
from dis import disco
from http import client
from pydoc import cli, describe
from turtle import color, title
from unicodedata import name
import discord
import os
from discord.ext import commands
client = commands.Bot(command_prefix="!")
@client.command(aliases=['user','info'])
@commands.has_permissions(kick_members=True)
async def whois(ctx, member : discord.Member):
embed = discord.Embed(title = member.display_name , description = member.mention , color = discord.Colour.red())
embed.add_field(name = "ID" , value = member.id , inline = True)
embed.set_thumbnail(url = member.avatar_url)
embed.set_footer(icon_url= ctx.author.avatar_url, text= f"Requested by {ctx.author.name}")
await ctx.send(embed=embed)
client.run(os.environ['TOKEN'])```
I want to add something so only a certain role can use the command, what do i do
!d discord.ext.commands.has_role
@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.
If a string is specified, you must give the exact name of the role, including caps and spelling.
If an integer is specified, you must give the exact snowflake ID of the role.
If the message is invoked in a private message context then the check will return `False`.
This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")...
Use this check decorator
You can use the name of the role
But using the id is recommended
#bot-commands
sry wrong channel
perfect ty :)
@client.command()
async def img(ctx):
imag = imag.new("RGB", (200,200) , (0,255,255))
imag.save(format="PNG")
await ctx.send(file=discord.File("imag.png"))```
Command raised an exception: UnboundLocalError: local variable 'imag' referenced before assignment
?
please see
it isnt working still
i hear v1 still supported for a year

Did you even import it
It must have given a different error now if you changed it to Image.new ?
^
yeah
yeah
Command raised an exception: UnboundLocalError: local variable 'image' referenced before assignment```
did you read the error
you called on image before you assigned it
it's Image.new (import it first)
@client.command()
async def img(ctx):
image = image.new("RGB", (200,200) , (0,255,255))
image.save(format="PNG")
await ctx.send(file=discord.File("image.png"))```
hm
what would image.new be?
an image object?
or a file obj
image
yeah
hmmm
from PIL import Image
I dont think you can do that directly
image.save(fp=r'./image.png', format="PNG")
i try it wait
@granite parcel

you dont even need to specify the format tbh
i don't but i just did anyway
I mean, no normal person would save their file as a jpeg and name the file extension as png

yes true, it automatically saves it in the format the image is in
so if the image is a png for example then i'd be image.png.png
well, its not gonna make much of a difference other than just show an extra .png in the filename
its good for hiding dangerous executables
i know lol, but that's useless cuz everyone has view extensions enabled
not everyone
a normal device user wont
who doesnt know much about computers
not yet
it's useless however, windows will pick it up and also, it'll say on the side for example: windows executable
not possible yet
workarounds are possible
well
Is there a way with heroku connected to a github repository to use database (Not mongodb)
Connected how?
CI/CD pipeline integration?
Case matters
?
image = Image.new(...)```
i did that
And yeah you need to provide the path to save the image to
hello, can ask for help here?
What do you need?
How to fetch the time of a message in PY?
Like:
Your message has been sent at (time when the message was sent)
!d discord.Message.created_at
property created_at```
The messageβs creation time in UTC.
@client.command()
async def img(ctx):
image = Image.new("RGB", (200,200), (0,255,255))
image.save(fp='./image.png', format="PNG")
dfile = discord.File(filename="image.png")
await ctx.send(dfile)```
@vale wingsee
cant get member.activity correct
what?
@tasks.loop(seconds=5)
async def check_streaming():
await bot.wait_until_ready()
guild = await bot.fetch_guild(GUILD)
member = await guild.fetch_member(user_id)
print(member.status)
printed value is "offline"
!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.
intent
show code
you should on it from dev portal
did you enable it on developer portal?
are you sure it's the same bot application?
!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.
!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.
import os
import asyncio
import discord
from discord.ext import commands, tasks
from discord.utils import get
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')
user_id = os.getenv('discord_user_id')
member_state = ''
urls = ''
bot = commands.Bot(command_prefix='.', intents=discord.Intents().all())
@tasks.loop(seconds=5)
async def check_streaming():
await bot.wait_until_ready()
guild = await bot.fetch_guild(GUILD)
member = await guild.fetch_member(user_id)
print(member.activity)
return
check_streaming.start()
bot.run(TOKEN)
client is not used, my bad left that trash
are you sure it's your ID?
i turned on this today. Maybe some time needed for it to be turned on
its instant as i know
just wanted a feature that would link my yt stream in text channel, well maybe i should try another way. meh
did you say meh
meh
π₯³
why do you fetch everything bro
you have all intents just use get
i am not a big experienced one
!d discord.Guild.get_member
get_member(user_id, /)```
Returns a member with the given ID.
Changed in version 2.0: `user_id` parameter is now positional-only.
needs member intents but you do have them
no?
get_guild
he has the guild in cache
he has every intent
get_guild(id, /)```
Returns a guild with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
member = guild.get_member(user_id)```
for member yes
tried like this
yeah, but idrk the point
!d disnake.Guild.getch_member
await getch_member(member_id, *, strict=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Tries to get a member from the cache with the given ID. If fails, it fetches the member from the API and caches it.
If you want to make a bulk get-or-fetch call, use [`get_or_fetch_members()`](https://docs.disnake.dev/en/latest/api.html#disnake.Guild.get_or_fetch_members "disnake.Guild.get_or_fetch_members").
wasn't it a thing?
maybe, it hasn't for me yet
of guild
Oh hm makes sense
it returns AttributeError: 'NoneType' object has no attribute 'get_member'
you can consider guild.getch_member as well
bot.get_guild returns None.
Is that the right guild ID and is the bot in it?
yes
how is this bookmark command?
fetch is ok with that
@slate swan get back to the anime pfp π
d a m n c o o l
@slate swan hunter has turned, we cannot trust him
AAAAA lightmode
hunter
meh
hunter's name was return Hunter if python === js
how do i send a dm through interactions, this doesn't work, it doesn't throw errors or anything
@discord.ui.button(label='Book Mark Current', style=discord.ButtonStyle.green, emoji='π')
async def bookmark_current(self, interaction: discord.Interaction, button: discord.ui.Button):
message = await interaction.user.create_dm()
await message.send(embed=self.pages[self.current_page])
which would throw an undefined and an else missing error
Udk the context
ig member.send
How
just get a member object and .send like usual
that doesn't work either
How?
error?
what do you mean?
i'm pretty sure ```py
guild = bot.get_guild() or bot.fetch_guild()
its not, normal dm command works it just the interactions
its a bad idea :3 just use a database so ppl can use custom welcome message
try sending 'hello world' instead of an embed, just to check
hmm that works
so then it is probably the embed
should i use await on this?
or await
and now if i am want to get member i use member = guild.get_member(user_id) right?
!d discord.ext.commands.Bot.fetch_guild
await fetch_guild(guild_id, /, *, with_counts=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") from an ID.
Note
Using this, you will **not** receive [`Guild.channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.channels "discord.Guild.channels"), [`Guild.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.members "discord.Guild.members"), [`Member.activity`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.activity "discord.Member.activity") and [`Member.voice`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.voice "discord.Member.voice") per [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member").
Note
This method is an API call. For general usage, consider [`get_guild()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_guild "discord.ext.commands.Bot.get_guild") instead...
how do i get a invite
guild = client.get_guild(851841115896152084)
How to do this that every time the thumbail image changes as color value change
pls anyone
you can';t
well, not from a guild directly
you need to get it from a channel
how?
so (await (client.get_guild(851841115896152084).channels[0].create_invite())).url
in condensed form
ok let me try
or just so (await (guild.channels[0].create_invite())).url
@quaint epoch
see mine
what?
.
hmm
i guess you can use PIL
!d PIL.Image
it should allow you to change the color of it by rgb values
I tried once
then just save the image, load it in the embed, then delete it after
r: 'coroutine' object has no attribute 'url' @quaint epoch
user_id = int(os.getenv('discord_user_id'))```
show the line @nimble plume
what is this?
now i have working bot.get_guild
without transforming env values to int get_guild didnt worked
how to leave a server from id
await guild.leave()
ok
alr
lemme check
bro
?
oh
.fetch is
so i remove await
invite = (await (self.bot.get_guild(id_here).channels[0]).create_invite()).url
there
unknown channel
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10003): Unknown Channel
show the full traceback
Ignoring exception in command sld:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/ext/commands/core.py", line 169, in wrapped
ret = await coro(*args, **kwargs)
File "/home/runner/nuker-1/utility.py", line 160, in sld
invite = (await (self.bot.get_guild(g.id).channels[0]).create_invite()).url
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/abc.py", line 1160, in create_invite
data = await self._state.http.create_invite(
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/http.py", line 416, in request
raise NotFound(response, data)
disnake.errors.NotFound: 404 Not Found (error code: 10003): Unknown Channel
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/ext/commands/bot_base.py", line 570, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/ext/commands/core.py", line 920, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/disnake/ext/commands/core.py", line 178, in wrapped
raise CommandInvokeError(exc) from exc
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: NotFound: 404 Not Found (error code: 10003): Unknown Channel
guild = self.bot.get_guild(id=id_here)
channel = guild.channels[1]
invite = await channel.create_invite()
invite_str = invite.url
i guess doing it on one line would be unnecessary
ok
how do i use
secud = (". ".join([f"{msg.content}"async for msg in\
message.channel.history(limit=int(1))][::-1])).lower()
but instead of 1 message or 2 messages it just gets the entire channel?
limit=None
hello
i have a problem
@bot.event
async def on_member_join(member):
embed= nextcord.Embed(title= "Welcome!", description=f"**Hello {member.mention}!**\nWelcome to **{member.guild.name}**!", color=nextcord.Colour.random())
embed.set_image(url="https://c.tenor.com/Ch4VFEjuI7IAAAAC/anime-boy.gif")
welcome=member.guild.system_channel
await welcome.send(f"Hey {member.mention}",embed=embed)
this is my welcome event
this works on 1 bot
but doesnt work on the other
but in script
thx
np
guys any help?
you dont have member intents on the other bot
MEMBER OBJECT HAS NO ATTRIBUTE ADD ROLES? WHAT
How can I use disable_all_buttons() in my command function, instead of waiting for someone to press a button
do you need help or..?
!d discord.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
??
!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.
Anyone know how I can make it so it gets the channel name instead of channel id
E.g channel = client.get_channel(942450268585472051) how can I make that for channel name instead of id
Hello, the error is for the boxed-in line **User** object is not iterable
!d discord.ext.commands.Bot.fetch_channel
await fetch_channel(channel_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`abc.GuildChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel "discord.abc.GuildChannel"), [`abc.PrivateChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.PrivateChannel "discord.abc.PrivateChannel"), or [`Thread`](https://discordpy.readthedocs.io/en/master/api.html#discord.Thread "discord.Thread") with the specified ID.
Note
This method is an API call. For general usage, consider [`get_channel()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_channel "discord.ext.commands.Bot.get_channel") instead.
New in version 1.2.
Changed in version 2.0: `channel_id` parameter is now positional-only.
Not id the name
No not it it gets the name of the channel and doesnβt get the id
what if that is a voice channel or a category
g.id exists
Yes
.
Thanks
I am making a dashboard for my bot
Then how can I make it iterable
I am trying to get this to run π
But the User object is not iterable
you shouldnt put a slash after the endpoint name in routes
I did
dont mind me but...well
yes, dont
So if I remove it
Would it run?
I am trying to get the guilds that a user are in
with the manage_guild permission
So you can set a prefix inside the dashboard
?
oh ok
Nextcord
Now my permissions parameter is broken
Well, 'Permissions' object has no attribute 'manage_server'
I did
π
I am using discord-quart, and I installed nextcord-ext-ipc
And that worked
Cause it's manage_guild OHHH
Breh
Modules used to make dashboards
Yeah
ipc -> Inter Process Communication
Traceback (most recent call last):
File "main.py", line 238, in <module>
bot.run(SIKE U THOUGHT TOKEN WAS HERE HEHE)
File "/home/runner/Romba/venv/lib/python3.8/site-packages/nextcord/client.py", line 730, in run
return future.result()
File "/home/runner/Romba/venv/lib/python3.8/site-packages/nextcord/client.py", line 709, in runner
await self.start(*args, **kwargs)
File "/home/runner/Romba/venv/lib/python3.8/site-packages/nextcord/client.py", line 673, in start
await self.connect(reconnect=reconnect)
File "/home/runner/Romba/venv/lib/python3.8/site-packages/nextcord/client.py", line 614, in connect
raise PrivilegedIntentsRequired(exc.shard_id) from None
nextcord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
ξΊ§ 172.18.0.1 - - [07/Apr/2022 15:38:38] "GET / HTTP/1.1" 200 -
can someone help?
Enable intents
hunter knows everything
Nice
how?
e x p e r i e n c e
It should be member
i think
Wym
how to disable all buttons in a view when they press one?
property guild_permissions```
Returns the memberβs guild permissions.
This only takes into consideration the guild permissions and not most of the implied permissions or any of the channel permission overwrites. For 100% accurate permission calculation, please use [`abc.GuildChannel.permissions_for()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel.permissions_for "discord.abc.GuildChannel.permissions_for").
This does take into consideration guild ownership, the administrator implication, and whether the member is timed out.
Changed in version 2.0: Member timeouts are taken into consideration.
subclass View and use a for loop with self.children and set every children of those to disabled
Well the error states 'Permissions' has no attribute 'manage server'
Check this
!d discord.Permissions.manage_guild @frozen patio
Returns True if a user can edit guild properties.
manage_guild doesn't work either
ah self.children thats what im looking for thanks
Or u can also use self.stop
!d discord.ui.View.stop
stop()```
Stops listening to interaction events from this view.
This operation cannot be undone.
i did this but it didnt like disable all the butons idk why
You're trying to check if they have manage server prms? Right basically you need to check the user (the one who connected to the website) if they have perms in the (user.guilds) and then you'll need to eh put those guilds in a list or whatever you're going to do. So it will shows those guilds (the user that has perms in) in the dashboard
Idk how to explain tho
this is prob easier
It does disable every button, but on the backend, not frontend
Yes
ik
so what about frontend
flex
like the ui
so how to fix?
Nah
oh frix
You're trying to check if they have manage server prms? Right basically you need to check the user (the one who connected to the website) if they have perms in the (user.guilds) and then you'll need to eh put those guilds in a list or whatever you're going to do. So it will shows those guilds (the user that has perms in) in the dashboard
Idk how to explain tho
ty
!d nextcord.Client.fetch_user is what u r looking for
await fetch_user(user_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a [`User`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.User "nextcord.User") based on their ID. You do not have to share any guilds with the user to get this information, however many operations do require that you do.
Note
This method is an API call. If you have [`nextcord.Intents.members`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Intents.members "nextcord.Intents.members") and member cache enabled, consider [`get_user()`](https://nextcord.readthedocs.io/en/latest/api.html#nextcord.Client.get_user "nextcord.Client.get_user") instead.
Why uninstal tho
use -U to update
what does this mean
disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 60003): Two factor is required for this operation
You might need 2 Factor Authentification enabled on your account
To use some features with a bot it requires the bot owner to have 2FA enabled to their account, just as a side note. So it might be that you do not have 2FA on your account and you try to do something with your bot that requires it.
Is there any way to get what song is someone playing on spotify?
Like someone is listening to a song, I want to get the name of that song and send a message based on that.
You can get the member's activities and see the Spotify activity.
A quick search on the documentation will let you know how to get the member's activities.
All right.
bro, it will update the 1.7.3 installation
"missing 1 required keyword-only argument: 'intents'
I don't think it can be more clear
wait what? that is a required kwarg now?
looks like it yes
That's what I was thinking
Bro show yr commands.Bot
@slate swan
u need intents=discord.Intents.default() in the commands.Bot

πΏ where you put the intents

do you use anything that might require privileged intents? like members intent, presence or message ?
Why is the command prefix a tuple?
why not
why would be a list
then go to developer portal and enable them, then enable through code
Don't see why it's not a string
I'm trying to learn cogs and that comes up
self, ctx
thanks
when inside a class always use self as first param
self is always the first param when you're in a class
i just said that 
@bot.event
async def on_message(message):
if "didn't ask" in message.content:
message=message.channel
await message.send("nobody cares if you didn't ask")
if message.author.id == bot.user.id:
return;
await bot.process_commands(message)
it is still spamming the same message even though i added if statement for the message author
because he also have commands.when_mentioned_or idk if it would work to do commands.when_mentioned_or'.'
He doesn't have when_mentioned_or though πΏ
πΏ wdym he doesn't
.
oh nvm, i fixed it, i just had to reposition it
here he does πΏ
Irrelevant. He didn't have it when he sent it.
can i do something like this?
async def test(ctx, arg):
if len(arg) >= 5:
...
else:
...
so if arg is over 5 letters
Sure
is it the correct code for it?
Cap.
Is there a way to get a list of DMS
wdym list of dms? whose dms
bot dms ofc. List of the users who dmed the bot
!d discord.DMChannel.history
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") that enables receiving the destinationβs message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.
Examples
Usage...
i guess?
Tnx
await fetch_message(id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Retrieves a single [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") from the destination.
I still cannot understand this error.
now i want to make a command that says what current language (cog) is loaded, but idk how to do the if statement to that
If the cog german was loaded it should say that its language is german
if the cog wasnt loaded it should say that its language is english
this is not in a cog
The same error?
Yep.
!d discord.ext.commands.ExtensionAlreadyLoaded
exception discord.ext.commands.ExtensionAlreadyLoaded(name)```
An exception raised when an extension has already been loaded.
This inherits from [`ExtensionError`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.ExtensionError "discord.ext.commands.ExtensionError")
It's getting VERY annoying.
Welp you need to check the user's guild perms not guild's guild permsπ
Yeah, but what do I change to do that?
Get the user that is connected to the dashboard then fetch the guilds that the user in, then check if the user has the manage_server.
It is guild, I checked the docs
I have the login working
It's the dashboard page itself that is not
Btw are u using Quart_discord?
Yeah
I installed nextcord-ext-ipc
and it all logged in successfully
It's the dashboard page right here that is being a pain
I can relate. Well idk how to get the user's guilds just lookupπ btw. Remove the if guild.permissions.manage_server and see if you will get all the user's guilds
I can now π¬
But it is very broken
U got the guilds right?
Correct! π
But you already have the access (to know what server they are in)
It's only in 2 servers
π
And all 92 servers I am in pop up
Mmmm
That permission line is KEY to this bot
also I got an error when I clicked on 1 of them :/
Dashboard is a pain in the assπ
Nah. I find it enjoyable
Try guild.name
[(None,)] hi how would i conert this to a string?
It's only a pain when you make it one
Lucky u
It's a pain when you use things like flask or whatever to do it
Well I am having 2 problems, can you help me with them please?
Its a pain when u tryna style ur website
Nah. Use tailwind π
Who are you saying Nah to?
Saad
Oh
Dashboard is very easy and enjoyable if you pick the right tools
I am using Python an HTML
Whats that
It's the Python that's being dumb
Probabably not the best tools, but it works
Probably
Utility library for styling websites without writing CSS
Very handy because it's universally agreed on that CSS sucks
Oh damn i didnt know that, lemme google it rq
for **kwargs, it's a dictionary right? So you can do if something not in kwargs or kwargs["something"] = something
You can do that, yes
!e
def test(*args, **kwargs):
print("hello" in kwargs)
test(hello="world")
@sick birch :white_check_mark: Your eval job has completed with return code 0.
True
@sick birch (sorry for ping)
But like this permission line is having an attribute error, And if I remove it does work but I got all 92 servers I am in
Yeah
How do I get the date a channel was created at
!d discord.TextChannel.created_at
property created_at```
Returns the channelβs creation time in UTC.
What error is it giving you?
@stuck oyster ^
'Permissions' object has no attribute to 'manage_'
So i have this bot that is this big game but i want an npc you interact with that you can play a mini game with but im not sure what to do
texas holdem maybe but all these regular ideas seem so boring to me
created = channel.created_at.strftime("%a, %#d %B, %Y %I:%M %p")
like the minigame or what?
i might just copy pasta some code
I'm not seeing anypermission property on discord.Guild
Cause I am using nextcord
sure, given channel is a textchannel
That shouldn't change
I named the client discord
nvm ignore
It doesn't make sense for a guild to have permissions
my bad
like you interact with a npc and its like you want to play a game? and you can pick to play x
A user, text channel, or a role may have permissions
it's kind of like an extra thing to add some diversity
Thats my point
I know, but how do I pass in the user without breking the rest of the code
a game within the gamee
channel = await categ.create_text_channel(name=f"{interaction.user.name}-{ticket_number}", overwrites=overwrites, topic=f"{interaction.user.id}")
yeah you could use buttons and stuff to do so, easy peasy
You need to check if the current logged in user has certain permissions for a guild
I did exactly this for my dashboard now that I remember
it's just figuring out what i want to do, because it could basically be anything or multiple things
I want to check for manage_guild
and nothing seems to excite me, like adding chess or whatever feels dumb
Yes. You need to get a user's current guilds and its permissions integer
That's what I did
I used the raw API which returned a list of guild objects along with the permisisons a user had
Yeah but I do not want to break the rest of this
Then checked if that was > 32 since 32 is the manage guild integer
Also discord doesn't have a fetch_guilds method
what are you trying to do?
But I am surprised it does not run how it is cause it should π€
Because there are 2 types of guilds the API returns
One is for the get current user guilds endpoint
When the user logs in to the dashboard it will see a list of servers where they have the manage_guild permission
One is for getting all your bot's guilds
That's not how you do it
nextcord doesn't naturally have that endpoint since it has to do with oauth
You're gonna have to interact with the raw API here there's no other way
given the guild object is guild and the user object is member, you need if member.guild_permissions.manage_guild:
!d discord.Member.guild_permissions
property guild_permissions```
Returns the memberβs guild permissions.
This only takes into consideration the guild permissions and not most of the implied permissions or any of the channel permission overwrites. For 100% accurate permission calculation, please use [`abc.GuildChannel.permissions_for()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel.permissions_for "discord.abc.GuildChannel.permissions_for").
This does take into consideration guild ownership, the administrator implication, and whether the member is timed out.
Changed in version 2.0: Member timeouts are taken into consideration.
right now you're just doing guild.permissions.manage_guild
// All guilds where both and bot and user are in, and the user has the manage server permission.
async function getValidGuilds(botToken: string, userToken: string) {
const userGuilds = await getCurrentGuilds(userToken, 'Bearer');
const botGuilds = await getCurrentGuilds(botToken, 'Bot');
const botGuildIDs = botGuilds.map(guild => guild.id);
let guilds: CurrentUserGuilds = []
for(const userGuild of userGuilds) {
if(botGuildIDs.includes(userGuild.id))
if(parseInt(userGuild.permissions) >= 32) // manage server permission
guilds.push(userGuild);
}
return guilds;
}
i hope this points you in the right direction since it's exactly what you're doing
whatβs the method for giving everyone in a guild a certain role?
None. Loop through and add it manualy
I changed I changed guild --> user
iterating through members
Watch out for rate limits
The guild specific nickname of the user.
message.author.name i thought?
Btw, my dashboard only shows guilds both you and the bot are part of, so you can ignore that part if your dashboard doesn't have that
so ctx.author.nick should work?
is name just username without discrim?
whatβs the command for adding a single role?
add_roles()
π€ you right
and pass the role thru the oarams? if so ty your rly helpful
i usually keep everything similar everywhere so never thought about it
TS?
Correct and thank you
Stop the cap π
You cannot code a discord bot in assembly that easily
I don't think so
this is python server
@slate swan u should start, Robin will join u
Why not use Promise.all()
You probably need to tell it how to put bits on the network
How does User have no attribute to Permissions
Because a user is not tied to a guild
a Member has it not User
Oh
Also you're gonna wanna use the raw API for your dashboard
Get current guilds has everything you want
But I never defined member in my code
Gives you all user's guilds, and their permissions in each as well
I can define it in an @app.route correct?
Define what?
member
What
You need to somehow obtain a member object
Doing nextcord.Member in an async def
Are you using Oauth2 for a user to log in to your dashboard?
Yeah using my bot invite link
..? Why are you interacting with the class directly
Then you should have their bearer token, yes?
I have the client secret and the bot token yeah
This really isnβt gonna work out that well with nextcord classes
Well Somehow I found myself watching a yt tutorial
And it all worked for them just like that
Because YouTube tutorials are pretty bad and somehow work even with bad code
Best to follow proper procedure with oauth flow in accordance with discord documentation
I will try this in JavaScript ig :/
I prefer Python
Thank you for trying to help me
average yt python discord bot tutorial:
Hello friends today we will be hosting a bot
To start, click the github repository in the description, and host.
You now have a working mod bot!
(clicks link) 404
(goes to waybackmachine) last wrapper version is alpha 0.1, uses deprecated fork.
bruh
Ikr
Lmaooo i can relate
How would I do an asynchronous while loop inside a bot command that can be stopped by another command?
got it, nevermind.
if message.startswith(prefix + "command name"):
break
im not sure if that would work in python
but it does in other langs
hmm
You donβt HAVE to but itβd be easier, yes
Yeah, JavaScript does better in backend development
Both front and back
Yeah
Making a dashboard in js is a lot more fun and easier
Ima watch a 61-part video
Mmm
gonna take me like a few weeks to do this
Sure, where would you like
cant really compare python and js on that one π
DM's but ik you have yours locked
Make a bot var or something and check the bot var for the whole loop
Yeah, send me a req and Iβll accept it
Sent
i mean it's not that hard to make a dashboard with python, Flask/Django
what does that mean
!bot-vars
Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:
bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"
@bot.command()
async def get(ctx: commands.Context):
"""A command to get the current value of `test`."""
# Send what the test attribute is currently set to
await ctx.send(ctx.bot.test)
@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
"""A command to set a new value of `test`."""
# Here we change the attribute to what was specified in new_text
bot.test = new_text
This all applies to cogs as well! You can set attributes to self as you wish.
Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!
For sure, definitely easier in JS however
how do i check if a role has a certaiun permission?
property permissions```
Returns the roleβs permissions.
Returns True if a user can ban users from the guild.
have you read the question?
I mean, they asked about a role
oh
no i didn't
anyway, Permissions_obj.ban_members = bool
you can check it like that
for i in range(5, -1, -1):
embed1 = discord.Embed(description=f"Deleting in {i} seconds...", color=0xb92222)
await ctx.channel.send(embed=embed1)```
How can I make it edit instead of sending new embeds
you mean like edit a message or an embed?
an embed
because editing an embed in a message, await message_obj.edit(embed=embed1)
and to check if a certain role has it would i just do role.has_permissions_ban_members?
Do most non-coders call guilds servers instead?
what is the `message_obj
yes
i've been calling servers guilds all through my code and someone was confused by it
the message object you want to edit
yes
and now... 2.6k lines of code to squint through
like the embed?
no, the message
because searching for "guild" and changing it is not...
where did you send the first message?
in ctx.channel its not a message its an embed embed
let me get this straight
you sent a previous message, and you want to EDIT the embed in that message, right?
ty π
yes
okay
show me the line where you sent the message
like, the message you want to edit later on
for i in range(5, -1, -1):
embed1 = discord.Embed(description=f"Deleting in {i} seconds...", color=0xb92222)
await ctx.channel.send(embed=embed1)```
no, the message you want to EDIT, not send
ie - py message1 = await ctx.send('this is a message') # first message await asynio.sleep(1) # wait one sec message1 = await message1.edit(content='this message has been edited') # the message has now been edited

embed = discord.Embed(description="Deleting ticket in 5 seconds...", color=0xb92222)```
this is not a message
well that is what I want to edit
are you trying to edit the embed?
yes
embed there is no message
^^
okay, just send over the full command
embed = discord.Embed(description="Deleting ticket in 5 seconds...", color=0xb92222)
for i in range(5, -1, -1):
embed1 = discord.Embed(description=f"Deleting ticket in {i} seconds...", color=0xb92222)
await asyncio.sleep(5)
await embed.edit(embed=embed1)```
you can give the pizza without a box
napkin
I said I was editing the embed at first
embed = discord.Embed(description="Deleting ticket in 5 seconds...", color=0xb92222)
message1 = await ctx.send(embed=embed)
for i in range(5, -1, -1):
embed.description = f'deleting in {i} seconds'
await asyncio.sleep(1)
message1 = await message1.edit(embed=embed)```
don't do this
don't do this either
why
don't make a new embed instance every time in the for loop
oh yeah
embed = discord.Embed(description="Deleting ticket in 5 seconds...", color=0xb92222)
message1 = await ctx.send(embed=embed)
for i in range(5, -1, -1):
embed.description = f"Deleting ticket in {i} seconds..."
await asyncio.sleep(1)
await message1.edit(embed=embed)
alr
bad
everything I do is good
and embed is the nice looking bubble
a message, is the thing that holds that bubble
well
when you edit a message, you can change what the bubble looks like
ey wassup with it tho
Alright I understand now
bubble
sad container noises
start using await, stop using ctx.channel.send
but seriously? bubble?
please
it doesn't matter
they both return the same object
it's about speed
wrong
isnt gonna matter
it's about power
the ctx.channel one
it's about the drive, it's about the power, we stay hungry we devour
dam you read my mind

depends if you do it one time a minute or 200 times
lets be real, no one is going to do that
πΏ so this is how the app discovery will look i guess
pretty sure dank memer has more than 200 sends in a minute
and they'll just get a 429
well, it just has a really good graphics card
so they do everything to make everything fast and well
no?
yes
one liners save long time memory
less variables save ram
more variables if used correctly save time
One of the reason a lot of people say whitespace based language are a bad idea
With brace-based languages such as Java or javascript, it can be minified
how much ram exactly would using a couple more dozen variables use?
not a lot im betting
especially with the servers dank memer runs on
oh fuq
i had geo this entire time and i did not pay attention
three vars per function with using 500 async functions running
gtg
in that case, wtf would you use python, switch to binary lmao
you just told us to be real 
i am being real
only read chad programmers use binary
oh fuck
this is a research assignment
i need to go now cya
it was fun arguing
yeah, if you gotta write everything many times it can be weird
in every single way possible
with open("file.txt", "r", encoding="utf-8") as file: print(valami := "A leghosszabb nevek:" if (lista := list(filter(None, [line.split(" : ")[0] if len(line.split(" : ")) != 1 else None for line in file.readlines()]))).sort(key=len) is None else "", "\n", "\n ".join(list(filter(lambda x: (len(x) == len(lista[-1])), lista))))
π
don't even need valami var do I
ey I just saved a var
π
πΏ just don't please.
with open("file.txt", "r", encoding="utf-8") as file: print("A leghosszabb nevek:" if (lista := list(filter(None, [line.split(" : ")[0] if len(line.split(" : ")) != 1 else None for line in file.readlines()]))).sort(key=len) is None else "", "\n", "\n ".join(list(filter(lambda x: (len(x) == len(lista[-1])), lista))))
```better now
what you can do in one print is fascinating
bots cant get changes in on_user_update if the user is bot.user?
Hey @slate swan!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
bot.user is literally your bot
you know when your bot changes in your code
you use disnake and discord in one code?
choose one and leave the other
but updating dpy might save your time
oh like in the dev portal?
it's mostly just changing discord to disnake or disnake to discord
Weird question: I'm wanting to make a server bootstrapping script. One that will let people layout a server layout (categories, channels, roles, etc) as a script to make it easier to develop for the Python bot. I was wondering if anyone knew of a way to test something like that without having to actually make x number of guilds during testing. Anyone know of anything like that?
Lame
they both have everything now
so it's up to what you prefer
but using both doesn't work well
yeah but they do things differently when talking about slash commands
so you're prolly gonna choose what's easier
or faster and more stable
don't ask which
I have no idea
I prefer the original lib
pycord is a banned word here pls
lmao
To each their own
admins lurking waiting to punish people be like πΏ
They aren't actually serious
No, I just posted a question a bit above
!otn_add pycord-is-a-sin
Lurking to see if anyone has any insight
Off-topic channels
There are three off-topic channels:
β’ #ot0-psvmβs-eternal-disapproval
β’ #ot1-perplexing-regexing
β’ #ot2-never-nesterβs-nightmare
The channel names change every night at midnight UTC and are often fun meta references to jokes or conversations that happened on the server.
See our off-topic etiquette page for more guidance on how the channels should be used.


