#discord-bots

1 messages · Page 610 of 1

tiny ibex
#

Potter fan I see

slate swan
#

Use @bot.command() since your using bot and not clientyert

tiny ibex
#

I suggest using commands.Bot

slate swan
#

It doesnt matter

slate swan
slate swan
slate swan
#

Basic dpy and basic python

slate swan
# slate swan 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)
sullen shoal
#

tbh the code could have been better like,

_dict = dict(lmao="You Dont Laugh In Russia", comrade="Hello Comrade"...)
print(_dict.get('lmao'))```
dapper cobalt
#
if message.author.bot: return

if message.content.lower().startswith("hello");  
  ...
...
sullen shoal
#

hm

#

!e

_dict = dict(lmao="You Dont Laugh In Russia", comrade="Hello Comrade")
print(_dict.get('lmao'))```
unkempt canyonBOT
#

@sullen shoal :white_check_mark: Your eval job has completed with return code 0.

You Dont Laugh In Russia
slate swan
#

That would work too

slate swan
sullen shoal
#

that was an example, it wont magically make your code work by pasting it

slate swan
#

lol ik

slate swan
slate swan
slate swan
maiden fable
#

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 ^^^

sullen shoal
#

you forgot to split it by space tho

slate swan
#

I did code nothing today my brain is failing ccuz i have exams

maiden fable
slate swan
#

tbh VSC made the evniroment better

sullen shoal
#

not sure

maiden fable
#

There

sullen shoal
#

i gotta check

maiden fable
#

Just to be safe haha

slate swan
sullen shoal
#

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__']
>>>```
🤔
maiden fable
#

No no no

#

just do dir(Message)

sullen shoal
#

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__',```
slate swan
#

How is the pfp of ma bot? lol

maiden fable
#

!e

for p in " Hi there ":
    print(p) 
unkempt canyonBOT
#

@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 |  
slate swan
#
        self.message = (
            message
            if any(['discord.gg/', 'https://']) not in message
            else print('someone tried to snipe something blacklisted')
        )
``` would this work ?
maiden fable
#

Hmm, so it splits by chars

sullen shoal
#

yeah

severe quarry
#
    @commands.Cog.listener()
    async def on_member_join(self, member):
        print('hi')

should work, but it doesn't how do I fix it?

slate swan
sullen shoal
severe quarry
sullen shoal
#

strings are Truthy unless its empty

#

!e

print(any(['fwf','wefwef']), any(['','']))
slate swan
#

how can i define how long someones been boosting for with premium_since

unkempt canyonBOT
#

@sullen shoal :white_check_mark: Your eval job has completed with return code 0.

True False
sullen shoal
#

if its empty, its considered None

#

!e

print(bool(''), bool([]), bool(()), bool({}))```
unkempt canyonBOT
#

@sullen shoal :white_check_mark: Your eval job has completed with return code 0.

False False False False
slate swan
#

If its emtpy its False if it contains a str then it will be True

sullen shoal
#

not False but None, None is falsy tho

slate swan
#

Yeah

sullen shoal
unkempt canyonBOT
#

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).
sullen shoal
#

i think it was somthing else

slate swan
#

Rookie Be Like: WHAT

sullen shoal
#

nah its right

slate swan
quiet coral
#

is there a way to make the font bigger with discord.py?

sullen shoal
#

font of?

quiet coral
#

the description field

#

sorry with the embed class

sullen shoal
#

nope

quiet coral
#

ok

versed folio
#

can someone guide me to create a discord bot?

slate swan
slate swan
#

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

quiet coral
# slate swan You can make it **bold** with just printing a str starting with ** and ending it...

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)
slate swan
severe quarry
#

#help-bread Something is broken, I've checked everything it's not my code that's not working. (no errors)

glass rock
#

!d await !d client.fetch_channel()

unkempt canyonBOT
glass rock
#

??

slate swan
#

@glass rock #bot-commands

glass rock
#

nah i was looking for a specific discord.oy command

slate swan
glass rock
#

do you know how to use get_channel?

glass rock
slate swan
#

Pls only use them in the channel

slate swan
unkempt canyonBOT
slate swan
glass rock
#

oke

#

btw i need to do
channel =await client.fetch_channel(msg.id) await channel.send('hello')
right?

hushed lantern
#

]]logo_cython

