#discord-bots

1 messages Β· Page 620 of 1

shadow wraith
#

you could use discord.Member if your bored

#

because idk if that works

boreal ravine
#

isn't it spoonfeeding without explanation

slate swan
#

The more I look at y'all convo the more I lose my brain cells πŸšΆβ€β™‚οΈ

shadow wraith
vale wing
#

Have any of you guys ever tried making AI chatbot

tropic briar
#
@bot.event
async def on_message(message):
  await bot.handler.propagate(message)
  await bot.process_commands(message)
  muted = message.guild.get_role(912976244499427339)
  message_split = message.content.split(".")
  for message_word in message_split:
    for bad_word in Filter:
      if(bad_word == message_word.lower()):
        await message.delete()
        await message.channel.send("I have deleted that message :angry:")
        message.author.add_roles(muted)
``` @vale wing Not working, I am the owner
boreal ravine
#

would've solved it a lot quicker if he knew more about class instances :')

tropic briar
#

oh wait

vale wing
#

Why not use listen

#

And yeah await it

boreal ravine
#

!d discord.Member.add_roles do people even read these smh

unkempt canyonBOT
#

await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
vale wing
#

Most of API interactions require awaiting just remember that MCK_SuperFlushed

shadow wraith
#

bro

tropic briar
#

and it worked Thanks a lot guys

vale wing
#

Np

shadow wraith
#

i tried using add_roles and it worked but my bot didnt have perms so i suppose it work

#

i tried running my example and it worked 🀯

vale wing
#

What does atomic parameter do btw

#

Like if it is true it adds all at once

#

And if false one by one

#

Right?

shadow wraith
#

that was an atomically unnecessary to explain 🚎

sullen shoal
#

User doesnt have guild stuff

boreal ravine
#

user = discord user

shadow wraith
#

huh

boreal ravine
#

member = guild member

shadow wraith
#

i think it worked for me

boreal ravine
shadow wraith
#

it just had a perm error

#

wait

#

let me inv the bot to a testing server

#

and see if it works

vale wing
#

See

#

!d discord.Member.add_roles

#

Only works for member

#

So typehint must be discord.Member and not discord.User

maiden fable
#

What error

visual island
sullen shoal
#

it cant be that slow to not even handle one bot

slate swan
#

You're at the wrong place.

sullen shoal
#

must be some crap code

prisma spoke
#

how do i indicate this as i want title as a user input? ` def check(m): return m.content = title and m.channel == channel

sullen shoal
#

what

rain olive
sullen shoal
#

so

abstract kindle
#

heyo guys

#

Myxi

#

I learned databases

prisma spoke
sullen shoal
#

your commands mostly run by a few events that the web sockets send and receive

abstract kindle
#

You were right, but it's still pretty tricky cause I'm having to do all my checks with tuples now instead of strings

#

Also, I have a question. Is there any way to send a message to the channel if a decorator error occurs? Like if a user can't use a command because @commands.has_role('baller') is preventing them from using it?

sullen shoal
#

i think it raises an error tho

#

!d discord.ext.commands.has_role

unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role.

If the message is invoked in a private message context then the check will return `False`.

This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
fading harness
abstract kindle
#

?

#

That isn't the question.

sullen shoal
#

catch the errors

abstract kindle
#

I'm wondering if when an error is raised I can send something

abstract kindle
#

What is the syntax for catching errors?

fading harness
#

use on_command_error

sullen shoal
#

use global error handlers

fading harness
slate swan
sullen shoal
#

using on_command_error event

fading harness
#

it is global

#

but you can do if instance(error, commands.MissingPermissions)

abstract kindle
#

would i just put in MissingRole(item)

fading harness
abstract kindle
#

oh ok

#

Cause in the core.py file it says when it happens it raises that exact thing

abstract kindle
#

Let me do some testing

#

Oh also, are you saying I would put this in the main code as a message that send ANY time someone doesn't have permissions?

slate swan
sick talon
#

i am doing %search hi 3 and i am getting this error

Command raised an exception: TypeError: search() missing 1 required keyword-only argument: 'page'

    @commands.command()
    # This command allows the user to search through the top repos in an org
    async def search(self, ctx, *, repo, page):
slate swan
sick talon
slate swan
#

You can't put it like that

sick talon
slate swan
#

You can only have one keyword argument

sullen shoal
#

yes

slate swan
#

So replace the order of arguments

unkempt canyonBOT
#

cogs/global_events.py lines 21 to 28

@commands.Cog.listener()
async def on_command_error(self, ctx, error):
    if isinstance(error, CommandNotFound):
        await ctx.send(embed=discord.Embed(
            color=easyembed.getcolor(ctx=ctx),
            title='Not found',
            description=
            f'Command not found. Try this instead: `​{ctx.prefix}help`​'))```
sullen shoal
#

old code, i hate that project

slate swan
abstract kindle
#

thanks @sullen shoal

slate swan
#

hey

slate swan
#
@client.command()
@commands.has_permissions(manage_messages=True)
async def session(ctx, time, md, *, name):
    if ctx.channel.id == 912962943484066367:
        mes = await ctx.send(f'**{ctx.author.mention} is hosting:**\n*Info: {info}\Name: {name}\nDate: {datetime.today().weekday()}*\n*Please react to this message if you plan on joining today! See you all there!*')
        await mes.add_reaction(":heavy_check_mark:")```
#

Does anyone know how to @ everyone?

sullen shoal
#

just putting @everyone should work

