#discord-bots
1 messages · Page 1095 of 1
How can I fix this?
is there an easy way to do that other than manually?
probably using a foreach?
got it
for item in view.children:
if item._provided_custom_id != "specificitem":
view.remove_item(item)
is there a better way to write this?
actually, this doesn't quite work lol
it leaves one element, but not the right one
!d discord.ui.Button.custom_id
property custom_id```
The ID of the button that gets received during an interaction.
If this button is for a URL, it does not have a custom ID.
why not use this?
Uhhh
Idk. I thought that is what I was using lol
well, if I change it to custom_id it behaves even stranger
it now gets the correct item but also leaves one
so there are two items
how strange
for item in view.children:
``` skips the second element for some bizarre reason
do someone know what this error mean?
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds.0.url: Not a well formed URL.```
Can I see the URL?
Okay well it's difficult to figure out what the issue is without the url
it is an automatic
mhmm, wait lemme get it a sec
ah ye i cant
well so its a provided url error?
Why can't you just print it?
If it's automated it should be going through your code regardless
building the code took aprox 5min
thats why
but maybe ill just download the image then use it mybe
I'm not seeing how that has to do with printing out a variable
wait lemme do it then
Probably a better question for #965291480992321536
oop
no prob
Is there any way to take the UI elements and abstract them out so that I can build a UI from whichever elements I want?
basically this whole chunk:
@disnake.ui.button(label="Cancel", style=disnake.ButtonStyle.grey)
async def cancel(self, button, inter):
button.disabled = True
self.value = False
self.stop()
I think it would have to be of type Item afaik
can i send it to ur dm?, it is kinda nsfw
Can someone help? ```py
if company == '1st':
except_cr = []
for rank_role_id in rank_ids.values():
if rank_role_id != (rank_ids["Catulan_Reaver"]):
rank_role = ctx.guild.get_role(rank_role_id)
except_cr.append(rank_role)
except_1 = []
for rank_role_id in company_ids.values():
if rank_role_id != (company_ids["1st Company"]):
company_role = ctx.guild.get_role(rank_role_id)
except_1.append(company_role)
await user.remove_roles(*except_1)
await user.remove_roles(*except_cr)
await user.add_roles(ctx.guild.get_role(company_ids["1st Company"]))
await user.add_roles(ctx.guild.get_role(rank_ids["Catulan_Reaver"]))``` These commands execute very very slowly, how can I speed up the process?
I don't do DM help sorry, just remove out the parts that are nsfw. the actual url isn't important, just the form
@sick birch do you know why it's so slow?
If I'm to guess something about removing those roles
how can I speed it up?
perhaps figure out if there's a better way than to remove all those roles?
I'm assuming you did print(a["fileurl"])?
yes
how can I use global cogs in my main file, and call them in my cog file
idk, i tried send the url on my server
and it shown the image
all of the url printed i tried to send
on discord chat all of it shown too
i think yes i need to download it first
Could be, not sure though that's strange
yea, i mean it is
my db like had 4k id registered "done" but like onlky 120 shown
Anybody know?
I have to imagine it's possible
im sorry, but idk
And probably quite simple, I just don't know how
I'm not fully understanding the question, you can build a UI from whichever elements you want normally?
how would I do this?
That's up to you, as that's a design decision
import discord
from discord.ext import commands
from discord import member
from discord.ext.commands import has_permissions, MissingPermissions
import os
from discord_slash import SlashCommand
bot = commands.Bot(command_prefix='z!')
bot.remove_command('help')
slash = SlashCommand(bot, sync_command=True)
@slash.slash()
async def ping(ctx):
await ctx.reply(f'Speed - {round(bot.latency * 10000)}ms')```
i already downloaded discord-py-slash-command
but i get this
discord-py 1.7.3 requires aiohttp<3.8.0,>=3.6.0, but you have aiohttp 3.8.1 which is incompatible.```
I don't mean to sound brash but this is an excellent opportunity to dump discord-py-slash-command
wdym by dump
stop using it
wdym
the library is unmaintained, outdated and bad
use discord.py's master branch, or a fork
or the continued instance of this library which is called interactions.py
whathow
pip install -U git+https://github.com/Rapptz/discord.py
ok
import discord
from discord import app_commands
from discord.ext import commands
from discord import member
from discord.ext.commands import has_permissions, MissingPermissions
import os
class aclient(discord.Client):
def __init__(self):
super().__init__(intents=discord.Intents.default())
self.synced = False
async def on_ready(self):
await self.wait_until_ready()
if not self.synced:
await tree.sync(guild = discord.Object(id = guild_id))
self.synced = True
print(f'Logged in as {self.user}.')
client = aclient()
tree = app_commands.CommandTree(client)
@tree.command(name = "help", description = 'test', guild = discord.Object(id = 602681616120414239))
async def self(interaction: discord.Interaction, name: str):
await interaction.response.send_message(f"Hello!")```
do pip show discord.py in terminal
you didn't run this command did you?
install git
on ur pc
haha
I'd like to be able to do it by just adding them from a list
you didn't invite the bot with application commands scope
this is the code I have now:
class UI(disnake.ui.View):
def __init__(self,):
super().__init__()
self.value = None
@disnake.ui.button(label="Confirm", style=disnake.ButtonStyle.green)
async def confirm(self, button, interaction):
self.value = True
self.stop()
@disnake.ui.button(label="Cancel", style=disnake.ButtonStyle.grey)
async def cancel(self, button, inter):
button.disabled = True
self.value = False
self.stop()
and I'd like to abstract it out to something like this:
ConfirmButton = @disnake.ui.button(label="Confirm", style=disnake.ButtonStyle.green)
async def confirm(self, button, interaction):
self.value = True
self.stop()
CancelButton = @disnake.ui.button(label="Cancel", style=disnake.ButtonStyle.grey)
async def cancel(self, button, inter):
button.disabled = True
self.value = False
self.stop()
class UI(disnake.ui.View):
def __init__(self,):
super().__init__()
self.value = None
@ConfirmButton
@CancelButton
this is sort of what I mean:
https://stackoverflow.com/a/69525876/18604531
except I want the click action and other features gained by subclassing it
actually wait
this might be way less complicated than I'm making it
https://gyazo.com/7bd51124e11a494d3995b4f96d0c1cfa how can I make the command only work with /help?
cuz if i want it to work i need to use /help something
import discord
from discord import app_commands
from discord.ext import commands
from discord import member
from discord.ext.commands import has_permissions, MissingPermissions
import os
class aclient(discord.Client):
def __init__(self):
super().__init__(intents=discord.Intents.default())
self.synced = False
async def on_ready(self):
await self.wait_until_ready()
if not self.synced:
await tree.sync(guild = discord.Object(id = guild_id))
self.synced = True
print(f'Logged in as {self.user}.')
client = aclient()
tree = app_commands.CommandTree(client)
@tree.command(name = "help", description = 'test', guild = discord.Object(id = guild_id))
async def self(interaction: discord.Interaction, name: str):
await interaction.response.send_message(f"Hello!")```
async def self(interaction: discord.Interaction, name: str):
should be:
async def self(interaction: discord.Interaction):
you're telling it that it needs a string called name
thx
Either remove the part with the name: str as Carson did tell you above me, or simply define it as None, then it's an optional argument:
async def self(interaction: discord.Interaction, name: str = None):
Especially helpful when you wanna have separated help given for every command
alright, I've gotten this working somewhat as intended
CancelButton = disnake.ui.button(custom_id = "cancelitem", label="Cancel", style=disnake.ButtonStyle.grey)
ConfirmButton = disnake.ui.button(custom_id = "confirmitem", label="Confirm", style=disnake.ButtonStyle.green)
class UI(disnake.ui.View):
def __init__(self):
super().__init__()
self.value = None
@CancelButton
async def cancel(self, input, inter):
self.value = 0
self.stop()
@ConfirmButton
async def confirm(self, input, inter):
self.value = 1
self.stop()
the buttons themselves are defined outside of the View
but their actions are still defined locally
how can I move the actions outside of the UI class?
okay... this is bizarre
import disnake
from disnake.ext import commands
CancelButton = disnake.ui.button(custom_id = "cancelitem", label="Cancel", style=disnake.ButtonStyle.grey)
async def cancel(self, input, inter):
self.value = 0
self.stop()
ConfirmButton = disnake.ui.button(custom_id = "confirmitem", label="Confirm", style=disnake.ButtonStyle.green)
async def confirm(self, input, inter):
self.value = 1
self.stop()
class UI(disnake.ui.View):
def __init__(self):
super().__init__()
self.value = None
@CancelButton
@cancel
@ConfirmButton
@confirm
class Ask(commands.Cog):
#... etc
this does not work. the class keyword in the last line errors with:
Expected function or class declaration after decorator
however, if I simply replace@confirmwith
async def confirm(self, input, inter):
self.value = 1
self.stop()
it works just fine
it doesn't have to do with the specific function definitions, just whichever one is last errors out if it's using the @ syntax
uhh
at least I thought it worked
it doesn't now lmao
You probably want to use View.add_item() in your view's __init__
You are being blocked from accessing our API temporarily due to exceeding our rate limits frequently. Please read our docs at https://discord.com/developers/docs/topics/rate-limits to prevent this moving forward.
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
uhhh so
i am running the bot on replit
well then there's your problem
sooo bot hosting on replit is the cause?
Well, you can just ditch replit and do this lol
try:
bot.run("token")
except:
os.system("kill 1")
bot.run("token")
where am i supposed to type this
also how am i supposed to make my bot get unbanned 💀
Where you logging the bot
Lol its host issue nothing else

It's not banned from Discord, but getting ratelimited. There's a HUGE difference
i tried to run it on vsc
doesnt work anymore
Well, youre ratelimited ofc it wont
so it should work after a while?
yup
thanks
Ofc
tbh just don't use replit, there are many cons
But I suggested you to ditch replit, as theyre using shared IPs
also like i should type this in vsc only?
what no
replit?
ye
When this happened with me i tried it hosting somewhere else that worked for me don't know why it didn't worked for u
NEVER do this in vsc, especially if you use linux
windows moment
still, don't do this
oh does your bot work well now?
Yeah
roger
It should
where do you host it now, if ye don't mindddd telling me
vps>
is it free?
Sarth Multiple events in client wait for ?
Nah
sad
kill is basically a command used to end process, for replit the 1st process is the repl itself so its fine to use this there, but in a general system it can be anything
you can wait_for only a single event at a time, it you want to wait for more than one event to get dispatched used listeners
so instead of client.run am i supposed to copy paste there?
yeah, thats it.
thanks
still not suggested to use replit for hosting :)
PoV: It's the kernel
sad
so when's my bot gonna run again 💀
its actually the init, also known as systemd
Wait 2-3 hours maybe
🥲
type kill 1 in shell, and rerun
still the same error
oop, so you're blocked by the api, wait is the only option for you :/
so 2-3 hours?
🥲
maybe, there's no specific time limit
if you're just testing code do it on some other bot lol
I don't think u can manually stop that service, can u?
Since that service is what runs other services iirc
you can, it will shutdown your computer
Thought so
hi
hi
i have remove command
async def remove(self,ctx:commands.Context,name):
pass
i want like check if name is a channel or a role in mention like #discord-bots or @role
like we do : name : disnake.channel
something like that
you can use typing.Union
or make a custom converter
typing.Union[discord.Channel, discord.Role], raises an error if its None of them
okay
what hunter said is more extendable tho
basically a class with an async convert function
yes
can u give a small example i cant understand
ofcourse
thanks 👍
@client.event
async def on_member_update(before, after, member):
if after.guild.id == 964841408257200179:
if before.activity == after.activity:
return
role = get(after.guild.roles, id=984560896460357633)
channel = get(after.guild.channels, id=984561160953139231)
async for message in channel.history(limit=200):
if before.mention in message.content and "is now playing" in message.content:
if isinstance(after.member.activity, discord.Game):
return
if isinstance(after.member.activity, discord.Game):
await after.add_roles(role)
playing_service = member.activity.name_split[1]
playing_service = member.activity.name.capitalize()
await channel.send(f"{before.mention} is now playing {playing_service}")
elif isinstance(before.member.activity, discord.Game):
await after.remove_roles(role)
async for message in channel.history(limit=200):
if before.mention in message.content and "is now playing" in message.content:
await message.delete()
else:
return
I’m trying to make a notification bot that sends something in the chat when a user is playing something
on_member_update takes 2 arguments which are before and after which are literal to Member objects
Ok
New error what do I put instead of member
nothing.
its a member object
use like member.name etc
youre trying to access an attribute, which the Member class doesnt have.
Oh ok
check the documentation, e.g all the attributes the Member class has/contains.
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s name with the discriminator.
I put member.name
And it’s there
code pls
@client.event
async def on_member_update(before, after):
if after.guild.id == 964841408257200179:
if before.activity == after.activity:
return
role = get(after.guild.roles, id=984560896460357633)
channel = get(after.guild.channels, id=984561160953139231)
async for message in channel.history(limit=200):
if before.mention in message.content and "is now playing" in message.content:
if isinstance(after.member.activity, discord.Game):
return
if isinstance(after.member.activity, discord.Game):
await after.add_roles(role)
playing_service = after.member.activity.name_split[1]
playing_service = after.member.activity.name.capitalize()
await channel.send(f"{before.mention} is now playing {playing_service}")
elif isinstance(before.member.activity, discord.Game):
await after.remove_roles(role)
async for message in channel.history(limit=200):
if before.mention in message.content and "is now playing" in message.content:
await message.delete()
else:
return
someone know if i can run two bots at the same time ?
like from the same python file that i will run
Use asyncio.gather on start methods of your bot instances
I think that should work
Except you might have loops conflicts
In that case use threads
i created a music bot and it's not playing music
it says ffmpeg was not found.
should i download the ffmpeg as an app on my pc
and if i do how do i extract it's files
and where do i extract it
hi
it should be there on system path
um i need to know that if someone pinged my bot so how do i reply the info the bot
can we edit ephermal messages?
on_message
if message.content == ""
hi guys, what's the endpoint to get the list of all the servers that i'm in ? (not the bot's server, the account that's in the servers)
on_message(ctx)
pls tell me the whole code

!d discord.on_message
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
Incorrect, the only argument is message (unless cog)
it was ironic
!d discord.ext.commands.Context , ctx is not a thing
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.
This class contains a lot of meta data to help you understand more about the invocation context. This class is not created manually and is instead passed around to commands as the first parameter.
This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
can anyone answer my ques.
idts, ephemeral messages can only be created by an interaction and the response are webhooks, which I don't think can be edited
webhooks can be edited
so your ephemeral responses can be edited as well, except for they can't be changed to normal message
If I want to make a bot where it for example has an interactive system where it can mass-edit channel permissions for roles or members what would be an ideal approach?
I actually want to edit ephermal message without any other interaction
How to use message to reference?
I tried it, and got an attribute error, console AttributeError: 'NoneType' object has no attribute 'edit'
Code*
was editing ephermal message, without any other interaction
There's Something Wrong In Your Code
how do i fix this
for i in embeds:
if len(embeds) == 1:
await ctx.send(embed=i)
else:
for j in embeds:
menu.add_page(j)
await menu.start()```
i mean it works fine but due to for loops messed up i get errors
you tried to edit the interaction like you used edit messages didn't you?
yeah
class discord.InteractionResponse```
Represents a Discord interaction response.
This type can be accessed through [`Interaction.response`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction.response "discord.Interaction.response").
New in version 2.0.
but I don't want any other interaction at that place
theres some method here, just check and use it
anyone?
Which error is raised?
@slate swan I checked it, it is editing the original message which I was already doing, let me explain my process
❯ There's a message containing some information with button in a channel.
❯ I click on the button to refresh the information and bot replies with an ephermal message 🔃 Refreshing
❯ After the refresh is done and the original message is edited I want that ephermal message also to be edited to Refreshed. because there's very high chance I'll get same information in the main message
use interaction.edit_original_message
How to display the number of participants on the server
!d discord.Guild.members
property members```
A list of members that belong to this guild.
get the len from that
ok
where exactly
check here if you're stuck http://blog.gregzaal.com/how-to-install-ffmpeg-on-windows/
hunter could you answer in #discord-bot-hosting if youve used gh edu and if you can ty
For the third one, u will want to check out https://github.com/Rapptz/discord.py/blob/master/discord/ext/commands/core.py#L798-L832
thx
yes
run the file and send the error as a text
run it using windows powershell
yk what nvm it
i was just trying new commands, it isnt what i need mainly so dont worry
ok
How to get the msg id of excuted cmd not by using
msg = await ctx.send(...)
print(msg.id) ```
Is there any other method?
why though
*~~ G.K~~ *
uh?

Like i wanted to delete the command executed by that msg id but not using that i mentioned in that msg @slate swan
there is a delete_after kwarg in send
U wanna delete a msg after fetching it?
!d discord.Message.delete
await delete(*, delay=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the message.
Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.
Changed in version 1.1: Added the new `delay` keyword-only parameter.
The delay kwarg
How to fetch that executed cmd replied msg
Wym
.
U need the message ID...
Yeah
Yep
Sooooo?
hm, could you give an example of which message you are referring to?
can someone help me with my code? a kind of lib im trying to make (makes coding for me easier)
||Golu
||
What u even doing
Doesn't dpy already do that for u?
even easier
I'm already crying after seeing the naming conventions
And Python being a high level language also does that
That message that is replied by the bot
msg = await ctx.send bro
Oh god
Why tf will u want to do an API call if u easily have access to the msg
.
Some other way?
await ctx.send(content=content, delete_after=secondsintorfloat)
why isnt this possible though if I may ask
Because he wants another way
but why
¯_(ツ)_/¯
I said The Reason is ||G.K||
wth is G.K
There is NO other way
General Knowledge
yes ```py
msg = await send(...)
await asyncio.sleep(time to delete after)
await bot.http.delete_message(msg.channel.id, msg.id)
ew
imagine msg.delete()
un-danny-ific
basically what the delete_after kwarg does