slate swan
#

Btw use get if possible to avoid a api call

#

fetch() calls the api unlike get()

glass rock
#

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

slate swan
#

Alr then dont use it much cause of api abuse

glass rock
#

ye or banned lol

slate swan
#

Maybe you dont have perms

glass rock
#

bot has admin perms what else do i give it

slate swan
#

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

glass rock
#

oh let me check

sullen shoal
#

disnake has, Bot.getch_user and Guild.getch_member which first checks if its in cache if not then it will fetch it

glass rock
#

btw <@id> pings user and <#id> links the channel right?

slate swan
#

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?

sage otter
slate swan
glass rock
#

ty so much

sage otter
#

RoboDanny already has a implementation of it.

slate swan
#

How to create a list (where the roles will be located) that the bot should not write.?

#

its for command [!userinfo]

sage otter
#

sets are mutable. frozensets aren’t

slate swan
#

I understand, but how do I make sure he doesn't mention certain roles

sage otter
#

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.

slate swan
#

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

clear rapids
#

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

sullen shoal
#

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

slate swan
#

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"

slate swan
#

a

full lily
#

the relevant code

slate swan
#

[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)
grand lagoon
#

!d discord.Client.get_channel

unkempt canyonBOT
sullen shoal
#

np

grand lagoon
#

[ctx,user:discord.Member=None]

slate swan
deep oak
#

h

slate swan
#

what do you guys recommened for hosting

deep oak
#

a vps

#

@slate swan

slate swan
#

but money

deep oak
#

if you dont have money you can use replit but it comes with a lot of drawbacks

slate swan
#

well im trying to use heroku

quick gust
#

use "somehost" instead if u wanna go the free way

slate swan
#

but when i deploy it deploys then stops

#

no i use disnake

slate swan
#

replit is just bad

#

in so many ways

deep oak
slate swan
#

Dont use replit

#

Use heroku its better than replit and best free option

deep oak
slate swan
#

ive heard good things about heroku but i cant get it to deploy correctly

slate swan
slate swan
deep oak
#

i know

#

i use disnake

slate swan
#

im useing disnake know

slate swan
slate swan
deep oak
#

i sent you the link

slate swan
#

ty

deep oak
#

haha

slate swan
#

i need help deploying to heroku

deep oak
#

disnake has a smaller community than pycord but i like disnake more

slate swan
#

^^

slate swan
#

for know

#

Its not about popularity

deep oak
#

yeah , i guess to
pycord has superb popularity because of swastik

slate swan
#

Ofc it will be the same

deep oak
#

lol , kraots

slate swan
#

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

slate swan
deep oak
slate swan
#

😎

slate swan
slate swan
slate swan
deep oak
#

lol

slate swan
deep oak
#

😆

#

nvm

slate swan
#

too late i ss'ed that

deep oak
#

oh no

slate swan
#

Lmfaoooo

#

imma expose u to him 🚶‍♂️

deep oak
slate swan
deep oak
#

no

slate swan
#

i'm jk :kek:

deep oak
#

hehe

slate swan
#

:kek: 😔

#

Disnake is probably the best fork because its always up to date and is the fork thats always one step ahead

deep oak
#

why so many unsuccessful attempts to use kek emoji

sour pecan
#

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.

slate swan
slate swan
deep oak
slate swan
sour pecan
slate swan
#

yw

sullen shoal
slate swan
#

it deploys then right after it stops

#

and i cant seem to figure out why

sullen shoal
#

show me the content of your Procfile

slate swan
slate nymph
#

omg

#

NOTEPAD!!!!!

#

BEST EDITOR IN THE WORLD

slate swan
#

i wouldve used notepad++ but this was what opened

#

ands its just for the procfile

sullen shoal
#

im kinda sleepy

#

gn

grand lagoon
#

how to write radius of a triangle with python codes

slate swan
grand lagoon
#

no

slate nymph
#

what are you talking about mate

grand lagoon
#

...

slate nymph
#

dude-

#

triangle doesnt have a radius as far as i know

#

@grand lagoon explain

manic wing
#

!ot

unkempt canyonBOT
brisk helm
#

ITs remove_roles or remove_role

slate swan
#

tias

slate swan
jaunty terrace
#

!d discord.Member.remove_roles