sick talon
slate swan
#
@client.command()
@commands.has_permissions(manage_messages=True)
async def session(ctx, time, md, *, name):
    if ctx.channel.id == 912962943484066367:
        mes = await ctx.send(f'|| @everyone ||**{ctx.author.mention} is hosting:**\n*Info: {info}\Name: {name}\nDate: {datetime.today().weekday()}*\n*Please react to this message if you plan on joining today! See you all there!*')
        await mes.add_reaction(":heavy_check_mark:")```
slate swan
dusk pumice
sick talon
dusk pumice
#

I need to use SQL...

#

I hate you SQL
I'm gonna kill you SQL!

sick talon
#

btw does anyone what is the error handler for the embed character limit pithink

dusk pumice
#

Hmmm. You are kylee

#

I think you were

sick talon
#

how to check which required argument is missing pithink

slate swan
#

free place to host discord bot?

sullen shoal
#

i think the class has an attribute for it

sick talon
sullen shoal
sick talon
sullen shoal
#

you will get an error, when its actually missing

abstract kindle
#

Lol I'm running into an error. My bot is sending everything twice....

#

It has something to do with on_message(self, message)

sick talon
#

i have made an error handler, i want to send the required args name along with the message

something like this :
Use all the required arguments | Missing argument : <the-missing-argument-name>

        elif isinstance(error, commands.MissingRequiredArgument):
            await ctx.send("Use all the required arguments")
abstract kindle
#

Am I missing a parameter in there?

#

Kira you can manually put them in there at the end of the string if there aren't too many arguments

sick talon
boreal ravine
#

@dusk pumice your nickname-

abstract kindle
#

Hahaha I thought I had that somewhere in there

boreal ravine
sullen shoal
abstract kindle
#

its in a cog. is this not good enough? ```py
if message.author == self.bot.user:
return

sullen shoal
unkempt canyonBOT
sullen shoal
boreal ravine
slate swan
#

If I was to delete all messages sent in a channel I would have to do on_message and if channel.id == <id> then delete right?

Is there a more efficient way of doing this?

abstract kindle
#

oh

sullen shoal
abstract kindle
#
        await self.bot.process_commands(message)
#

its something to do with this

boreal ravine
abstract kindle
#

Because it only happens on commands I think

slate swan
sullen shoal
boreal ravine
boreal ravine
abstract kindle
#

I figured it out

#

self.bot.process was running it twice since it's in a cog

#

only needed self.process

sullen shoal
#

you dont need to process if its just a listener

slate swan
abstract kindle
#

the whole thing is self.process_commands(message)

boreal ravine
#

afaik no other way is efficient

orchid inlet
#

Sup guys. How do I get started making a discord bot

#

is there a start guide some where

abstract kindle
#

yeah

boreal ravine
orchid inlet
#

wdym?

boreal ravine
#

what

sullen shoal
boreal ravine
abstract kindle
boreal ravine
abstract kindle
#

Really good tutorial

boreal ravine
sullen shoal
boreal ravine
slate swan
abstract kindle
#

I used that one and so far im CHILLIN

boreal ravine
#

And also what asyncio does

orchid inlet
boreal ravine
unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

abstract kindle
#

yeah learn some python first XD

sullen shoal
orchid inlet
#

okay thanks

abstract kindle
#

wait @sullen shoal

#

For the whole process_commands(message) thing

slate swan
abstract kindle
#

im assuming you need it if it's not in a cog and its just under @bot.event

lone aurora
#
    @commands.Cog.listener()
    async def on_ready(self):
        await self.client.change_presence(status=discord.Status.idle, activity=discord.Game('1'))
        await asyncio.sleep(5)
        await self.client.change_presence(status=discord.Status.idle, activity=discord.Game('2'))``` How can i make this loop endlessly? *under a cog btw*
sullen shoal
abstract kindle
#

are listeners only in cogs

quick gust
#

no

#

u can add one in ur main file too

abstract kindle
#

what are they used for?

sullen shoal
#

you can also use it with Bot.listen

lone aurora
abstract kindle
#

the first time I saw how to make the on_message function, they didn't use a listener

#

so what is the purpose of a listener with on_message?

orchid inlet
#

is there any similarities between html and python?

#

Or is it 2 whole different languages

quick gust
#

well it is lmao

slate swan
#

How to get avatar url as png??

slate swan
orchid inlet
#

How do you make the code blocks in this chat

slate swan
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

orchid inlet
#

'hello'

slate swan
lone aurora
slate swan
# lone aurora Can you show me how I could do that?
from discord.ext import tasks

status = '1'
@tasks.loop(seconds=5)
async def change_status():
    if status == '1':
        await bot.change_presence(..., discord.Game('2'))
        status = '2'
    else:
        status = '1'
        await bot.change_presence(..., discord.Game('2'))

change_status.start()
slate swan
orchid inlet
#

Β΄print ("Hello World")Β΄

slate swan
#

CTRL C+V

slate swan
orchid inlet
#
print('Hello world!')
#

ah

slate swan
orchid inlet
#

print ("Hello World")

#

there you go

slate swan
#

I want to get the png form

#

possible?

#

Just replace it

unkempt canyonBOT
#

await save(fp, *, seek_begin=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Saves this asset into a file-like object.
slate swan
#

can you explain

#

User avatars supports PNG, JPEG, WebP, GIF

#

So you can easily get any of these

#

!d discord.Asset.with_format

unkempt canyonBOT
slate swan
#

o ok

#

.with_format('png')

#

\πŸ‘

slate swan
#

.display_avatar

#

.avatar can be None

#

o ok

#

is it possible to send people dm with user.id which are in a txt file?

lone aurora
#
@tasks.loop(seconds=5)
async def change_status():
    status = '1'
    if status == '1':
        await client.change_presence(status=discord.Status.idle, activity=discord.Game('-help'))
        status = '2'
    else:
        status == '2'
        await client.change_presence(status=discord.Status.idle, activity=discord.Game('-help2'))

change_status.start()``` this doesn't seem to be working..

Error = `in change_presence
    await self.ws.change_presence(activity=activity, status=status, afk=afk)
AttributeError: 'NoneType' object has no attribute 'change_presence'`
slate swan
#

(its a giving payout)

lone aurora
#