Stop overusing emojis now
use their escaped names instead
Yup
Let everyone feel like they are in the discord bots dev channel and get the vibe
nobody ever forbid to use emojis
What does to_reference does?
Replies
Imagine not using robo danny
....?
Can we find msg id referenced to that bot command
Message reference is related to replies
Wym
okay thanks smarty
Hunter*
smarty hunter
Like if i use a command hi my bot replies me hello so i want to get that hello message id by using reference? Is it possible
@bot.command()
@commands.has_permissions(manage_messages=True)
async def clear(ctx, amount=5):
await ctx.channel.purge(limit=amount + 1)
When an unauthorized person uses this code, I want him to send a warning message. How can I do that?
You dont have ....permissions.
!d discord.ext.commands.Command.error
@error```
A decorator that registers a coroutine as a local error handler.
A local error handler is an [`on_command_error()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") event limited to a single command. However, the [`on_command_error()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") is still invoked afterwards as the catch-all.
Changed in version 2.0: `coro` parameter is now positional-only.
client.load_extension(f"cogs.{filename[:-3]}")
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
what is this error?
That's... not how it works
Then?
you're using 2.0, and you now need to await client.load_extension
Like, I replied to yr message, so now when I do ctx.message.reference (assuming my msg is the command msg), then I get yr msg object
Got it!
!d discord.Message.reference
The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.
New in version 1.5.
if it is none?
Nothing was replied to
your bot
R. Danny
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: object of type 'NoneType' has no len()
em.add_field(
name='**Badges**',
value=f'{" ".join(get_badges(user)) if len(get_badges(user)) > 0 else "`None`"}')
@bot.command()
async def clear(ctx, amount=5):
await ctx.channel.purge(limit=amount + 1)
await ctx.send(" deleted messages")
How can I delete " deleted messages" after 5 seconds?
get_badges is None
it works for a person who has a badge but doesnot work if i dont hv any badge
await ctx.send("content", delete_after=seconds)```
seconds should be an integer or a floating point number
that's what I said, get_badges is None, in essence, poorly written code as it cannot handle responses for non-badge users (since None does not have a __len__ method to it)
thx
!e
None.__len__
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | AttributeError: 'NoneType' object has no attribute '__len__'. Did you mean: '__le__'?
can someone explain to me why one random function in my entire code would refuse to recognise a variable as global
unless i explicitly declare it as global
global is shit
very helpful tooru
i tried
if you have member intents, yes
until your memory usage max's out and the not crashes
if you can tell me a better way than using globals to access database cursors and connections i'd like to hear it
discord.py is really cache dependent
bot.db = Connection(...)
!botvar use botvars 🙂
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!
if you're only using one db isn't that a huge waste of resources to keep creating new connections every time?
class attributes ig
why would u create more connections?
how is that a new connection all the time?
do you know python basics?

kinda
that sounds like a good idea
btw even better way is ```py
async with Connection() as bot.db:
await bot.connect()
thats the same thing tooru just said.
u create the connection once, make it a bot variable and use that