unkempt canyonBOT
#

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.
jaunty terrace
brisk helm
#

Thx

jaunty terrace
#

i swear eivl is always in Pycharm

slate swan
#

I finally updated hikari-lightbulb to v2 and I love it

wild oak
#

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

#

this is me trying to do python3 bot.py instead of python bot.py

slate swan
slate swan
# slate swan

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

wild oak
#

i have no clue what to do

slate swan
#

how do i add buttons with disnake

brave vessel
slate swan
#

... 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

pliant gulch
slate swan
#

ctx is undefined there, so it definitely won't

safe depot
#

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

wild oak
twin moon
wild oak
slate swan
pliant gulch
wild oak
#

like this

#

or without iirc

wild oak
pliant gulch
#

It would be discord.__version__

wild oak
#

ok

slate swan
#

Import aiohttp

pliant gulch
#

Whichever file your bot code is in

#

Add the prints there

wild oak
#

OHH

#

so print aiohttp.version

dark river
#

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)```
pliant gulch
#

Also are you using some sort of template bot?

wild oak
#

yes

pliant gulch
#

Ah, can you show me the requirements.txt file if there is one?

wild oak
#

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

pliant gulch
#

Ah.... 👀 Found out the problem

wild oak
#

AGHHHHHHHH

pliant gulch
#

Whoever the creator of this template is, kinda had a dumb moment

wild oak
#

OO

pliant gulch
#

Remove asyncio from requirements.txt

wild oak
#

Lol

pliant gulch
#

And re-install the dependencies

wild oak
#

Ok

pliant gulch
wild oak
#

Lmaoo

pliant gulch
#

After you remover asyncio from requirements and update the dependencies it should be working fine

dark river
wild oak
#

wait how do i update the dependencies

#

slow brain moment

pliant gulch
wild oak
#

pip3

#

so yeah

pliant gulch
#

Ok, try out pip3 uninstall asyncio

#

Then run the bot

wild oak
#

Ok

pliant gulch
wild oak
#

yes

#

i used this template before and it worked beautifully but idk what he did lol

pliant gulch
#

Hmm try uh

pliant gulch
slate swan
#

It has nothing to do with the requirements

pliant gulch
#

It should

slate swan
#

Can already tell that

pliant gulch
#

For some reason asyncio in the template requirements

outer violet
#

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
pliant gulch
wild oak
#

yeah ive removed it

pliant gulch
#

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

wild oak
#

yeah i can gimme a sec

quiet coral
slate swan
red blade
#

is there kinda a easy way to make a discord bot search python docs?

wild oak
#

@slate swanis that bad

slate swan
slate swan
wild oak
#

OOOOOO

#

How do i fix that

brave vessel
slate swan
#

pip install -U discord.py

pliant gulch
#

But even then I don't think discord.py supports that version

brave vessel
#

asyncio was a third party library before 3.3?

pliant gulch
#

And why does pip even install outdated versions that behind

wild oak
pliant gulch
brave vessel
brave vessel
pliant gulch
slate swan
wild oak
#

what does iirc mean

slate swan
#

iirc -> if i remember correctly

wild oak
#

UHh wait

#

ok so like it worked but i did sum wrong so hold on

slate swan
#
    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
slate swan
#

how do u round it

summer flume
#

round()

red blade
#

round(int) and int can be the variable of an integer

slate swan
#

{(psutil.virtual_memory().percent(round))}

#

like that?

red blade
#

no

slate swan
#

No

#

round(psutil.....)

#

or {round(psutil.virtual_memory().percent)}

red blade
#

round(int)

slate swan
#

ty

#

Yeah like that

wild oak
#

UGHHHHHHHHHHHHHHHHHHHHH >:|

slate swan
#

replit?

#

ggs

wild oak
#

does that mean forever lmao

slate swan
#

You can now wait up to 24 hours

#

Not forever

#

yes, it means forever obviously

#

Clearly says temporarily

wild oak
#

i told u

#

im slow

#

lmao

slate swan
#

Running on replit?

wild oak
#

No

#

Its called railway

slate swan
#

Interesting then

pliant gulch
#

Railway probably shares IP's like repl.it then

slate swan
#

Probably has the same network setup yeah

wild oak
#

So now what

pliant gulch
#

You wait

wild oak
#

i just wait

slate swan
#

Now wait

wild oak
#

ok

slate swan
#

Can be up to 24 hours

pliant gulch
#

Or stop using services like railway, if you want to avoid being banned

wild oak
#

i literally tried to do it like 293898239283 times so thats why

slate swan
#

No

wild oak
#

o

pliant gulch
#

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

wild oak
#

can i host it on my pc instead for now lmao

pliant gulch
#

And I'd doubt you'd get ratelimited from trying to relog your bot a lot

wild oak
#

?

pliant gulch
slate swan
#

Restarting your bot multiple times and attempting a websocket connection won't get you rate limited that fast

pliant gulch
#

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

wild oak
#

can i host it on my pc for now

summer flume
wild oak
#

SO NOT A DAY?

summer flume
#

I remember that I spammed the on and off bot code and I got temporarily banned, after few minutes I got unbaned

wild oak
#

ok

slate swan
pliant gulch
slate swan
#

What window manager and theme?

pliant gulch
#

bspwm oceanic next colorscheme

slate swan
#

Ty

pliant gulch
#

👍

slate swan
#

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)
jagged root
#

how can i do so the bot reply to an user message.

slate swan
#

!d discord.Message.reply

unkempt canyonBOT
#

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.
outer violet
jagged root
#

alr

slate swan
#

or context

#

yes

wild oak
jagged root
# slate swan or context
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?
slate swan
#

hm

outer violet
#

remove mention_author and just make it an f string

jagged root
#

ok

slate swan
#

I don't think mention_author should be a problem

jagged root
slate swan
#

but it would throw an error

#

and why do you need an f-string

pliant gulch
outer violet
#

i thought he wanted to mention the author as well idk

jagged root
#

hm

wild oak
#

uhhh what

slate swan
#

oh

pliant gulch
#

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

slate swan
#

on_message is not a command

pliant gulch
#

So that's two requests

slate swan
#
async def on_message()```
#