@slate swan any clue?

slate swan
#

You didn't define what bot is

lone aurora
#

but im not using bot

#

i switched it to client

slate swan
#

Oh

#

Weird

#

How can I send author avatar (no embed/avatar url) direct file??

slate swan
visual island
slate swan
#

No clue what self.ws is supposed to be tho :kek:

#

Websocket connection is None

#

Ah makes sense

lone aurora
visual island
#

!d discord.Client.wait_until_ready

unkempt canyonBOT
#

await wait_until_ready()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits until the client’s internal cache is all ready.
slate swan
#

😐 😐

visual island
lone aurora
slate swan
visual island
lone aurora
#

uhh what do i need to import for it?

slate swan
lone aurora
#
@tasks.loop(seconds=5)
async def change_status():
    await wait_until_ready()``` also would be like this or uh

```py
await wait_until_ready()
@tasks.loop(seconds=5)
async def change_status():```
#

newbie 101

sick talon
#

pithink how can i make a paginator which shows certain amount of elements of a list in a separate page

something like this

test = ["hi","hello","lol","kek","testing"]

i want two elements should be showed in a single page
so the first page should have hi and hello and the second one lol and kek and third one testing

pithink it would be great even if someone gives some kind of hint

slate swan
#

how do I send dm to specific user using their id?

#

can i use await user.send()?

lone aurora
visual island
slate swan
#

i want to send the file as png and if user has nitro then gif

lone aurora
sullen shoal
slate swan
#

thank you blank, kira and seatch

slate swan
slate swan
lone aurora
visual island
# slate swan so?
a = User.avatar_url_as(format="jpg").save("filename.jpg")
await ctx.channel.send(file=discord.File("filename.jpg"))
lone aurora
visual island
lone aurora
#

thanks

#

i should learn how to read the library πŸ˜”

sick talon
orchid inlet
#

yo guys. import discord doesnt work

sick talon
#

in the command prompt

orchid inlet
#

I will try now

sick talon
#

lol why are you importing message,channel ... lemon_pikalemon_pika

orchid inlet
sick talon
#

yeah there is no need of that

#

pithink idk about discord utils module sorry

lone aurora
#
@tasks.loop(seconds=5)
async def change_status():
    await client.wait_until_ready()
    status = '1'
    if status == '1':
        await client.change_presence(status=discord.Status.idle, activity=discord.Game('-guide'))
        status = '2'
    else:
        status == '1'
        await client.change_presence(status=discord.Status.idle, activity=discord.Game('-guide2'))

change_status.start()``` 

Did I change something I shouldn't have?
sick talon
sullen shoal
#

reaction based or button based?

sick talon
sick talon
sick talon
#

pithink thanks

sick talon
sullen shoal
unkempt canyonBOT
#

itertools.pairwise(iterable)```
Return successive overlapping pairs taken from the input *iterable*.

The number of 2-tuples in the output iterator will be one fewer than the number of inputs. It will be empty if the input iterable has fewer than two values.

Roughly equivalent to:

```py
def pairwise(iterable):
    # pairwise('ABCDEFG') --> AB BC CD DE EF FG
    a, b = tee(iterable)
    next(b, None)
    return zip(a, b)
```...
sullen shoal
#

AB BC
it will be like this tho

sick talon
#

thanks

sullen shoal
#

i think you have to make your own algorithm for AB CD

sick talon
slate swan
#
@bot.command()
async def msg(ctx, user):
    userid = 793206762101669948
    user = bot.get_user(userid)
    await user.send("hehe")```
error: user argument is missing
boreal ravine
#

if i iterate through discord.Message.mentions will it have an id attribute?

slate swan
#

help pls

boreal ravine
sullen shoal
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.

boreal ravine
#

hm

sullen shoal
#

it returns a list of Member

boreal ravine
sullen shoal
#

yes

boreal ravine
#

ah ok ty

sullen shoal
#

keep in mind,

if the message is in a private message then the list will be of User instead.

#

though, both have id attribute

visual island
#

how about if the member leaves the guild? will it be User?

slate swan
visual island
#

undocumented (unlike message.author) but alright

slate swan
#

but it was giving user argument missing error

#

codes:

@bot.command()
async def msg(ctx, user):
    user = bot.get_user(793206762101669948)
    await user.send("hehe")```
visual island
#

if you dont need the user parameter why would you have it there?

slate swan
visual island
#

no, on message.mentions i mean. "How if the member that's mentioned leaves the guild? Will it be user?"

dusk pumice
#

How to get thing like this?

visual island
#

!d discord.Member.roles

unkempt canyonBOT
#

property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [β€˜@everyone](mailto:'%40everyone)’ role.

These roles are sorted by their position in the role hierarchy.
slate swan
#

( the member Is kicked)

abstract kindle
#
    @commands.command()
    async def reward(self, ctx):
        item = 'sword'
        if os.path.isfile(f'Discord Avatars/{ctx.author}.png'):
            print("Image already exists in path.")
        else:
            await ctx.author.avatar_url_as(format="png").save(fp=f"Discord Avatars/{ctx.author}.png")
        file = discord.File(f"{ctx.author}.png")
        rewardembed = discord.Embed(title="Victory!", description=f'You won this item! {item}',color=discord.Colour.gold())
        rewardembed.set_image(url=f"attachment://{ctx.author}.png")
        print(f'{ctx.author}.png')
        await ctx.send(file=file, embed=rewardembed)
        print(ctx.author)
        # await ctx.send(embed=rewardembed)
#

How come this code isn't getting past the if / else: statement..

#

If it passes the if check, it doesn't run the other code beneath the if / else

#

Am i being stupid rn?

boreal ravine
#

afk command flex 😎

boreal ravine
abstract kindle
#

Can you not have code after an if / else statement?

boreal ravine
#

you can

#

uh

abstract kindle
#

Yeah, so I wan't to run the code after the if / else statement happens

#

but none of it runs. It gets to the if statement and then stops

#

None of the print statements beneath the if / else are happening

visual island
visual island
slate swan
#
@Blank.command(aliases=["avatar", "pfp"])
async def av(ctx, user:discord.Member=None):
    await ctx.message.delete()
    if user is None:
        user=ctx.author
    if not user.avatar:
        await ctx.channel.send("User does not has any avatar")
    else:
        avatar_content=requests.get(user.avatar.read())
        image=io.BytesIO(avatar_content)
        try:
            await ctx.channel.send(file=discord.File(image))
        except:
            await ctx.channel.send(user.avatar_url.replace('.webp', '.png'))```