class Foo:
bar: str = "x"
``` is same as ```py
Foo().bar = "x"
nope
after the second one, Foo class still doesnt have bar, only that instance has it
like i usually put in __init__
self.cursor = connect(...).cursor()```
shouldnt u create a new cursor for each query?
welp, i can say that i use the same cursor for every query and it works fine
also i would suggest to utilize dependency inversion pattern
and pass db connection to bot's init
rather than creating it inside
how can i run an arg against a Union of Converters?
much like dpy param parsing
from within a command
functionally
ofcourse a class variable and attaching a class attr after defining its instance are different, but i was talking about the functionality that it would just be needed to done once.
also the global was messing up because i was using the same variable name for something later in the function for something else

thats the reason for which you shouldn't be using globals
how to create pages
Cellulose fibers are extracted from a variety of sources and converted to pulp.
Pulp is combined with water and placed on a paper making machine where it is flattened, dried, and cut into sheets and rolls.
page = Page()
what type of page and which lib do you use?
any possible way of making a music bot with spotify links?
define possible
under 100 lines of code which doesn't require me to download 20 web pages
no 
damn, welp i tried
i want a page that changes on button click
discord has no concept of pages
be more specific in discord's context
embed? codeblock?
page1 = ""
what library
like that so on
if its a string, then Message.edit
yeah but i want if someone click on next then it change
what lib
send the new so called "page" on button click ....
dpy 2.0
basically a paginator 
yep paginator
i only know disnake examples 
ahh
u can store the "pages" in a list and change the index on button click, or if u want something better use discord.menus.ListPageSource
class discord.ext.commands.Paginator(prefix='```', suffix='```', max_size=2000, linesep='\n')```
A class that aids in paginating code blocks for Discord messages.
len(x) Returns the total number of characters in the paginator.
dont moan, other people can help too
rip embed code blocks
i think there are so many way to do that
yeah the builtin one works with strings, what you want
although it doesnt use buttons afaik
||
lightbulb got inbuilt paginators with button and reaction types||