not command

#

and you don't need self

jagged root
#

ok

slate swan
#

unless you're in a cog

outer violet
#

^^

pliant gulch
wild oak
#

@pliant gulchr u talking to me?

pliant gulch
#

Taking up 1 out of 50

wild oak
#

oh

pliant gulch
pliant gulch
#

And I told you the bucket resets after 5 seconds

jagged root
wild oak
#

i ment how long is the ban

#

i thot it would tell u

slate swan
#

is there an error

#

what doesn't work on it

jagged root
jagged root
outer violet
pliant gulch
wild oak
#

oh

pliant gulch
#

Depends if you have been banned before or not though iirc

wild oak
#

what does iirc mean

jagged root
# outer violet an error would help :)
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'```
pliant gulch
#

if I remember correctly

wild oak
#

OHH

#

ive never been banned

wild oak
#

but i tried it like 2 times after the ban thing showed up

jagged root
slate swan
#

!d discord.Message.reply

unkempt canyonBOT
#

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.
slate swan
#

what version of dpy are you using

wild oak
pliant gulch
#

I don't think so

wild oak
#

Ok good

jagged root
slate swan
#

um

jagged root
#

or update it

slate swan
#

well idk how to check it

pliant gulch
#

You can print discord.__version__

#

To get which version you have

slate swan
#

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

unkempt canyonBOT
#

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...
slate swan
#

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