velvet tinsel
#

can you DM someone in a mutual server using a bot?

slate swan
velvet tinsel
slate swan
#

wait I think I understood

velvet tinsel
#

great!

visual island
slate swan
#

I used it because IDK if the avatar is .gif

slate swan
#

can you help....I wish that It send the avatar as an attachment

But sends file with .webp extension as .png

zealous dagger
#

How can I change

#

Embed

#

using

#

Dropdown

boreal ravine
unkempt canyonBOT
boreal ravine
#

Use that to change it from webp to png

zealous dagger
#

I want to add in my help command

#

@boreal ravine

boreal ravine
#

Don't ping me

slate swan
#

I am doing this because I dont think discord previews webp images

visual island
unkempt canyonBOT
#
Naw.

No documentation found for the requested symbol.

slate swan
visual island
#

yea it exists

boreal ravine
unkempt canyonBOT
#

is_animated()```
[`bool`](https://docs.python.org/3/library/functions.html#bool "(in Python v3.9)"): Returns whether the asset is animated.
visual island
#

The embed is for 2.0

boreal ravine
#

2.0 go brrr, he's using 1.7.x

#

oh

#

my bad

orchid inlet
#

import discord doesnt work

#

And I have installed it in cmd

valid perch
#

What cmd

visual island
#

cmd prompt*

orchid inlet
#

do you know why @visual island

visual island
#
  1. You're doing it wrongly
  2. The cmd prompt hadn't connected your project
orchid inlet
#

how do I do that then?

visual island
#

What did you do before?

tropic briar
#

Can we use emotes that are from private servers in a bot embed or message

visual island
#

yes

tropic briar
orchid inlet
#

and then in my python file in VScode I said import discord

lethal moat
#
async def ForageCommand(ctx):
    PossibleItems = ["Red berry", "Blue berry"]
    item = random.choice(PossibleItems)
    embed = nextcord.Embed(title="Searching",description="You are looking for items in the forest...",color=0x11ba2a)
    embed.set_footer(text=f"Requested by {ctx.author.display_name}")
    message = await ctx.reply(embed=embed, mention_author=False)
    await asyncio.sleep(5)
    embed = nextcord.Embed(title="You found something!", description=f"You found a {item}!")
    embed.set_footer(text=f"Requested by {ctx.author.display_name}")
    await message.edit(embed=None)
    await message.edit(embed=embed)

the edited embed never appears, no errors in terminal whatsoever
i did await the function when i ran it, otherwise there would be errors in terminal

visual island
tropic briar
lethal moat
#

:Bar1Full:

visual island
orchid inlet
#

I did python -m pip install discord
and then in my python file in VScode I said import discord

#

@visual island

tropic briar
tropic briar
orchid inlet
#

how

tropic briar
#

Just find the terminal in your IDE

orchid inlet
#

uhm

#

im very new to this

tropic briar
#

and do
pip install discord

tropic briar
orchid inlet
#

in vscode?

visual island
#

who executes the command? You?

tropic briar
lethal moat
#
async def ForageCommand(ctx):
    PossibleItems = ["Red berry", "Blue berry"]
    item = random.choice(PossibleItems)
    embed = nextcord.Embed(title="Searching",description="You are looking for items in the forest...",color=0x11ba2a)
    embed.set_footer(text=f"Requested by {ctx.author.display_name}")
    message = await ctx.reply(embed=embed, mention_author=False)
    await asyncio.sleep(5)
    embed = nextcord.Embed(title="You found something!", description=f"You found a {item}!")
    embed.set_footer(text=f"Requested by {ctx.author.display_name}")
    await message.edit(embed=None)
    await message.edit(embed=embed)

the edited embed never appears, no errors in terminal whatsoever
i did await the function when i ran it, otherwise there would be errors in terminal

orchid inlet
#

Oh yeah I see

#

where my resuslts go¨when I press run

tropic briar
tropic briar
#

Oh yes no

#

It is called Console

orchid inlet
#

requiremtn already satisfied

#

that is what it said

tropic briar
#

Hmm

#

Is there any error?

#

ModuleNotFound Error

orchid inlet
#

no

#

or wait

tropic briar
orchid inlet
tropic briar
orchid inlet
#

well. It still dont work

#

for some odd reason

visual island
#

It's what your if statement does right? If the author id is your id, execute the aiohttp thing

#

what do you mean "but also says no thanks"? So it executes both the if block and the else block?

#

!d discord.ext.commands.has_role yeah

unkempt canyonBOT
#

@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.

If a string is specified, you must give the exact name of the role, including caps and spelling.

If an integer is specified, you must give the exact snowflake ID of the role.

If the message is invoked in a private message context then the check will return `False`.

This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").

Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
orchid inlet
#

@tropic briar I found out. I need to install an API, but I dont know how

#

where do I download a discord API

shadow wraith
#

bru

#

requirement satisfied means you've downloaded everything

#

giant do be spreading misinfo ngl

sick talon
#

i have a list and want to make an embed with field title as the elements in the list

shadow wraith
#

are you saying you want the title to be a random choice from your list?

#

if so look at this example

shadow wraith
#

oh

#

could you elaborate what you need help with

sick talon
shadow wraith
#

hm

sick talon
shadow wraith
#

not sure what an embed field is but if you mean this thing i found from google

shadow wraith
#

hmm

#

i am getting the confusion already lmfao

velvet tinsel
#

Use a for loop

shadow wraith
#

oh

velvet tinsel
#

@sick talon make a for loop

sick talon
velvet tinsel
#

for item in yourlist

shadow wraith
velvet tinsel
#

And embed add field

shadow wraith
sick talon
#

i want separate fields for each element

#

not all in the same field

#

if the list is ["first","second","third"] then the embed should look like this

sick talon
#

@shadow wraith does it make sense now ?

shadow wraith
#

oh you want like an automated way to make fields and stuff

#

i could say manually doing it is an option but ehhh

sick talon
shadow wraith
#

embed.add_field

#

shoot,

#

!d discord.Embed.add_field

unkempt canyonBOT
#

add_field(*, name, value, inline=True)```
Adds a field to the embed object.