hikari?
what about tanjun
give some love to the other command impl
im unsure, but im quite sure they don't have it
everyone uses lightbulb
not true, im kinda interested in crescent now
Released recently
and i've not even used hikari myself, so i dont know a lot about it
it got a cleaner interface
i could say that for 3+ discord.py forks.
yea the only thing i know its good 
Especially about their code bases
trust me u dont wanna know their code base
page = page + 1
i dig a lot into pycord's, just to answer "why not use" pycord question.
that is equal to page = page + 1, but what do you think "pages" are?
📄
lol
my very simple embed paginator
https://paste.pythondiscord.com/iposehisok
probably the worst thing you wanna see today
its open source anyways so~
lol, i yanked mine from danny
i think there'a a bug
you are using a mutable default value
embeds is a list
so when you call init again, it uses the same list, which could already be non-empty
a lot of my commands have that kind of pattern, so with a little tweaking its perfect
i find danny's paginator utter crap
ugliest thing i've seen on discord
codeblocks.. really?
After discord.py's source code
codeblocks?
without any highlighting whatsoever
This is page 1
Content
Any tips or advice when developing Discord bots on replit?
how do i fix this
for i in embeds:
if len(embeds) == 1:
await ctx.send(embed=i)
else:
for j in embeds:
menu.add_page(j)
await menu.start()```
i mean it works fine but due to for loops messed up i get error
i guess he took pages too literally
forget about replit
No
yes
Yes. Don't use replit
I am using interactions, I am literally using replit for what it was made for

Oh
👌
wow
Why tho 🤨
ya ik that, but how is that related to the paginator...? the one he has just uses pagesources
Discord requires HTTPS. Either this, or I use like Ngrohk/localtonet (iffy), or somehow set up my own domain with certification 😅
not sure we're talking about the same thing. im talking about commands.Paginator
from discord.ext import commands
@commands.command()
async def status(ctx):
await ctx.reply(f"{bot.user.name}")
def setup(bot):
bot.add_command(status)
``` I'm working with extensions in discord.py, but I'm wondering how to include the bot class from my "main.py"-file so that i can call {bot.user.name} like above. Could anybody help me?
Replit is the easiest way to do this because you get an HTTPS URL
hi
whyw would someone call the init dunder manually?
im not talking about that, anyways
isnt it called internally?
Class() calls __init__ automatically
it is... but wdym by init again
if u create another paginator
then you create another instance of the paginator ez
u dont get it
class A:
def __init__(self, b=[]):
b.append(2)
print(b)
A() # [2]
A() # [2, 2]
@slate swan
anyone?
!e ```py
class A:
def init(self, b=[]):
b.append(2)
print(b)
print(A().embeds)# [2]
print(A().embeds)# [2, 2]
oop
1 min
yea thats too much
👍
why did you send me this...
i thought you were looking for a better paginator?
no?
uh okay...
i dont disagree
Kk
@summer bough you can install it by doing
pip install disnake
Oki
what
i need help with this gah
they didnt say they wanted dpy specifically, so i saw no reason to install an inferior lib
ah, my bad pip install disnake[discord]
now it works
and you're using a better library
only upsides dem
There you go! Got it working now after having to fix a bug 🥴 https://replit.com/@Bluenix2/Contributor-bot#main.py
Replit interactions 👍
||me who just makes an init.py with import disnake as discord in the projects folder||
lol
demon 
im trying to make an embed generator but when i tried, nothing comes and there is no error
this is a very helpful error message
@slate swan 1v1 me in RL to decide if dpy is better than disnake
if someone wants a message sent in embed including an image and want to add extra fields. ive tried with from_dict but nothing shows
uhhh i play from pc, can i give you my epic games tag?
Is there any free hosting doesnt matter if its slow or bad i just wanna host my bot in one server
im talking about generating it but with a json
What type of bot is it?
halp
for i in embeds:
if len(embeds) == 1:
await ctx.send(embed=i)
else:
for j in embeds:
menu.add_page(j)
await menu.start()```
i mean it works fine but due to for loops messed up i get error
Most of the commands are just sending some messages/embed and not really doing a big task
party chat is cross-platform, also im currently at work and will return home in about 3.5 hours. is it fine if i dm you my id?
Any idea?
Ah- I meant more whether it was for interactions. I guess not. You could sign up for a Google Cloud free tier?
from json import loads
from nextcord import *
from nextcord import slash_command as jeanne_slash
from assets.errormsgs import admin_perm
from asyncio import TimeoutError
from nextcord.ext.application_checks import *
@jeanne_slash(description="Main say command")
async def say(self, ctx: Interaction):
pass
@say.subcommand(description="Type something and I will say it in embed")
@has_permissions(administrator=True)
async def embed(self, ctx: Interaction, channel: GuildChannel = SlashOption(description="Which channel should I send the message?", channel_types=[ChannelType.text, ChannelType.news])):
ask = Embed(
description="Type something")
await ctx.followup.send(embed=ask)
def check(m):
return m.author == ctx.user and m.content
try:
msg = await self.bot.wait_for('message', check=check, timeout=300)
embed_text = Embed.from_dict(loads(msg.content))
await msg.delete()
await channel.send(embed=embed_text)
await ctx.followup.send("Sent", ephemeral=True)
except TimeoutError:
timeout = Embed(
description=f"Guess you have nothing to say", color=0xFF0000)
await ctx.followup.send(embed=timeout, ephemeral=True)```
I host my bot on Google Cloud for free. Although... it has 40K members 😅 So you'll do fine there
well crap...
ive been doing that for long but now, i want it to be generated. the user can add own fields and color
i know someone who did that but their bot is coded in c#
well, my first guess was json then it converts to embed
!d discord.Embed.from_dict this or what....?
classmethod from_dict(data)```
Converts a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") to a [`Embed`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed "discord.Embed") provided it is in the format that Discord expects it to be in.
You can find out about this format in the [official Discord documentation](https://discord.com/developers/docs/resources/channel#embed-object).
They could use flags
can someone tell me how to host a discord bot on aws
You should ask that in #965291480992321536 since your question is related to hosting
guys, I am trying to install discord.py, but when I try, it returns errors? What do?
what error?
how are you installing it?
using the python terminal, lemme get the error up.
python terminal?
imagine using python.exe directly
you are supposed to install it in the normal terminal provided by ur os
when i use (self, ctx, *args) does dpy simply use str.split on message content to give me a list?
*args returns a list in dpy?
if you denote a parameter like that, yes
is a json file good to use for a custom prefix command?
*, text will return it as 1 string
or do i need a db
i thought i was just a tuple like normal
json is only ok for initial configuration
other than that u want a db
oh im not sure which type it is exactly
could be a tuple
i thought u meant list as a data structure
using files makes ur bot very prone to errors
what if 2 people use this command at once
You don't have to parse anything @brave moth
Just use a lock
or a db 😅
Yes
the help command though, i am using the minimal help command. will the help command content also update [in only different prefix server] with prefix change?
minimal help command uses prefix used to invoke the help command
you need your own logic to grab prefix(es) from your own function
oh okay
do i need to make a different db for prefixes or can i put it in the same one as my data
How do I run the file to start my bot, now I have it setup?
i dont see why youd need separate db
ya it returns a tuple and seems like it uses str.split but i can't find it in the src
uh what then?
what os do you have ? where are you running it
just store in same db
you have a table for options or smth
key/value store
you could put it there
windows 10
- wdym where am I running it
is it fine to use json for storing data which is static, and file opened only on initialization?
py yourfile.py
does it fine work even with command spam?
yes again
should work
i trust you but i need opinions 😭
Should I do it from CMD or Terminal?
maybe, good luck
tuple
!d discord.Embed
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, 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.
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.
Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
I already understood how to do it
Ex:
embed1 = discord.Embed(title="Hello world",description="some description")
await ctx.send(embed=embed1)
Nice
hey, i keep getting this error (im using replit as the ide). my project was working yesterday, went to rerun it today and bam this error appeared - any idea as to why its saying too many redirects?
and:
ok so im looking for a way to make my bot ping a role on use of (?vc) while having a global cooldown of 4 hours
try kill 1 in shell
the code i spent 1 hour doing is trash
Yeah I have, multiple times, and then I rerun and I still get that error
hm
ill try it again
theres a pip.cnf , you could delete
is that from discord-interactions or smth
yeah
thats in your pyproject
could try venv/bin/python -m pip install discord-interactions in shell
or just rm -rf venv and start over
very buggy tool imo
i was thinking of using pip freeze and then seeing what moduels are important
than making a requirements file
ill try that first tho
yeah i get rid of the poetry crap coz it never works right in replit for me
requirements.txt does
!d discord.ext.commands.has_permissions
@discord.ext.commands.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member has all of the permissions necessary.
Note that this check operates on the current channel permissions, not the guild wide permissions.
The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions").
This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.MissingPermissions "discord.ext.commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
tanks
!d discord.app_commands.checks.has_permissions
@discord.app_commands.checks.has_permissions(**perms)```
A [`check()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.check "discord.app_commands.check") that is added that checks if the member has all of the permissions necessary.
Note that this check operates on the permissions given by [`discord.Interaction.permissions`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction.permissions "discord.Interaction.permissions").
The permissions passed in must be exactly like the properties shown under [`discord.Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions").
This check raises a special exception, [`MissingPermissions`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.MissingPermissions "discord.app_commands.MissingPermissions") that is inherited from [`CheckFailure`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.CheckFailure "discord.app_commands.CheckFailure").
New in version 2.0...
wrong reply nvm
oh he was using slash commands never saw my bad thanks ashley
New Discussion Topic: Why do people have "Discord Bot Developer" in their bio and ask basic and stupid questions in this channel? Comment.
I want to put a picture of the person using the command on the right side, how can I do that?
embed.set_thumbnail(url=avatarurl)
flex
lmao
why not use embed.set_author
@bot.command()
async def embed(ctx):
embed = discord.Embed(
title='This is a title! you can customise this!',
description='This is a description!',
colour=discord.Color.green(),
timestamp=datetime.datetime.now()
).add_field(
name='This is non inlined field 1!',
value='This is a value!',
inline=False
)
await ctx.send(embed=embed)
sorry i don't understand can you show me on this code?
!d discord.Embed.set_author
set_author(*, name, url=None, icon_url=None)```
Sets the author for the embed content.
This function returns the class instance to allow for fluent-style chaining.
never said I was good
you technically are a discord bot developer as soon as you create a bot on the dev portal, even if you don't know a shit about programming
In that case, I'm a Quantum Mechanics professor
Okay, then "custom bots commision/for free"
full traceback & code?
i hate dis one
but this would be like judging people, so nvm
lmao
thinking I should put it too
you don't come here that often?
😔 leave mah man alone!
doesn't matter too much, David
you're almost an Ed Sheeran lookalike if you had curls I think
so many ppl tell me so lmao
better than being a murderer lookalike ig
i like poetry just not in replit
poetry is cool and handy
check out stats in #esoteric-python
i believe replit messes with poetry only because of their outdated py version (3.8.2/4) and auto lib installations
?
the exact thing would be ctx.author.avatar_url
whats the () at the end, is that part of it
Don't call
just short for raise TypeError
lol i didnt realize you can init Embed like that
@pure void
i just searched and only got 68 ?
suggest some games for discord bot
see
so the actual amount of messages you have is 1679^68!
makes sense, right?
someday maybe
how does the number of messages he sent matter?
power
"^"
it doesn't, thats the whole point
sorry i made a mistake
..
tetris
nvm
you can't possibly create tetris within the discord app so it isn't possible anyways
very simple: rock paper scissors, sokoban, connect 4, ...
wow nice idea rock paper scissors :D
monopoly
lol idk whats tetris
rock paper for now 💀
wow, we're getting old
or just steal @lament depot
I'd bet it's possible
ratelimits might keep you to one player at a time but probably possible
Anyone? (scroll up to see more)
Or just here
before and after are already Member objects. They don't have a member attribute
Ohhh ok
=> it's just after.activity
whenever is see => it reminds me js function 💀
same
arrow functions in js are basically like lambdas right?
yeah
.name.split
.name.split()[1]
not sure why you're splitting though
and you even override the value the line after it
checking the 2nd word in the activity ig
What does it do?
yeah wtf
!e print("word1 word2 word3".split())
@slate swan :white_check_mark: Your eval job has completed with return code 0.
['word1', 'word2', 'word3']
Comma?
@wicked atlas :white_check_mark: Your eval job has completed with return code 0.
['word']
nvm, that was something else
its a list of *strings
!d str.split
str.split(sep=None, maxsplit=- 1)```
Return a list of the words in the string, using *sep* as the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are done (thus, the list will have at most `maxsplit+1` elements). If *maxsplit* is not specified or `-1`, then there is no limit on the number of splits (all possible splits are made).
If *sep* is given, consecutive delimiters are not grouped together and are deemed to delimit empty strings (for example, `'1,,2'.split(',')` returns `['1', '', '2']`). The *sep* argument may consist of multiple characters (for example, `'1<>2<>3'.split('<>')` returns `['1', '2', '3']`). Splitting an empty string with a specified separator returns `['']`.
For example:
how to remove a item on timeout in a class?
!d discord.ui.View.on_timeout
await on_timeout()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A callback that is called when a view’s timeout elapses without being explicitly stopped.
!d discord.ui.View.remove_item
remove_item(item)```
Removes an item from the view.
This function returns the class instance to allow for fluent-style chaining.
everytime I do view.clear_items() it says view is not definied
Yay thanks guys it’s working
show code and full traceback
im guessing you are looking for self.clear_items
def __init__(self,ctx):
super().__init__(timeout=10)
self.ctx = ctx
@discord.ui.button(label='next', style= discord.ButtonStyle.gray)
async def button_callback(self,button, interaction):
await interaction.response.edit_message(content='test')
async def on_timeout(self):
await view.clear_items()```
I tried and it says: Traceback (most recent call last): File "main.py", line 34, in on_timeout await self.clear_items() TypeError: object NoneType can't be used in 'await' expression
because you don't await it.
oh ok
but now nothing happens
that just clears the items from your view, not your message
that just clears the items from your view, not your message
!d discord ui.View.stop
!d discord.ui.View.stop
stop()```
Stops listening to interaction events from this view.
This operation cannot be undone.
hse this
so self.stop()?
nvm it wont work either
Just edit the message and pass an empty view aka None lmao
hm
examples/views/disable_view.py lines 45 to 49
# Defines our view so that we can use the message in on_timeout to edit it
view = MyView()
# Sends a message with the view
view.message = await ctx.send("These buttons will be disabled or removed", view=view)```
`examples/views/disable_view.py` lines 12 to 18
```py
async def on_timeout(self):
# Once the view times out we disable the first button and remove the second button
self.children[0].disabled = True # type: ignore
self.remove_item(self.children[1])
# make sure to update the message with the new buttons
await self.message.edit(view=self)```
the point is, view has no attribute or method which gets you the message, you need to attach that manually.
Then retrieve the value and edit it then.
Wait i got sum code.
@narrow grail use this, the only difference is you will be using self.clear_items instead of the stuff they did inside the on_timeout
await interaction.response.edit_message(content=self.conf_msg, view=None)
Perfect valid response.
you don't have an interaction in on_timeout 🙂
just do self.message = interaction.message (after interaction)
yeah, thats what the example above basically did ( in a message command though)
ah i didnt notice
Fetching users with name in client guilds member?
Then edit the msg inside the command since time-out receives a False value.
How to do that
!d discord.ui.View.wait
await wait()```
Waits until the view has finished interacting.
A view is considered finished when [`stop()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View.stop "discord.ui.View.stop") is called or it times out.
Returns
If True, then the view timed out. If False then the view finished normally.
list comp on bot.users with .name attribute check
they want to remove the view when the view time outs, how is this related?
[user.name if getattr(user, "name", False) else (await bot.fetch_user(user.id)).name for user in bot.users]
I don't think you are seeing it.
Task exception was never retrieved future: <Task finished name='discord-ui-view-timeout-05bf4a51fd6e6a9b7daf0cc476f64ceb' coro=<ViewWitz.on_timeout() done, defined at /root/tb.py:33> exception=IndexError('list index out of range')> Traceback (most recent call last): File "/root/tb.py", line 35, in on_timeout self.remove_item(self.children[1]) IndexError: list index out of range
You can also overwrite the on timeout
thats what this is ^
yeah panda, dealing with extra methods and an additional interaction is just making it an extra deal 😔
don't see whats the issue in using this.
True
Maybe this?
discord.utils.get(guild.members, name="Username")
you didn't read the complete message, did you?
I'd use this as well, I was just referring to a different method.
my mistake
title=f'hello {member.mention} ',
Why does the mention look like this?
how can i fix this?
you can't mention someone in author, title, field names and footers
ah ok thx
!paste show code
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.
def __init__(self,ctx):
super().__init__(timeout=10)
self.ctx = ctx
@discord.ui.button(label='next', style= discord.ButtonStyle.gray)
async def button_callback(self,button, interaction):
await interaction.response.edit_message(content='test')
async def on_timeout(self):
await self.clear_items()```
now you didn't do the await self.message.edit
but I need it cause my message should change everytime you click on the button, but if no one is clicking anymore on the button it should be removed
u use pycord?
what all errors i MUST be handling in on_command_error function
looks like dpy to me
interactions come before buttons
yyes
ohh
clear_items doesn't edit the message so edit the message as sarth said
MissingPermissions
MissingRequiredArgument
CommandNotFound
BadArguement
and..?
but he said to do it with clear_items
.
ya but u need the send a message/edit the message for it to show up on the screen
you used it first at the first place.
this is what I asked to use
the errors you would like to handle... there is no must it really depends on you
await self.message.edit(view=self) ?
view=None
ok
i mean, which happens often,
like UserInputErrors, CommandNotFound, many more
the first thing I'd do is not handle or raise thr commands.CommandNotFound, then a mixed response for UserNotFound, MemberNotFound and ChannelNotFound, then MissingRequiredArgument
https://paste.pythondiscord.com/otumeqarub
@odd mango
so confused
wtf i said OFTEN not ALL
i already gave the two most common ones, rest are those
how do i do a mixed response
mixed response not in any programming related term lol, basically same if/elif block for all these errors.
finally got it, thanks @slate swan @paper sluice
with too many bots, possibly with the same prefix in one server, it doesn't make sense to handle commandnotfound. Other wise i dont see a problem
command not found error is useless
Adding, Did u mean? Is better
yeah thats what, i wanna do sm like
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
await ctx.send("**Invalid command. Try using** `help` **to figure out commands!**")
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send('**Please pass in all requirements.**')
if isinstance(error, commands.MissingPermissions):
await ctx.send("**You dont have all the requirements or permissions for using this command :angry:**")```
ya you can do that, but for that to happen you have to handle CommandNotfound first....
most of the botlists discourage it, and if you don't have something significant like specifying matching commands with fuzzymatch or something, its useless
Ye I mean not send only x command not found
use elifs & don't forget to addelse: raise error in the end
okayy
so which all main ones i need to do
Bruh dc lagged
command not found happens a lot cause bots with same prefix exist
ya that is kinda pointless
BotMissingPermissions,
MissingPermissions,
MissingRole,
DisabledCommand,
ChannelNotFound,
MemberNotFound,
UserNotFound,
TooManyArguments,
CommandOnCooldown,
MissingRequiredArgument,
PrivateMessageOnly,
NoPrivateMessage,
NotOwner,
CommandOnCooldown is what i handle
nvm
why not command not found
.
so is it okay if it spams red on my console if i do a wrong command ?\
you are aware of pass and return statements right?
yeah what of those?
just this?
if isinstance(error, commands.CommandNotFound):
return
raise error```
come at your server
does anyone know how to create a webhook with a picture
hello I'm trying to create a command in which people can get the bot to dm a user whose id is specified as well as the message itself but my code wont work and i returns the error "AttributeError: 'NoneType' object has no attribute 'send'
Here is the code
async def sendid(ctx, userid, Message):
await ctx.channel.send("debug")
id = int(userid)
user = bot.get_user(id)
await user.send(Message)````
can you help please ?
Maybe U can use
@bot.command()
async def sendid(ctx, user:discord.User, *, message):
await user.send(message)
await ctx.reply(f"{message} has been sent to {user}!")```
!d discord.Member | If you want it only for ctx.guild.members then replace User with Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s name with the discriminator.
How can i make live server count???
draw?
is "user:discord.user" taking an id ?
Dear please tell me what is wrong
@commands.Cog.listener()
async def on_member_join(member):
channel = client.get_channel( 977252614498582538)
role = discord.utils.get ( member.guild.roles, id = 977252174964871258)
await member.add_roles (role)
await channel.send ( embed = discord.Embed (description = f"``{member.name}``, добро пожаловать на сервер", color = 0xffffff))
i dont know anything about cogs but i think you might also need self
I'm assuming that you're using this inside a class, because of your use of @commands.Cog.listener(), and all regular instance methods (excluding @classmethod and @staticmethod) need to have self as the first argument:
@commands.Cog.listener()
async def on_member_join(self, member: discord.Member):
...
oh right. just got another error
@commands.Cog.listener()
async def on_member_join(self, member: discord.Member):
channel = client.get_channel( 977252614498582538)
role = discord.utils.get ( member.guild.roles, id = 977252174964871258)
await member.add_roles (role)
await channel.send ( embed = discord.Embed (description = f"``{member.name}``, добро пожаловать на сервер", color = 0xffffff))