jagged root
#
                f"⚠️ {message.author.mention} Yooo, chill out.")```
this could work?
slate swan
#

no

jagged root
#

f

slate swan
#

did you check your version?

jagged root
#

nop

#

just wanna update it

#

but idk how

slate swan
#

pip install -U git+https://github.com/Rapptz/discord.py

jagged root
#

thats my version

slate swan
#

the python version?

jagged root
#

ye

#

ig

slate swan
#

the dpy version

#

we need

jagged root
#

im using ur cmnd rn

#

its updating it seems

slate swan
#

that should update

#

ye

jagged root
# slate swan that should update
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

slate swan
#

what

jagged root
#

thats what it said

slate swan
#

I don't get why it doesn't work

jagged root
#

nethier

slate swan
#

that's what R.Danny said in the dpy server

#

what os do you have

jagged root
#

idk nethier

lusty geyser
#

What do you guys use to store data per user?

slate swan
#

database

lusty geyser
#

Any suggestions for a db?

slate swan
#

postgresql

tawny knoll
#

if you have a general event handler cog, how can you override and show the specific command errors?

blissful crane
#

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

visual island
#

!d asyncio.wait

unkempt canyonBOT
#

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...
rustic temple
#

question about embeds

#

how do i have a link dispaly on an embed

#

for example

#

that vs

#

the first one looks much better

visual island
summer flume
rustic temple
rustic temple
summer flume
#

like this emb = discord.Embed(title = "", description = "", color = "")

#

and discord will auto preview the link

rustic temple
#

for some reason no matter where I put it, i dont get a preview 😦

silver wolf
#

ur not gonna get a preview in embeds

#

the closest thing is assigning it an image

final iron
#

You could use aiohttp to grab the image and display it I guess

nova mauve
#

Getting this error when trying to run my discord.py script

final iron
#

discord.channel.PartialMessageable?

#

!d discord.channel.PartialMessageable

unkempt canyonBOT
#

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...
final iron
#

You cannot import that

nova mauve
#

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

final iron
#

Can you verify discord is imported correctly?

#

remove that code and try

import discord
print(discord.__version__)
nova mauve
#

kk

slate swan
nova mauve
#

@final iron

#

my stuff messed up frfr

nova mauve
final iron
#

Use aiohttp

final iron
#

Are you using a venv?

nova mauve
#

my friend can run my script but i cannot

nova mauve
final iron
#

Im guessing anaconda?

nova mauve
#

idek im just on an RDP

final iron
#

Why?

nova mauve
#

my pc sucks

#

like its rly old laptop

final iron
#

I would suggest you download a package manager like anaconda, create a venv and try downloading discprd.py in there

slate swan
#

Is there a way I can check if a text_channel with a name is already on the server?

rare saddle
#

Please tell me why it doesn't work?

slate swan
#

How do you check how much characters a message has with len()?

fast tree
#

Hey guys, how can I ping people in a embed?

slate swan
fast tree
fast tree
slate swan
fast tree
#

How do I use it?

#

I want to have it in my description,

#

is that possible?

slate swan
#

You use the member object

slate swan
fast tree
#

{member.mention}

#

like this?

slate swan
fast tree
#

{member.mention} Zeatman

slate swan
fast tree
#

@silk mauve hi btw

#

lol

slate swan
#

How do I check if the member is speaking through dm only using bot listen("")?

fast tree
#

{member.mention Zeatman}

#

Thats how it is?

slate swan
#

Get the members id and you mention him

fast tree
#

okay

slate swan
#

@commands.guild_only() doesn't seem to work if I use bot.listen()

slate swan
fast tree
#

Ye

#

Thanks

glass rock
#

wait what

slate swan
#

Yes

#

Now help me

glass rock
#

ive been using <@id> lol

slate swan
#

Can u help Me sand?

#

Please

slate swan
glass rock
slate swan
#

Never done it before

fast tree
#

Ye, pls

slate swan
#

Or okimii

slate swan
#

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

fast tree
#

{member.911779386615795753.mention.}

#

Thats right, right?

slate swan
#

Idrk

fast tree
#

f string I know

slate swan
#

Yeah ofc

slate swan
fast tree
#

Huh

#

SyntaxError: f-string: invalid syntax

slate swan
fast tree
#

(member.911779386615795753.mention.)

slate swan
#

How do I check the channel type and what is that

rare saddle
#

How to get a bot avatar?

fast tree
rare saddle
rare saddle
slate swan
#

Oh

slate swan
#

Lol

#

Hi DevKid

#

I'm a kid too

fast tree
#

g = id?

fast tree
slate swan
#

:Pog:

fast tree
slate swan
#

Help

#

if ctx.guild: return

#

Like this?

fast tree
slate swan
#

What r u trying to do DevKid

fast tree
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: module 'discord.member' has no attribute 'g'

fast tree
slate swan
#

U cant ping in embeds

#

They dont actually ping

fast tree
#

But like

slate swan
#

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()

fast tree
slate swan
#

Because it ain't a command ig

fast tree
#

It doesnt actually ping but you know what I mean

slate swan
#

Yeah

#

Just do member.mention

#

Wow

fast tree
#

But I dont want to ping myself

slate swan
#

That's that easy

#

Use guild.get_member() to get member

#

I think thats the right one

#

@slate swan can u help me too

fast tree
slate swan
#

Oh u might need to enable intents

#

Help me

#

U could try get_user i think its client/bot.get_user

slate swan
#

No but how do I check if the member is speaking to the bot through dms only

#

@slate swan

fast tree
slate swan
#

What are u tryna do commands in dm or speaking?

glass rock
slate swan
fast tree
#

My brain is not working, its 2am for me

slate swan
#

Doesn't work

slate swan
#

Yes

#

if not ctx.guild: return

#

I think its as simple as a setting u set somewhere

fast tree
slate swan
slate swan
#

Oh dang

#

So I should do the opposite then

slate swan
#

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

fast tree
slate swan
#

And use guild.get_member()

fast tree
rare saddle
#

How to send a message to a random channel correctly?

fast tree
#

member=bot.get_user("911779386615795753")

slate swan
#

Ok maybe users dont have mention

#

Get member intent and do it with member

fast tree
#

How

glass rock
slate swan
#

Discord dev portal

fast tree
#

oh shit

slate swan
#

Where u make the bot on discord

slate swan
fast tree
#

its fine

glass rock
slate swan
#

That part looks fine

rare saddle
fast tree
#

what now

slate swan
fast tree
#

?

slate swan
#

U also might need to subscribe to intents in ur code

fast tree
#

I am gonna sleep

#

Its 2am and my brain isnt working anymore

#

I dont understand anything anymore

#

still ty

slate swan
#

Lmao bye

rare saddle
slate swan
#

@fast tree see this code for doing intents

#

The top part

slate swan
#

That looks wrong

glass rock
rare saddle
slate swan
#

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?

slate swan
#

Do guild.text_channels

rare saddle
rare saddle
slate swan
#

Your welcome

slate swan
#

Lol

glass rock
#

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

glass rock
#

k

slate swan
#

@fast tree its like this:

Myid = "<@int>"
print(myid)

Output:

@int
silk mauve
#

Guys

#

I want to ping people in my embed

#

Not really ping but you know what I mean

#

But idk how to do that

slate swan
#

Thats how you ping someone with their id

silk mauve
slate swan
silk mauve
#

but like

#

wait

#

title="◈ ℍ𝔸ℕ𝔸𝕄𝕀 𝔹𝕆𝕆𝕊𝕋𝔼ℝ◈",
description=f"𝘽𝙊𝙊𝙎𝙏𝙀𝙍:\n\n ➥{myid}",
colour=discord.Colour.purple(),
timestamp=datetime.datetime.utcnow(),

#

This is my code

#

How to

slate swan
#

{myid}

#

Put it were you want it to be

silk mauve
#

Alright

#

Now

#

title="◈ ℍ𝔸ℕ𝔸𝕄𝕀 𝔹𝕆𝕆𝕊𝕋𝔼ℝ◈",
description=f"𝘽𝙊𝙊𝙎𝙏𝙀𝙍:\n\n➥{Myid}",
colour=discord.Colour.purple(),
timestamp=datetime.datetime.utcnow(),
Myid="@silk mauve"

#

Like this

slate swan
#

And make a variable named myid and add the id

flint forum
#

your id is 371597683548225537

silk mauve
#

371597683548225537

flint forum
#

so paste 371597683548225537 in there

silk mauve
#

I know

#

I did

#

SyntaxError: f-string: invalid syntax

slate swan
#

Send the trance back

silk mauve
#

wdym

slate swan
slate swan
#

I dont think that works in embeds

silk mauve
#

I've so a brain f#ck

slate swan
silk mauve
slate swan
#

A = member.mention

#

Inside ur embed

silk mauve
#

title="◈ ℍ𝔸ℕ𝔸𝕄𝕀 𝔹𝕆𝕆𝕊𝕋𝔼ℝ◈",
description=f"𝘽𝙊𝙊𝙎𝙏𝙀𝙍:\n\n➥{member.mention}",
colour=discord.Colour.purple(),
timestamp=datetime.datetime.utcnow(),

#

Like this?

slate swan
#

Actually

silk mauve
#

And now

slate swan
#

a = guild.get_member(id)

#

Inside embed

#

F strings do work in embeds too

slate swan
#

f'{a.mention}'

#

May you please show how to mention a member with their id?

slate swan
silk mauve
#

Alright

slate swan
#
f"<@!{id}>"```
#

