#discord-bots
1 messages · Page 610 of 1
Use @bot.command() since your using bot and not client
I suggest using commands.Bot
It doesnt matter
instead of @bot.ebvent?
for a sserver
Yes and make them different functions
@bot.commands
async def on_message(message):
if message.author == bot.user:
return
elif message.content.startswith('Hello'):
await message.channel.send('Hello Comrade')
elif message.content.startswith('Hi'):
await message.channel.send('Hi. Did ya nuke USA?')
elif message.content.startswith('Comrade'):
await message.channel.send('Shut Up Fool')
elif message.content.startswith('hello'):
await message.channel.send('Hello Comrade')
elif message.content.startswith('hi'):
await message.channel.send('Hi. Did ya nuke USA?')
elif message.content.startswith('comrade'):
await message.channel.send('Fuck You')
elif message.content.startswith('LMAO'):
await message.channel.send('You Dont Laugh In Russia')
if 'i solemnly swear that i am upto no good' in message.content.lower():
role = discord.utils.get(message.guild.roles, id=904021392998146118)
await message.author.add_roles(role)
elif 'mischief managed' in message.content.lower():
role = discord.utils.get(message.guild.roles, id=904021392998146118)
await message.author.remove_roles(role)
await bot.process_commands(message)
tbh the code could have been better like,
_dict = dict(lmao="You Dont Laugh In Russia", comrade="Hello Comrade"...)
print(_dict.get('lmao'))```
I had a big stroke
if message.author.bot: return
if message.content.lower().startswith("hello");
...
...
hm
!e
_dict = dict(lmao="You Dont Laugh In Russia", comrade="Hello Comrade")
print(_dict.get('lmao'))```
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
You Dont Laugh In Russia
So whos gonna tell him
that was an example, it wont magically make your code work by pasting it
No you didnt
ik
i did
You literally just copy pasted it without knowing
Or just do
words = [word for word in message.content.split() if word == dict]
if words:
await message.channel.send(dict[words[0]])
Lol
This should work ^^^
you forgot to split it by space tho
I did code nothing today my brain is failing ccuz i have exams
Welp, message class doesn't have the loop dunder method?
tbh VSC made the evniroment better
not sure
There
i gotta check
Just to be safe haha
More of John Wick tho
which one,
>>> dir(Message.content)
['__class__', '__delattr__', '__delete__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__name__', '__ne__', '__new__', '__objclass__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__set__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']
>>>```
🤔
oh
>>> dir(Message)
['_CACHED_SLOTS', '_HANDLERS', '__annotations__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__slots__', '__str__',```
How is the pfp of ma bot? lol
!e
for p in " Hi there ":
print(p)
@maiden fable :white_check_mark: Your eval job has completed with return code 0.
001 |
002 | H
003 | i
004 |
005 | t
006 | h
007 | e
008 | r
009 | e
010 |
self.message = (
message
if any(['discord.gg/', 'https://']) not in message
else print('someone tried to snipe something blacklisted')
)
``` would this work ?
Hmm, so it splits by chars
yeah
@commands.Cog.listener()
async def on_member_join(self, member):
print('hi')
should work, but it doesn't how do I fix it?
Your basically saying for character in hi there print character
any returns True if any item from the given iterable is True
(doesn't give an error)
how can i define how long someones been boosting for with premium_since
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
True False
if its empty, its considered None
!e
print(bool(''), bool([]), bool(()), bool({}))```
@sullen shoal :white_check_mark: Your eval job has completed with return code 0.
False False False False
If its emtpy its False if it contains a str then it will be True
not False but None, None is falsy tho
Yeah
!d datetime.datetime.strptime
classmethod datetime.strptime(date_string, format)```
Return a [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "datetime.datetime") corresponding to *date\_string*, parsed according to *format*.
This is equivalent to:
```py
datetime(*(time.strptime(date_string, format)[0:6]))
``` [`ValueError`](https://docs.python.org/3/library/exceptions.html#ValueError "ValueError") is raised if the date\_string and format can’t be parsed by [`time.strptime()`](https://docs.python.org/3/library/time.html#time.strptime "time.strptime") or if it returns a value which isn’t a time tuple. For a complete list of formatting directives, see [strftime() and strptime() Behavior](https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior).
i think it was somthing else
Rookie Be Like: 
nah its right
Not hard tbh🤷♂️
is there a way to make the font bigger with discord.py?
font of?
nope
ok
can someone guide me to create a discord bot?
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
You can make it bold with just printing a str starting with ** and ending it with the same thing
Can you only click on one button once? Because if I click on the same button again, even if I wait about 20 seconds the button doesn't work anymore
here is the code can you give me an example to make it bold ?
@commands.command()
async def definition(self, ctx, word):
define=get_definition(word)
definitions=''
count=1
for x in define:
definitions+=f"{count}. {x['definition']}. "
definitions+='\n'
count+=1
embed=Embed(title=f"Hey {ctx.author.name.title()}, {word} means:", type='rich', description=definitions, color=disnake.Colour.blue())
await ctx.send(embed=embed)
await ctx.send("**hello**")
output:
hello
#help-bread Something is broken, I've checked everything it's not my code that's not working. (no errors)
!d await !d client.fetch_channel()
6.4. Await expression
Suspend the execution of coroutine on an awaitable object. Can only be used inside a coroutine function.
await_expr ::= "await" primary
``` New in version 3.5.
??
@glass rock #bot-commands
nah i was looking for a specific discord.oy command
Still a command
do you know how to use get_channel?
oh mb sorry
Pls only use them in the channel
!d discord.Client.get_channel
get_channel(id, /)```
Returns a channel or thread with the given ID.
also this ^^
oke
btw i need to do
channel =await client.fetch_channel(msg.id) await channel.send('hello')
right?
]]
You can .send after getting the channel
Btw use get if possible to avoid a api call
fetch() calls the api unlike get()
ya but i dont have it cached or whatever happened like 10 hours ago with get_message and fetch_message
i got a none type
Alr then dont use it much cause of api abuse
ye or banned lol
Maybe you dont have perms
bot has admin perms what else do i give it
If the bot doesnt have a id in the cache it means theres a problem with perms or other
Because it always should have the id of everything
oh let me check
disnake has, Bot.getch_user and Guild.getch_member which first checks if its in cache if not then it will fetch it
btw <@id> pings user and <#id> links the channel right?
Never seen it before thats cool
I have a message with a Button. Evertime you click on it you get a role. But when I restart my bot the old message is not working anymore and I have to resend the Bot message. Is there a way I can fix that?
It’s not really that cool. You can easily make something this in dpy.
Yes. And <@&id> is a role ping
ty so much
Ik chill😭
RoboDanny already has a implementation of it.
How to create a list (where the roles will be located) that the bot should not write.?
its for command [!userinfo]
sets are mutable. frozensets aren’t
I understand, but how do I make sure he doesn't mention certain roles
Are you asking how to show a users roles without actually mentioning the roles.
Take a way your bots permission to mention them. Or just put it in an embed.
you don't understand, I want to create a list where I will write there the ID of certain roles. and the bot should not write them
880922829212745799
can anyone please tell me how to get id of people who reacted to a reaction , I'm using this code to get list of people who reacted py new_msg = await channel.fetch_message(id) users = await new_msg.reactions[0].users().flatten() users.pop(users.index(client.user)) if ctx.author in users: users.pop(users.index(ctx.author))
so after that I could use a command like this
user = bot.get_user(userId)
await ctx.send(user.created_at)
and find out that how many user's account is older than n days
discord.Message.reactions returns a list of discord.Reaction which has a method users that returns an async iterator of the users that reacted to the reaction. it will either yield User or Member
so iterating through the reaction list then iterating through the async iterator of User, you could do that
guys, how do I get the bot not to write certain roles that will be in the "list" list
I don't want the bot to write these roles: "880922829212745799, 880935336509866075"
Send the code you have
the relevant code
[ctx,user:discord.Member=None]
else:
async with ctx.typing():
await asyncio.sleep(0.4)
if user==None:
user=ctx.author
rlist = []
for role in user.roles:
if role.name != "@everyone":
rlist.append(role.mention)
date_format = "%a, %b %d, %Y %I:%M %p"
memberavatar = user.avatar_url
b = ", ".join(rlist)
# Начала первого embed
embed = discord.Embed(description=f"{user.mention}",color=0x2e2f33,timestamp=ctx.message.created_at)
embed.set_thumbnail(url=user.avatar_url),
embed.set_author(name = f"{user.name}", icon_url = memberavatar)
embed.set_footer(text=f"Запросил: {ctx.author}",icon_url=f"{ctx.author.avatar_url}")
embed.add_field(name='Joined',value=ctx.author.joined_at.strftime(date_format),inline=True)
embed.add_field(name='Created',value=ctx.author.created_at.strftime(date_format),inline=True)
embed.add_field(name=f'Roles [{len(rlist)}]',value=''.join([b]),inline=False)
# Первый embed; конец
# Начала Второго embed
emb2=discord.Embed(color=0x2e2f33)
emb2.add_field(name="Nickname:", value=f"`{user}`")
emb2.add_field(name="ID:", value=f"`{user.id}`")
await ctx.send(embed=embed)
!d discord.Client.get_channel
get_channel(id, /)```
Returns a channel or thread with the given ID.
Thanks bro
it worked
np
[ctx,user:discord.Member=None]
?
h
what do you guys recommened for hosting
but money
if you dont have money you can use replit but it comes with a lot of drawbacks
well im trying to use heroku
use "somehost" instead if u wanna go the free way
No
replit is just bad
in so many ways
same 🕺
why are u not in disnake server ,
ive heard good things about heroku but i cant get it to deploy correctly
i didnt know there was one lol
Hes talking about a fork of dpy?
and no its not dis-snek
im useing disnake know
help
just use if and else
Theirs a link in the pypi page of disnake
Theirs a link in the pypi page of disnake
i sent you the link
haha
i need help deploying to heroku
disnake has a smaller community than pycord but i like disnake more
^^
Doesnt matter disnake is probably the best fork out their
for know
and its the exact same ish with discord.py
Its not about popularity
yeah , i guess to
pycord has superb popularity because of swastik
Its a fork of dpy and it has the same syntax
Ofc it will be the same
lol , kraots
pycord attracts noobs and people that can't think for themselves
disnake attracts people that somewhat know what they're doing and what they want with their bot and end up testing every other fork and lib
You only speak facts my boy
well yea but like its better then having to leanr an entire new syntax
yay , thats why i use disnake , the best snake
😎
Aka kraots knows about it cause hes a nerd and hes a contributor
what
first time i've been called a nerd 😳
lol
😏
too late i ss'ed that
oh no