This function returns the class instance to allow for fluent-style chaining.
shadow wraith
#

you could always use this

#

but lists and embeds connection is

#

eh, i dont think its really possible

sick talon
#

i am working with the api and i have stored few stuff inside lists

sick talon
shadow wraith
#

then make it manually pithink

lethal moat
#

my bot isnt able to make use of the custom emojis in my server, anyone know why?

#

i checked it with default discord emojis and they work

shadow wraith
#

do \:emojiname

#

type that in chat

#

and then you'll send an emoji id

lethal moat
shadow wraith
#

see!

#

now don't use :BarFull: use the emoji id

lethal moat
#

nice thanks

shadow wraith
#

did it work?

#

i think it did.

sick talon
#

!paste

unkempt canyonBOT
#

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.

shadow wraith
#

github repositories but like idk how to make fields present lists and stuff since adding like 3 fields for example would be 3 lines of code

#

wait a second

#

hmm let me try indexing

shadow wraith
covert palm
#

Any idea how I can make a reaction of that if u react on a message u get a role and then u can acces the rest of the channel?

shadow wraith
#

strings*

shadow wraith
sick talon
#

this is my embed design this is how i want it to look

covert palm
sick talon
shadow wraith
#

ok, so what i know

#

is that you have a list

#

seperate lists

#

i think indexing would work in my opinion

#

{list_obj[0]}

#

but i geniunely do not know Β―_(ツ)_/Β―

sick talon
#

so indexing wont work as well lemon_angrysad

shadow wraith
#

damn for loops and indexing won't work?

sick talon
#

i want to change it coz idk why but when i see the embed from mobile it looks like shit

#

this is how it looks from mobile

shadow wraith
#

it looks fine

sick talon
#

this is how it looks from PC

shadow wraith
#

is it possible to make multiple lists for when the user searches another repository?

#

and if so, indexing should work like that then 🚎

sick talon
shadow wraith
#

oh

#

you clear the list meaning it's a single list

#

πŸ’€

sick talon
shadow wraith
#

is it in a cog

sick talon
shadow wraith
#

hmm

#

you know how to retreive list data right?

sick talon
shadow wraith
#