No

silk mauve
#

raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'a' is not defined

slate swan
#

That doesnt work in embeds

silk mauve
#

title="◈ ℍ𝔸ℕ𝔸𝕄𝕀 𝔹𝕆𝕆𝕊𝕋𝔼ℝ◈",
description=f"𝘽𝙊𝙊𝙎𝙏𝙀𝙍:\n\n➥{a.mention}",
colour=discord.Colour.purple(),
timestamp=datetime.datetime.utcnow(),
A=guild.get_member(371597683548225537)

slate swan
#

Actually try it

slate swan
silk mauve
#

title="◈ ℍ𝔸ℕ𝔸𝕄𝕀 𝔹𝕆𝕆𝕊𝕋𝔼ℝ◈", description=f"𝘽𝙊𝙊𝙎𝙏𝙀𝙍:\n\n➥{a.mention}", colour=discord.Colour.purple(), timestamp=datetime.datetime.utcnow(), A=guild.get_member(371597683548225537)

slate swan
#

Also get member needs to be higher than a.mention

silk mauve
#

raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'a' is not defined

slate swan
#

If you do <@id> it pings them

#

Yeah coz u put it after

slate swan
silk mauve
#

Ok

#

I'll try

slate swan
#

@slate swan thx for showing never new that <@id> was even a thing