😭
no
i'm jk :kek:
hehe
:kek:
:kek: 😔
Disnake is probably the best fork because its always up to date and is the fork thats always one step ahead
why so many unsuccessful attempts to use kek emoji
Hi. Does anyone know of an updated cogs tutorial? The docs are giving me headache. I need at least a code that has two commands or functions on it written in cogs.
and has the best implementations
Yes :kek:
its first to have all kind of supports and keeps improving itself at superb pace
in my opnion
Cogs are a very important part of discord.py which allow you to organise your commands into groups - not to be confused with actual command groups, which will be explained later in the tutorial.
Thanks. Reading it now
yw
you gotta state the issue
ok so basically when i press deploy
it deploys then right after it stops
and i cant seem to figure out why
show me the content of your Procfile
how to write radius of a triangle with python codes
is this for a discord bor?
no
TRIANGLE HAS A RADIUS?
what are you talking about mate
...
!ot
Off-topic channels
There are three off-topic channels:
• #ot2-never-nester’s-nightmare
• #ot1-perplexing-regexing
• #ot0-psvm’s-eternal-disapproval
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
ITs remove_roles or remove_role
tias
don't shitpost m8
!d discord.Member.remove_roles
await remove_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Removes [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s from this member.
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 removed [`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.
@brisk helm
Thx
i swear eivl is always in Pycharm
I finally updated hikari-lightbulb to v2 and I love it
Hey this is my code and issue, i have zero clue on why this is happening please help
Am i just being slow or what lol
Idling with PyCharm in background
In case you haven't got it fixed, I think you need to name the file Procfile and not procfile. I think it's case sensitive
i have no clue what to do
how do i add buttons with disnake
i did thank you anyway
iirc it's Procfile with a capital P
... anyways
@disnake.ui.button(label="cat")
async def cat(self, inter: disnake.MessageInteraction):
async with aiohttp.ClientSession() as session:
request = await session.get('https://some-random-api.ml/img/cat')
catjson = await request.json()
# This time we'll get the fact request as well!
request2 = await session.get('https://some-random-api.ml/facts/cat')
factjson = await request2.json()
embed = disnake.Embed(title="Kitty!", color=disnake.Color.purple())
embed.set_image(url=catjson['link'])
embed.set_footer(text=factjson['fact'])
await ctx.send(embed=embed)
await ctx.message.delete()
this wont work
ctx is undefined there, so it definitely won't
https://paste.pythondiscord.com/budotejija.py
Hey, im looking to make a multiple reaction support ticket, multiply reactions will open different tickets, we can only get it to open 1 ticket/channel and give as many reactions as we put, so we need it to pick up the other reactions and open channels when clicked, any advice or help is appreciated
holup
im slow how do i check that

You would print aiohttp.__version__ iirc
i ment to @ you (sorry for the random ping with the person named you)
Without iirc
And can you also print your discord.py version?
It would be discord.__version__
Import aiohttp
Seems like your in the python REPL
Whichever file your bot code is in
Add the prints there
Hey, i'm making a ticket system for my bot and trying to make it where my server admins can also close tickets, how can i make it work? here's my code:
try:
await client.wait_for("message", check=lambda m: m.channel == ticket_channel and m.author == payload.member and m.content == "!close", timeout=3600)```
Yea and discord.__version__ as well
Also are you using some sort of template bot?
yes
Ah, can you show me the requirements.txt file if there is one?
i swear i can make one by myself but im too lazy
yes i can gimme a sec
ive alr done pip3 install -r requirements.txt
Ah.... 👀 Found out the problem
AGHHHHHHHH
Whoever the creator of this template is, kinda had a dumb moment
OO
Remove asyncio from requirements.txt
Lol
And re-install the dependencies
Ok
Dk why asyncio is in there in the first place lmao
Lmaoo
After you remover asyncio from requirements and update the dependencies it should be working fine
Just gonna ignore me? Please anybody can help
Are you using pip?
And are you running the bot via python3
Hmm try uh
Have you removed asyncio from requirements.txt already?
It has nothing to do with the requirements
It should
Can already tell that
For some reason asyncio in the template requirements
would this be the right way to handle a disabled command error? cuz i have a toggle command and whenever i disable a command and try it again, it says the command is disabled in the console and im trying to make it display it when i try it. this is the toggle command https://mystb.in/OriginallyWebsterMichel.less
@client.event
async def on_command_error(ctx, error):
if isinstance(error, commands.DisabledComand):
message = f"{commands.name} command is disabled."
await ctx.send(message)
else:
raise error
And this error the person has is known to be from that
yeah ive removed it
Can you try pip install -r requirements.txt
That should probably update it, if not I'm not sure I don't really use pip only poetry
anybody #help-pretzel ?
You're running discord.py 0.16.12?
is there kinda a easy way to make a discord bot search python docs?
@slate swanis that bad
Don't come to others channel asking for help
It's really outdated
Huh, why did the template creator add a builtin module to the requirements
pip install -U discord.py
I guess backwards compatibility for python 3.3 ¯_(ツ)_/¯
But even then I don't think discord.py supports that version
asyncio was a third party library before 3.3?
And why does pip even install outdated versions that behind
Yea iirc
Yeah it doesn’t iirc
Yes
Interesting, never knew that
what does iirc mean
iirc -> if i remember correctly
can someone help
embed.add_field(name = 'CPU Usage', value = f'{psutil.cpu_percent()}%', inline = False)
embed.add_field(name = 'Memory Usage', value = f'{psutil.virtual_memory().percent}%', inline = False)```
https://oml.wtf/dLbhku6B
how can i remove decimal points
just round it
how do u round it
round()
round(int) and int can be the variable of an integer
no
round(int)
does that mean forever lmao
You can now wait up to 24 hours
Not forever
yes, it means forever obviously
Clearly says temporarily
Running on replit?
Interesting then
Probably has the same network setup yeah
So now what
You wait
i just wait
Now wait
ok
Can be up to 24 hours
Or stop using services like railway, if you want to avoid being banned
i literally tried to do it like 293898239283 times so thats why
No
o
Could be that someone else using railway and had the same IP address as yours on railway got API banned
As API bans are based on IP
can i host it on my pc instead for now lmao
And I'd doubt you'd get ratelimited from trying to relog your bot a lot
?
Restarting your bot multiple times and attempting a websocket connection won't get you rate limited that fast
Well, the bucket only has 2 requests in it and the global ratelimit is 50
I don't think its even possible to get ratelimited like that
Unless discord.py's ratelimiter just craps the bucket and doesn't handle bucket depletion correctly
can i host it on my pc for now
I did it too, it will unban u in like 5mins
SO NOT A DAY?
I remember that I spammed the on and off bot code and I got temporarily banned, after few minutes I got unbaned
ok
Sexy OS
What window manager and theme?
bspwm oceanic next colorscheme
👍
how do i make this into an embed?
@commands.command(pass_context=True, aliases=['color', 'gc'])
@commands.cooldown(1, 5, commands.BucketType.user)
async def getcolor(self, ctx, *, colour_codes):
colour_codes = colour_codes.split()
size = (60, 80) if len(colour_codes) > 1 else (200, 200)
if len(colour_codes) > 10:
return await ctx.send("You can only supply and maximum of **10** hex codes.", delete_after=5)
for colour_code in colour_codes:
if not colour_code.startswith("#"):
colour_code = "#" + colour_code
image = Image.new("RGB", size, colour_code)
with io.BytesIO() as file:
image.save(file, "PNG")
file.seek(0)
await ctx.send("Color {}".format(colour_code), file=discord.File(file, "colour_file.png"))
await asyncio.sleep(1)
how can i do so the bot reply to an user message.
!d discord.Message.reply
await reply(content=None, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").
New in version 1.6.
await ctx.reply()
alr
Can you tell how much time you have left?
async def on_message(self, message):
# we do not want the bot to reply to itself
if message.author.id == self.user.id:
return
if message.content.startswith('!hello'):
await message.reply('Hello!', mention_author=True)```
why this doesnt work?
hm
remove mention_author and just make it an f string
ok
I don't think mention_author should be a problem
async def on_message(self, message):
# we do not want the bot to reply to itself
if message.author.id == self.user.id:
return
if message.content.startswith('!hello'):
await message.reply(f'Hello!')```
like that?
For gateway/bot buckets reset after 5 seconds
i thought he wanted to mention the author as well idk
hm
uhhh what
oh
I assume with discord.py they request /@me to get current user. To validate token and gateway/bot to get the websocket url and shard info
on_message is not a command
So that's two requests
ok
unless you're in a cog
^^
And @me has no ratelimit bucket, so it uses the global ratelimit
@pliant gulchr u talking to me?
Taking up 1 out of 50
oh
Well, you asked how long the ratelimit for gateway/bot was
help?
And I told you the bucket resets after 5 seconds
async def on_message(message):
if message.content.startswith('hello'):
await message.reply(f'Hello!')```
actual code and still doesnt work
what did you type in discord
is there an error
what doesn't work on it
hello
none i think
an error would help :)
It doesn't tell you, I don't think atleast. And all API bans are generally 1 hour long
oh
Depends if you have been banned before or not though iirc
what does iirc mean
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 333, in _run_event
await coro(*args, **kwargs)
File "main.py", line 140, in on_message
await message.reply(f'Hello!')
AttributeError: 'Message' object has no attribute 'reply'```
if I remember correctly
wtf
but i tried it like 2 times after the ban thing showed up
hum?
!d discord.Message.reply
await reply(content=None, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
A shortcut method to [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") to reply to the [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message").
New in version 1.6.
what version of dpy are you using
@pliant gulch does that matter
I don't think so
Ok good
how can i check that
um
or update it
well idk how to check it
well idk out of code
How can I create a text channel and changing the permissions while creating it? Not a line after
!d discord.Guild.create_text_channel
await create_text_channel(name, *, reason=None, category=None, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel "discord.TextChannel") for the guild.
Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.
The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.
Note
Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
overwrites kwarg
hey
i have this code
async for member in guild.fetch_members(limit=None):
print(f"{member}")```
and when i type the command this error occurs
and i need to verify my discord email again and again
why are you fetching all members
and if you have an error handler, could you disable it?
this error does not seem enough
f"⚠️ {message.author.mention} Yooo, chill out.")```
this could work?
no
f
did you check your version?
pip install -U git+https://github.com/Rapptz/discord.py
pip 21.2.dev0 from /opt/virtualenvs/python3/lib/python3.8/site-packages/pip (python 3.8)
thats my version
the python version?
WARNING: You are using pip version 21.2.dev0; however, version 21.3.1 is available.
You should consider upgrading via the '/opt/virtualenvs/python3/bin/python3 -m pip install --upgrade pip' command.```
what command should i use now
what
thats what it said
I don't get why it doesn't work
nethier
idk nethier
What do you guys use to store data per user?
database
Any suggestions for a db?
postgresql
if you have a general event handler cog, how can you override and show the specific command errors?
Hey I wanted to know, how do I wait for 2 events at the same time, so I want the bot to wait for either a reaction or a message, but if I add 2 wait_for one of the wait_for's will block the other wait_for from happening
!d asyncio.wait
coroutine asyncio.wait(aws, *, timeout=None, return_when=ALL_COMPLETED)```
Run [awaitable objects](https://docs.python.org/3/library/asyncio-task.html#asyncio-awaitables) in the *aws* iterable concurrently and block until the condition specified by *return\_when*.
The *aws* iterable must not be empty.
Returns two sets of Tasks/Futures: `(done, pending)`.
Usage:
```py
done, pending = await asyncio.wait(aws)
``` *timeout* (a float or int), if specified, can be used to control the maximum number of seconds to wait before returning...
question about embeds
how do i have a link dispaly on an embed
for example
that vs
the first one looks much better
this is auto generated by discord
emb = discord.Embed(title = "", url = "", description = "", color = "")
going to try this rn
this look so much better, but how do i have the image of the link show up
then just use this but without the url, and put the url in description
like this emb = discord.Embed(title = "", description = "", color = "")
and discord will auto preview the link
for some reason no matter where I put it, i dont get a preview 😦
You could use aiohttp to grab the image and display it I guess
Youtube has an api you could use https://developers.google.com/youtube/v3
class discord.PartialMessageable```
Represents a partial messageable to aid with working messageable channels when only a channel ID are present.
The only way to construct this class is through [`Client.get_partial_messageable()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.get_partial_messageable "discord.Client.get_partial_messageable").
Note that this class is trimmed down and has no rich attributes.
New in version 2.0...
You cannot import that
wdym
im not importing it
im using from discord.ext import commands
i literally have no idea why its saying import webhook or client
import requests
from discord.ext import commands
these are all my modules lol
Can you verify discord is imported correctly?
remove that code and try
import discord
print(discord.__version__)
kk
Btw request isnt async
o thx
Use aiohttp
this wont even work
Are you using a venv?
my friend can run my script but i cannot
yea cuz my pc spec sucks :((
Im guessing anaconda?
idek im just on an RDP
Why?
What does that have to do with your pc specs?
I would suggest you download a package manager like anaconda, create a venv and try downloading discprd.py in there
Is there a way I can check if a text_channel with a name is already on the server?
How do you check how much characters a message has with len()?
Hey guys, how can I ping people in a embed?
.mention
Wdym?
^
You use the member object
Yes
Yes
{member.mention} Zeatman
No
How do I check if the member is speaking through dm only using bot listen("")?
Get the members id and you mention him
okay
@commands.guild_only() doesn't seem to work if I use bot.listen()
I think its {member.id.mention}
wait what
ive been using <@id> lol
Show the format?
im a noob lol
Never done it before
Ye, pls
Or okimii
With what exactly?
How do I check if the member is speaking through dm only using bot listen("")?
@commands.guild_only() doesn't seem to work if I use bot.listen()
Because it ain't a command ig
Check the channel type
Idrk
f string I know
Yeah ofc
How
Wdym how?
(member.911779386615795753.mention.)
How do I check the channel type and what is that
How to get a bot avatar?
Discord developer portal lol
Using the code, otherwise I would not ask such a question
Using the code, otherwise I would not ask such a question
Oh
g = id?
Pog
k
Didnt work sadly
What r u trying to do DevKid
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.member' has no attribute 'g'
Pingin a guy in a embed
But like
This code confuses me
Hey
How do I check if the member is speaking through dm only using bot listen("")?
@commands.guild_only() doesn't seem to work if I use bot.listen()
I mean like this
Because it ain't a command ig
It doesnt actually ping but you know what I mean
But I dont want to ping myself
That's that easy
Use guild.get_member() to get member
I think thats the right one
@slate swan can u help me too
About here
didnt get it
Oh u might need to enable intents
Help me
U could try get_user i think its client/bot.get_user
I would just use on_message
No but how do I check if the member is speaking to the bot through dms only
@slate swan
How can I put that in a description of an embed
What are u tryna do commands in dm or speaking?
what
U make it a variable
My brain is not working, its 2am for me
bot listen("on_message")
commands.dm_only()
Doesn't work
Yeah that looks wrong. So u wanna do commands in dms?
Yes
if not ctx.guild: return
I think its as simple as a setting u set somewhere
?
Like this?
That will stop dms
Oh dang
So I should do the opposite then
member = bot.get_user()
And then do member.mention
I dunno if get_user is in bot im assuming it is
Check the docs to see where get_user is
@fast tree how do u get a member? U randomly mention a member?
Or enable member intent in discord dev portal
Hmm
And use guild.get_member()
No, I want to get one that I want to
How to send a message to a random channel correctly?
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.member' has no attribute 'mention'
member=bot.get_user("911779386615795753")
How
do you know if channels is a list?
Discord dev portal
oh shit
Where u make the bot on discord
It is i think
then what is the issue with that code
yea, i used
for guild in bot.guilds:
for channel in guild.channels
Use guild.get_member()
whats the issue
?
U also might need to subscribe to intents in ur code
I am gonna sleep
Its 2am and my brain isnt working anymore
I dont understand anything anymore
still ty
Lmao bye
maybe try random.choice(guild.chanlels)?
one sec
Nvm i see console
Yeah ur tryna do random choice on the text channel
Actually thats just confusing i dunno why u do for
Are u making a spam bot?
Do guild.text_channels
no
It's worked, thanks
Your welcome
if message.content.startswith('h!h'):
id=str(message.author.id)
await message.channel.send('<@'+id+">")
is this what you meant by format @slate swan
Nah nvm
k
@fast tree its like this:
Myid = "<@int>"
print(myid)
Output:
@int
Guys
I want to ping people in my embed
Not really ping but you know what I mean
But idk how to do that
@silk mauve ^
Thats how you ping someone with their id
How to use that?
I gave a example wdym
but like
wait
title="◈ ℍ𝔸ℕ𝔸𝕄𝕀 𝔹𝕆𝕆𝕊𝕋𝔼ℝ◈",
description=f"𝘽𝙊𝙊𝙎𝙏𝙀𝙍:\n\n ➥{myid}",
colour=discord.Colour.purple(),
timestamp=datetime.datetime.utcnow(),
This is my code
How to
Alright
Now
title="◈ ℍ𝔸ℕ𝔸𝕄𝕀 𝔹𝕆𝕆𝕊𝕋𝔼ℝ◈",
description=f"𝘽𝙊𝙊𝙎𝙏𝙀𝙍:\n\n➥{Myid}",
colour=discord.Colour.purple(),
timestamp=datetime.datetime.utcnow(),
Myid="@silk mauve"
Like this
And make a variable named myid and add the id
your id is 371597683548225537
371597683548225537
so paste 371597683548225537 in there
Send the trance back
wdym
member.mention
He can do it the way i said too
I dont think that works in embeds
I've so a brain f#ck
Never tried it so idrk
How does this work?
title="◈ ℍ𝔸ℕ𝔸𝕄𝕀 𝔹𝕆𝕆𝕊𝕋𝔼ℝ◈",
description=f"𝘽𝙊𝙊𝙎𝙏𝙀𝙍:\n\n➥{member.mention}",
colour=discord.Colour.purple(),
timestamp=datetime.datetime.utcnow(),
Like this?
Actually
And now
Yeah i was confused
f'{a.mention}'
May you please show how to mention a member with their id?
<@id> i think doesnt work in embeds
Alright
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'a' is not defined
That doesnt work in embeds
title="◈ ℍ𝔸ℕ𝔸𝕄𝕀 𝔹𝕆𝕆𝕊𝕋𝔼ℝ◈",
description=f"𝘽𝙊𝙊𝙎𝙏𝙀𝙍:\n\n➥{a.mention}",
colour=discord.Colour.purple(),
timestamp=datetime.datetime.utcnow(),
A=guild.get_member(371597683548225537)
Actually try it
Make a lowercase
Im on phone
How would it not work
title="◈ ℍ𝔸ℕ𝔸𝕄𝕀 𝔹𝕆𝕆𝕊𝕋𝔼ℝ◈", description=f"𝘽𝙊𝙊𝙎𝙏𝙀𝙍:\n\n➥{a.mention}", colour=discord.Colour.purple(), timestamp=datetime.datetime.utcnow(), A=guild.get_member(371597683548225537)
Also get member needs to be higher than a.mention
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'a' is not defined
@silk mauve^
@slate swan thx for showing never new that <@id> was even a thing
IT WORKED
👍
OMG I LOVE U GUYS

Oh i thought that didnt work in embeds
Emojis dont work like that
Ofc they wont😭
I mean like this
U have to actually get the emoji
Yes ik
Cause its a discord feature if you add a id in id it will ping it
<@id> your basically saying ping this member
I know that
Makes sense then
@slate swan
Did that actually ping u?
Yes
Lol
It would
It did
It does but it shows my id idk why
Magic
It's \@okimii
@slate swan
Dont ruin the magic
Makes sense
You can chill now
It also works for everyone and still pings if u have perms but is white
Lol it's understandable , almost all discord objects can be used with \ to get their elasped names
Yeah also works to give u raw unicode emojis
\😀
try <@&the_servers_id> in. A guild
Lol
Says invalid user lmao
U can do voice channels aswell
Thats so cursed
Notice the &
Oh i thought you were just saying and
& is role
nah it's for roles
For channels u do #
everyone role's id in a guild is same as the guild's id xd
<#>
and u can do voice channel links like text channel links
Just @everybody
Now it says you made a channel wtf😭
lol it does not show up with a voice icon on mobile
Yeah
no i didnt make it, its already AFK channel, but u can link to voice channels like text channels with the id using <#id>
Oh lmao
It said on mobile that it wasnt
A voice channel
if u click it u will join afk channel lol
Doesnt say it
oh on mobile it takes u to empty text channel lol
Yeah
How to specify the time to send a message in a function on_guild_join?
Does this also work with roles?
Is there a way I can check if there is a channel with a specific name on the server?
How do I do
like i said
It worked with members
oh i wanted to be right
What do they mean and whats the difference?
role and member i guess
i dunno the difference between ! and no !
both work
@slate swan sorry for the ping but do you know the meanings?
musta done wrong role id
I didnt
does it work outside of the embed?
idk
try it
and are u in same server as role?
@slate swan do you know how to check how much characters message.content has? Does len() work
does it work outside the embed if u just send it on ur discord @silk mauve
i think len works @slate swan
Yeah i think so
Ill check later
i used it b4 to check b4 i sent message
Alr
and then i done this at the end of the string variable to shorten it [:1997]
length = len(page.definition)
if length > 2000:
definition = page.definition[:1997] + '...'```
I wanna make my bot to react to any message that contains a mention
any tips?
not a specific mention btw, just anyone who gets pinged
yeah
u can check a message to see how many mentions are in it
if message.mentions:
^
don’t understand entirely yet
so I can check if a message has a mention like this?
!d discord.Message.mentions
A list of Member that were mentioned. If the message is in a private message then the list will be of User instead. For messages that are not of type MessageType.default, this array can be used to aid in system messages. For more information, see system_content.
Warning
The order of the mentions list is not in any particular order so you should not rely on it. This is a Discord limitation, not one with the library.
that’s so awesome thanks a lot
if message.mentions:
await message.add_reaction('🙂')
Is there a way I can check if there is a channel with a specific name on the server?
can I see who gets mentioned?
message.mentions is a list of member objects, so yes
yeah do a for loop for the channels
and then match the names
Don't really know but that's how the mentions in the on_message events show up , also it's useful in regex and stuff@slate swan
I see
According to docs its related to nicknames
its weird the ! and no ! though
You can probably use discord.utils for this
discord.utils.get(guild.channels, name="general-chat")
i had bots break coz i didnt check for both
If you check only <@!> , It will be fine
nah it wasnt lol
i switched to using if member.mention in instead
! is used for mentions that display nickname, according the the discord docs
https://discord.com/developers/docs/reference#message-formatting-formats
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
So
try:
discord.utils.get(guild.channels, name="general-chat")
except:
pass
? Or what


With nickname vs without nickname

Yea I knew it was related to nicknames but wasn't actually sure , thanks
discord.utils.get returns a list of elements from the first argument that have the properties that are put after it. So you can just check it like so
if discord.utils.get(guild.channels, name="general-chat"):
...
# If you actually want to use those channel objects
channels = discord.utils.get(guild.channels, name="general-chat"):
if channels:
# do whatever with your channels
for channel in channels:
...
i was wondering how u were gonna respond to his question lmao
Cant you just do if channel.name = "":???
u would need to do for loop for that
i was telling him that method but this more elegant
Yes ofc for channel in guild.channels