or get the list data like how much strings are there (strings in this case = repo's searched)

shadow wraith
#

wait

#

automating the index would be hard and not a good idea

sick talon
slate swan
#

How to send mentioned user's avatar as an attachment

shadow wraith
#

store the amount of repo's the user has searched into an int, and then try indexing it using the var/class/instance/idk you just madw

shadow wraith
#

wait

#

your thing is seperate πŸ’€ l

orchid inlet
#

what is the guild name?

#

is that the name of your bot

sick talon
sick talon
orchid inlet
#

So fx it the guild name is Python

#

for the bots on this server

shadow wraith
#

guild = server

orchid inlet
#

okay ty

shadow wraith
#

bro it's not code to copy πŸ˜‚

sick talon
shadow wraith
#

i think that's what he means

sick talon
dusk dust
#

how can I check if the user who reacted to such a message is allowed to kick members?

sick talon
#

Β―_(ツ)_/Β―

shadow wraith
#

they don't have a choice

#

wait that just means nothing πŸ’€

dusk dust
shadow wraith
#

hey

#

does anyone know here how to subclass a help command

sick talon
dusk dust
sick talon
dusk dust
#

it wouldn't work in my case

shadow wraith
#

oh i thought everyone in your server was a member

slate swan
sick talon
sick talon
velvet tinsel
#

You can just use put it inside the for loop

#

What are you asking?

sick talon
slate swan
slate swan
velvet tinsel
#

What’s happening

dusk dust
# sick talon why ?

it is a command to report bugs... The bug report is sent to the moderation server where it is viewed. If this message has something illegal, the moderator has the option to kick this member reacting to 🚫

slate swan
velvet tinsel
#

What is happening? Does anyone need help?

sick talon
dusk dust
sick talon
sick talon
velvet tinsel
#

What’s the problem

sick talon
velvet tinsel
#

Just use wait_for()

#

I don’t know how to use the bot

sick talon
#

!d discord.Client.wait_for

unkempt canyonBOT
#

wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
velvet tinsel
#

Yes that

sick talon
dusk dust
velvet tinsel
#

Has_permissions()

dusk dust
velvet tinsel
velvet tinsel
#

if ctx.message.author.guild_permissions.administrator:

#

@dusk dust

dusk dust
#

ok

velvet tinsel
#

Ok

velvet tinsel
#

That’s that

#

What?

#

You expect me to code for you?

dusk dust
#

i need the bot to see the author of the REACTION and not the message

velvet tinsel
#

Ok

dusk dust
#

because the member who is the author of the message

velvet tinsel
#

I don’t think stack is down

sick talon
#

πŸ₯² its down over here

velvet tinsel
#

Damn

sick talon
velvet tinsel
#

But @dusk dust should be able to access it

velvet tinsel
#

That’s your answer

dusk dust
velvet tinsel
#

No problem

velvet tinsel
#

Ok

sick talon
velvet tinsel
#

What do you mean by field title

sick talon
velvet tinsel
#

embed.add_field(text=β€œtext”)

#

Ohh

orchid inlet
#

how do I make an basic respond command for my bot

velvet tinsel
#

That

#

I don’t have my pc with me tho

orchid inlet
#

fx one of the guild members says hello, it will send a hello

sick talon
velvet tinsel
#

On_message()

velvet tinsel
sick talon
velvet tinsel
#

But make a for loop

#

And then embed.add_field(text=β€œtext”)

sick talon
velvet tinsel
#

It’s just how it looks on your mobile

orchid inlet
#

like this on_message ("Hello Bozo")

velvet tinsel
orchid inlet
#

huh

slate swan
unkempt canyonBOT
#

discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") is created and sent.

This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/master/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/master/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
sick talon
slate swan
#

which is not defined by you

velvet tinsel
sick talon
velvet tinsel
#

Read the docs

slate swan
orchid inlet
#

oh

#

bruh, im blind

#

But this is for delete, I want it to respond

velvet tinsel
#

Starts_with

#

Or whatever it’s called

#

I only used it once

slate swan
#

Here's an example ```py
@client.event
async def on_message(message):
if message.author == client.user:
return

if message.content.startswith('$hello'):
    await message.channel.send('Hello!')
#

Quick Questions: Doespy with open('avatar.png', "wb+") as e:

wb+ method exist??

velvet tinsel
#

I don’t think so

slate swan
#

Can wb create a file if not exist

#

b is for binary files iirc

#

Yea

#

Ik I want to copy a user avatar data to avatar.png file

#

but file does not exist

orchid inlet
slate swan
#

You can just save it actually...

#

how how how??

#

.save()????

#

!d discord.Asset.save

unkempt canyonBOT
#

await save(fp, *, seek_begin=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Saves this asset into a file-like object.
slate swan
#

ooo

#

\πŸ‘

orchid inlet
#

@slate swan in the client.user command I need to type in the members right?

#

or something like that

slate swan
#
user.avatar_url.save("avatar.png")```??
#

Blank , you on 1.7.3?

#

yes

orchid inlet
slate swan
#

gimme a moment

sick talon
wheat heart
#

please help

slate swan
slate swan
unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

wheat heart
#

it write?

velvet tinsel
#

hello

slate swan
#

Yoir indentation is wrong

wheat heart
#

idk

slate swan
#

See the example how it should look like

velvet tinsel
#

yay let's go winrar

slate swan
orchid inlet
slate swan
#

Indentation is basic python though, might want to take a closer look at it

orchid inlet
#

but thanks!

slate swan
wheat heart
#

@slate swan

#

hoooow

slate swan
#

Still wrong

slate swan
orchid inlet
slate swan
slate swan
slate swan
# wheat heart

The if statement needs to be at the same indentation level as the response =

wheat heart
#

ok

orchid inlet
sick talon
slate swan
#

how do I send dm to multiple users using id?(i have 10) is it possible to use json for this?? like adding 10 user id in the file and then making the bot send them dm?

wheat heart
slate swan
# wheat heart
blah = "something"
if ....:
    if ....:
        do_something()
else:
    do_something_else()

Very basic python knowledge, you should take a closer look at how indentation works.

slate swan
#

And the entire code you showed probably doesn't match the indentation of the code above

wheat heart
sick talon
slate swan
# wheat heart

Search on the internet how indentation in python works, you will find good wikis to read and get more information about it, and what you should change.

lapis wyvern
#

help

#

File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Expected discord.Colour, int, or Embed.Empty but received method instead.

wheat heart
#

please heeelp

lapis wyvern
#

thats error

sick talon
slate swan
lapis wyvern
#

`@client.command()
async def helpers(ctx):
em = discord.Embed(title="The helpers",timestamp=ctx.message.created_at,description=f' Peopo and Sala',colour = discord.Colour.green)
em.add_field("Want to know the owners",value="Dm the owners")

await ctx.send(embed=em)
`

covert palm
#

I super confused

lapis wyvern
#

/discord/embeds.py", line 115, in init
self.colour = colour
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/embeds.py", line 230, in colour
raise TypeError('Expected discord.Colour, int, or Embed.Empty but received %s instead.' % value.class.name)
TypeError: Expected discord.Colour, int, or Embed.Empty but received method instead.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 63, in on_command_error
raise error
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Expected discord.Colour, int, or Embed.Empty but received method instead.

slate swan
#

!code please

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

orchid inlet
#

@client.event async def on_message(message): if message.content==("Hello") await msg.reply==("Hello Bozo")

covert palm
#

anyone can help with reaction to message to get roles?

orchid inlet
#

@slate swan like that?

slate swan
#

Without the second ==

lapis wyvern
#

help pls

wheat heart
#

@slate swan

covert palm
slate swan
#

And not msg but message

slate swan
unkempt canyonBOT
#

discord.on_raw_reaction_add(payload)```
Called when a message has a reaction added. Unlike [`on_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_reaction_add "discord.on_reaction_add"), this is called regardless of the state of the internal message cache.

This requires [`Intents.reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.reactions "discord.Intents.reactions") to be enabled.
slate swan
wheat heart
slate swan
#

!d discord.Member.add_roles

unkempt canyonBOT
#

await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
lapis wyvern
#

@client.command()
async def helpers(ctx):
em = discord.Embed(title="The helpers",timestamp=ctx.message.created_at,description=f' Peopo and Sala',colour = discord.Colour.green)
em.add_field("Want to know the owners",value="Dm the owners")

await ctx.send(embed=em)

slate swan
# wheat heart

And as I said, go on the internet and R E A D about python indentation

lapis wyvern
#

/discord/embeds.py", line 115, in init
self.colour = colour
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/embeds.py", line 230, in colour
raise TypeError('Expected discord.Colour, int, or Embed.Empty but received %s instead.' % value.class.name)
TypeError: Expected discord.Colour, int, or Embed.Empty but received method instead.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(args, **kwargs)
File "main.py", line 63, in on_command_error
raise error
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Expected discord.Colour, int, or Embed.Empty but received method instead.

orchid inlet
wheat heart
#

please link

covert palm
slate swan
# wheat heart please link

I'm sure you can search on your own, it's not that hard to use Google and search for "Python indentation"

lapis wyvern
#

help plsssssssssssss

sick talon
# slate swan Yw

pithink ok can you also help me with this

i have the desp of the field in a list as well how to do it ?

lapis wyvern
#

help ples

slate swan
slate swan
slate swan
orchid inlet
dapper cobalt
unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

slate swan
slate swan
orchid inlet
#

@client.event async def on_message(message): if message.content=("Hello") await message.reply=("Hello")

dapper cobalt
lapis wyvern
#

help omg help pls

orchid inlet
velvet tinsel
#

how do you get user input in discord.py again? I forgor πŸ’€

slate swan
orchid inlet
slate swan
lapis wyvern
#

you didnt even give help

#

didnt see that

velvet tinsel
#
if (thing)
  indent
sick talon
slate swan
boreal ravine
dapper cobalt
slate swan
slate swan
velvet tinsel
lapis wyvern
#

now I get this error

#

File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 63, in on_command_error
raise error
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: add_field() takes 1 positional argument but 2 positional arguments (and 1 keyword-only argument) were given

velvet tinsel
orchid inlet
velvet tinsel
#

and show us the code

slate swan
slate swan
#

Add name=

boreal ravine
lapis wyvern
#

`@client.command()
async def helpers(ctx):
em = discord.Embed(title="The helpers",timestamp=ctx.message.created_at,description=f' Peopo and Sala',colour = discord.Colour.green())
em.add_field("Want to know the owners",value="Dm the owners")

await ctx.send(embed=em)`

slate swan
#

wait_for

velvet tinsel
#

I searched far and wide and yet yielded no results

orchid inlet
#

@client.event async def on_message(message): if message.content==("Hello") await message.reply("Hello")

orchid inlet
#

@slate swan still doesnt work

slate swan
#
@bot.command()
async def msg(ctx):
    user = await bot.fetch_user(793206762101669948)
    wala = "congratulations you have won 100k DMC giveaway from dank pepe server"
    await user.send(f"{wala}")

can anyone tell me how do I send this to multiple users?

#

Remove the () on "Hello"

velvet tinsel
slate swan
lapis wyvern
#

???????????

slate swan
#

like is it possible to add
bot.fetch_users(ID,ID)?

velvet tinsel
slate swan
slate swan
orchid inlet
#

npnp

slate swan
#

Is it the same for you?

slate swan
#

get some idea from this , I'm in a class brb

slate swan
lapis wyvern
#

ohhhhhh

velvet tinsel
#

how do you prompt for user input in discord.py to get any result? For example, asking for anything?

velvet tinsel
lapis wyvern
#

thanks

orchid inlet
slate swan
#

And wait for a message

orchid inlet
#

@client.event async def on_message(message): if message.content==("Hello") await message.reply("Hello")

velvet tinsel
orchid inlet
#

haha

lapis wyvern
#

works lol

orchid inlet
lapis wyvern
#

himm ima add footer text

slate swan
# velvet tinsel how do you prompt for user input in discord.py to get any result? For example, a...
@client.event
async def on_message(message):
    if message.content.startswith('$greet'):
        channel = message.channel
        await channel.send('Say hello!')

        def check(m):
            return m.content == 'hello' and m.channel == channel

        msg = await client.wait_for('message', check=check)
        await channel.send('Hello {.author}!'.format(msg))

Example from the docs: https://discordpy.readthedocs.io/en/latest/ext/commands/api.html?highlight=wait_for#discord.ext.commands.Bot.wait_for

velvet tinsel
slate swan
#

Then remove the check what

velvet tinsel
slate swan
#

Change from

return m.content == 'hello' and m.channel == channel

to

return m.channel == channel
#

Β―_(ツ)_/Β―

velvet tinsel
#

Oh, I was thinking about that. Thank you.

orchid inlet
#

Β΄helloΒ΄

slate swan
# velvet tinsel no, it gets their id

like dis?

@bot.command()
async def msg(ctx):
    user = await ctx.author.id(793206762101669948,496569071106523148)
    wala = "Test"
    await user.send(f"{wala}")
velvet tinsel
orchid inlet
#

I already use those

velvet tinsel
#

Uhhh...no

slate swan
#

Not correctly though

#

!code This is how to use them

orchid inlet
#

hello

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

slate swan
#

This is just one

orchid inlet
#

hello

slate swan
#

You need three of them

velvet tinsel
orchid inlet
#

three backticks in the front of the text and in the back?

boreal ravine
#

yes

slate swan
orchid inlet
#

hello

#

oooooh

slate swan
#

It literally shows an example on how it works..

orchid inlet
slate swan
#

It's an example from the docs

orchid inlet
#

ah okay

slate swan
#

It's meant to simulate a command

#

With prefix $

slate swan
#

thats why need help

#

Use get_user(id) or fetch_user(id)

lapis wyvern
#

help

slate swan
#

import it

boreal ravine
slate swan
#

And it's datetime

lapis wyvern
#

await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'datatime' is not defined

slate swan
#

We can see

lapis wyvern
slate swan
#

Can you stop?

thick sigil
#

Why is this guy spamming

slate swan
#

<@&831776746206265384> Could you please explain to @lapis wyvern that spamming won't give him more help, it's not the first time either.

thick sigil
#

Thats your problem, you dont even read when they gave you the answer, stop rushing your code and you will make less errors

boreal ravine
# lapis wyvern

Just do datetime.utcnow(), you've already imported datetime which is a class from the datetime module

slate swan
slate swan
#

thanks

lapis wyvern
#

on other brackets

#

did that

slate swan
#

You still haven't changed it to datetime as I already said before

lapis wyvern
#

?

#

let me scroll back

slate swan
#

It's not datatime it's datetime

slate swan
#

But since you spam your errors and images you don't see it shrug

boreal ravine
#

lmao

lapis wyvern
#

uh yeah ok

velvet tinsel
#
msg = await client.wait_for("message", check=check2, timeout=30)
                        member = msg.content
                        await member.send("test")

how do you get a member from user input lemon_long dumb af

slate swan
#

msg.author

velvet tinsel
#

oke

lapis wyvern
#

btw do you guys have some docs or something

slate swan
lapis wyvern
#

for watching listening and playing a game status

velvet tinsel
slate swan
#

Because you're the one who answered xD

slate swan
unkempt canyonBOT
#

class discord.Status```
Specifies a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") β€˜s status.
slate swan
#
@Blank.command(aliases=["avatar", "pfp"])
async def av(ctx, user:discord.Member=None):
    await ctx.message.delete()
    if user is None:
        user=ctx.author
    if not user.avatar:
        await ctx.channel.send("User does not has any avatar")
    else:
        if user.is_avatar_animated():
            user.avatar_url.save("avatar.gif")
            try:
                await ctx.channel.send(file=discord.File('avatar.gif'))
            except Exception:
                await ctx.channel.send(user.avatar_url)
            os.remove('avatar.gif')
        else:
            user.avatar_url_as("png").save("avatar.png")
            try:
                await ctx.channel.send(file=discord.File('avatar.png'))
            except Exception:
                await ctx.channel.send()
            os.remove('avatar.png')```

avatar_url_as() takes 1 arguement but 2 were given
#

!d discord.Activity

unkempt canyonBOT
#

class discord.Activity(**kwargs)```
Represents an activity in Discord.

This could be an activity such as streaming, playing, listening or watching.

For memory optimisation purposes, some activities are offered in slimmed down versions:

β€’ [`Game`](https://discordpy.readthedocs.io/en/master/api.html#discord.Game "discord.Game")

β€’ [`Streaming`](https://discordpy.readthedocs.io/en/master/api.html#discord.Streaming "discord.Streaming")
velvet tinsel
#

Yes but if I send something like Bob I want it to DM Bob pls

lapis wyvern
#

weird cant find watching

#

let me look into more

slate swan
velvet tinsel
slate swan
lapis wyvern
#

wait I Have a status cycle

#

so how do I do it

velvet tinsel
#

How do you message the user mentioned

lapis wyvern
#

nvm

#

right in my face the whole time

slate swan
#

Just get the element at index 0 if you only mention one user

lapis wyvern
#

ok nvm

#

I get a error

#

Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/init.py", line 101, in _loop
await self.coro(*args, **kwargs)
File "main.py", line 408, in change_status
await client.change_presence(activity=discord.Watching(next(status)))
AttributeError: module 'discord' has no attribute 'Watching'

#

how can I fix this

slate swan
#
# Setting `Playing ` status
await bot.change_presence(activity=discord.Game(name="a game"))

# Setting `Streaming ` status
await bot.change_presence(activity=discord.Streaming(name="My Stream", url=my_twitch_url))

# Setting `Listening ` status
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="a song"))

# Setting `Watching ` status
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="a movie"))

Source: https://stackoverflow.com/questions/59126137/how-to-change-discord-py-bot-activity

slate swan
lapis wyvern
#

so I have to change it

slate swan
#

If your code doesn't work, what do you think you should do?

lapis wyvern
#

hover my cursor onto the error?

slate swan
lapis wyvern
#

ok but

#

ok

orchid inlet
#
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('Hello'):
        await message.channel.send('Hello')```
#

I ahve now tried this, and it still doesnt work

#

and the bot is online on the server

lapis wyvern
#

UHHH

slate swan
#

Please hide your token...

lapis wyvern
#

Oh its fine

#

let me renew

orchid inlet
#

@slate swan can you help?

slate swan
#

And you haven't updated the code

orchid inlet
#

are you talking to me?

slate swan
#

Nope

lapis wyvern
#

what do you mean

orchid inlet
#

okay

slate swan
#

Goodmorning guys

#

Not the same

orchid inlet
#

Goodmorning

slate swan
#

You haven't restarted your bot

orchid inlet
#

@slate swan you seem like a guy that can help me

lapis wyvern
#

here true error

slate swan
#

My name says otherwise lmao

lapis wyvern
#

File "main.py", line 409
(activity=discord.Activity(type=discord.ActivityType.Watching, name="a movie"))
^
SyntaxError: invalid syntax
ξΊ§

slate swan
#
@Blank.command(aliases=["avatar", "pfp"])
async def av(ctx, user:discord.Member=None):
    await ctx.message.delete()
    if user is None:
        user=ctx.author
    if not user.avatar:
        await ctx.channel.send("User does not has any avatar")
    else:
        if user.is_avatar_animated():
            await user.avatar_url.save("avatar.gif")
            try:
                await ctx.channel.send(file=discord.File('avatar.gif'))
            except Exception:
                await ctx.channel.send(user.avatar_url)
            os.remove('avatar.gif')
        else:
            await user.avatar_url_as(format="png").save("avatar.png")
            try:
                await ctx.channel.send(file=discord.File('avatar.png'))
            except Exception:
                await ctx.channel.send(user.avatar_url_as(format="png"))
            os.remove('avatar.png')```

Help, this is only sending url 😒
orchid inlet
slate swan
orchid inlet
#

this doesnt work

slate swan
#

As the example says

lapis wyvern
#

oh so remove