silk mauve
#

IT WORKED

slate swan
silk mauve
#

OMG I LOVE U GUYS

slate swan
#

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?

slate swan
#

Lol

#

It would

#

It did

#

It does but it shows my id idk why

#

Magic

#

It's \@okimii

#

@slate swan

#

Dont ruin the magic

slate swan
slate swan
#

It also works for everyone and still pings if u have perms but is white

slate swan
slate swan
#

\😀

#

pixels_snek_2 try <@&the_servers_id> in. A guild

#

Lol

slate swan
#

U can do voice channels aswell

slate swan
slate swan
slate swan
slate swan
#

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

slate swan
slate swan
slate swan
#

lol it does not show up with a voice icon on mobile

slate swan
#

no i didnt make it, its already AFK channel, but u can link to voice channels like text channels with the id using <#id>

slate swan
#

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

rare saddle
#

How to specify the time to send a message in a function on_guild_join?

slate swan
#

asyncio.sleep()?

#

If its a delay^

silk mauve
slate swan
#

Is there a way I can check if there is a channel with a specific name on the server?

silk mauve
#

Becuase it didn't

slate swan
#

told u they dont work in embeds

silk mauve
#

How do I do

slate swan
#

like i said

silk mauve
#

It worked with members

slate swan
#

No thats a role id

#

a = guild.get_members()

silk mauve
#

But it didn't mit roles

#

with

slate swan
#

for roles &

#

instead of !

silk mauve
#

ah

#

thanks

slate swan
#

oh i wanted to be right

slate swan
#

role and member i guess

#

i dunno the difference between ! and no !

#

both work

slate swan
slate swan
#

musta done wrong role id

silk mauve
#

I didnt

slate swan
#

does it work outside of the embed?

silk mauve
#

idk

slate swan
#

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

silk mauve
#

And It's not the wrong id

slate swan
#

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] + '...'```
stone moon
#

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

slate swan
#

if bot.mention in message.contents:
await message.add_reaction()

#

oh

stone moon
#

yeah

slate swan
#

u can check a message to see how many mentions are in it

wicked atlas
#
if message.mentions:
slate swan
#

^

stone moon
#

don’t understand entirely yet

stone moon
wicked atlas
#

!d discord.Message.mentions

unkempt canyonBOT
#

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.

stone moon
#

that’s so awesome thanks a lot

slate swan
#
  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?

stone moon
wicked atlas
slate swan
#

and then match the names

slate swan
slate swan
#

According to docs its related to nicknames

slate swan
wicked atlas
slate swan
#

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

wicked atlas
slate swan
slate swan
slate swan
slate swan
wicked atlas
# slate swan So ```py try: discord.utils.get(guild.channels, name="general-chat") except:...

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:
      ...
slate swan
#

Cant you just do if channel.name = "":???

slate swan
#

i was telling him that method but this more elegant

slate swan