#discord-bots

1 messages · Page 499 of 1

fallow mauve
#

but thats the command

final iron
#

@fallow mauve

bot.cooldown(1, 1, commands.BucketType)

fallow mauve
#

where in the code do i put that

final iron
#

That's an example

#

Don't copy and paste

#

Look at the documentation yourself

fallow mauve
#

i dont copy/paste

#

but i also dont get where that fits into the code

final iron
#

Under the command decorator

fallow mauve
#

decorator, pretend i dont know what that means

#

sry if im a pain to deal w, i just started using python

final iron
#

My keyboard just broke

#

Give me a sec

fallow mauve
#

oof

#

my mouse is half-broken

#

cant scroll well at all

final iron
#

bot.command()

#

Under that

fallow mauve
#

so if this is the command then...

#

what line is the decorator

final iron
#

Above it

#

Send the code

#

I'll tell you

cosmic crystal
#

has there been any news about discord.py since the author said he's stepping down?

fallow mauve
# final iron Send the code

if message.content.startswith('<ping'):
await message.channel.send('pong')
if message.author == client.user:
return

final iron
#

No the full code

fallow mauve
final iron
#

aaaaa

fallow mauve
#

?

final iron
#

I'm guessing you're following a tutorial?

fallow mauve
#

i was in the beginning, ive torn that apart and redid things

#

*redone

final iron
#

I would really suggest against what you're doing

fallow mauve
#

but the basis of the code is what i learned from a tutorial

fallow mauve
final iron
fallow mauve
#

ok...

final iron
#

You should start from scratch and find a good tutorial

fallow mauve
#

-_-

final iron
#

Sorry about that

#

But this is really bad practice

fallow mauve
#

its fine

#

its not you its my friend

#

he sent me the tutorial and said to follow it

final iron
#

Find a different one

#

And make sure it's up to date

fallow mauve
# final iron And make sure it's up to date

i was following this one, uploaded in 2020:
https://youtu.be/SPTfmiYiuok

Learn how to code a Discord bot using Python and host it for free in the cloud using Repl.it.
🚨Note: At 16:43, Replit now has a new method for environment variables. Check the docs: https://docs.replit.com/programming-ide/storing-sensitive-information-environment-variables

Along the way, you will learn to use Repl.it's built-in database and cr...

▶ Play video
final iron
# fallow mauve i was following this one, uploaded in 2020: https://youtu.be/SPTfmiYiuok

In this video, we go over how to setup a discord bot in python using discord.py v1.0.1 (rewrite).

If you have any suggestions for future videos, leave it in the comments below.

GITHUB: https://github.com/Rapptz/discord.py
DOCUMENTATION: https://discordpy.readthedocs.io/en/latest/

OFFICIAL DISCORD.PY SERVER: https://discord.gg/r3sSKJJ
JOIN MY ...

▶ Play video
#

Follow this series

fallow mauve
#

ok

#

i dont need to know anything except coding it, i have everything else set up

final iron
#

Its a 14 part series

#

Find the other parts

fallow mauve
#

ok

final iron
#

I wouldn't suggest following this for long though

fallow mauve
#

thats long

#

ok, why?

final iron
#

You want to be able to code yourself

fallow mauve
#

true, i cant by copy/pasting tutorials the whole time

final iron
#

Yup

#

It is easier to start out with a tutorial though

fallow mauve
#

mhm

#

whats wrong with this?

#

it says theres a syntax error

wicked atlas
#

Those need to be two seperate lines

fallow mauve
#

what needs to be?

#

what goes in the first line and what goes in the second?

wicked atlas
#

I’m on my phone right now, so cant really type anything out thats really good, but take a look at the code in the tutorial you said you were following

fallow mauve
#

nvm

#

i figured it out

slate swan
#

why is there an error

full lily
#

indentation

slate swan
#

?

full lily
#

!indent

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
#

how do i fix it

full lily
#

unindent line 2

slate swan
#

how?

full lily
flat solstice
#

This seems like a really silly thing to be stuck on but i've been puzzling over this error for a few weeks now (i forgot about it till i tried the command today)py await ctx.reply(f"I am in {str(guilds)} servers! Their names are: ".join(self.bot.guilds)) TypeError: sequence item 0: expected str instance, Guild foundwhich is caused by these commands, i'm trying to get it to show a list of the names of each guild the bot is in```py
@commands.command(description = "See how many servers I'm in.", usage = "servers")
async def servers(self, ctx):
guilds = sum(await self.bot.comm.handler("guild_count", self.bot.cluster_count))
await ctx.reply(f"I am in {str(guilds)} servers! Their names are: ".join(self.bot.guilds))

@cog_ext.cog_slash(name = "servers", guild_ids = [448405740797952010])
async def _servers(self, ctx: SlashContext):
    guilds = sum(await self.bot.comm.handler("guild_count", self.bot.cluster_count))
    await ctx.reply(f"I am in {str(guilds)} servers! Their names are: ".join(self.bot.guilds))```
slate swan
#

this goes on then off (no errors) how do i fix

flat solstice
#

!codeblock

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.

full lily
full lily
#

You should be getting errors

wicked atlas
slate swan
full lily
#

not have a return outside of a function

slate swan
#

ok

#

this gud?

slate phoenix
#

there is still a ton of errors in your code

hasty iron
#

!indents

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

final iron
#

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

slate swan
slate phoenix
# slate swan what errors?

for one your on_message doesnt have an event decorator, it also doesnt have proper indentation for the code under it and wont work, you're also using the parameter self but its not a cog so it doesnt need it and wont even work

bold dawn
#

import yaml
from munch import Munch

config_file_path = os.path.join(
    os.path.dirname(__file__), os.path.pardir, 'config.yml')

config = None


def load_config():
    with open(config_file_path) as config_file:
        _config = yaml.safe_load(config_file)
        globals()['config'] = Munch.fromDict(_config)


load_config()```


Is there a better way of doing this
hasty iron
#

yes, a class

bold dawn
#

Thank you

misty stream
#

please help

@slash.slash(name='clear', description="the bot will remove the set amount of messages (max 100)", guild_ids=[SERVERS])
async def clear(ctx:SlashContext, amounttoclear):
    if amounttoclear == 0:
       await ctx.channel.purge(limit= 100)
       await ctx.send("removed 100 messages")
    else:
       await ctx.channel.purge(limit= amounttoclear)
       await ctx.send(f"removed {amount} messages")
#

this code returns this error :

#

```An exception has occurred while executing command clear:
Traceback (most recent call last):
File "C:\Users\Robin310\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_slash\client.py", line 1352, in invoke_command
await func.invoke(ctx, **args)
File "C:\Users\Robin310\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_slash\model.py", line 210, in invoke
return await self.func(*args, **kwargs)
File "C:\Users\Robin310\Desktop\Shoutout Network\SOHelper\bot.py", line 708, in clear
await ctx.channel.purge(limit= amounttoclear)
File "C:\Users\Robin310\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\channel.py", line 377, in purge
msg = await iterator.next()
File "C:\Users\Robin310\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\iterators.py", line 285, in next
await self.fill_messages()
File "C:\Users\Robin310\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\iterators.py", line 327, in fill_messages
if self._get_retrieve():
File "C:\Users\Robin310\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\iterators.py", line 294, in _get_retrieve
if l is None or l > 100:
TypeError: '>' not supported between instances of 'str' and 'int'

#

how do i fix this ?

high flame
#

code blocks--

misty stream
#

oh sorry

hasty iron
#

thats not a code block

misty stream
#

better

high flame
#

the error says you can't compare string and int

#

you use > operator pithink

hasty iron
#

limit takes an int and you’re passing in a string

misty stream
#

oh

#

how would i send a int

#

cause i type a int

#

/clear 100

high flame
#

or wait forget what i told

hasty iron
#

cast it to an int

misty stream
#

int(amount) like that ?

hasty iron
#

yes

high flame
#

yeah

misty stream
#

it says invalid syntax

hasty iron
#

yeah it does

misty stream
#

so its not correct it seems

hasty iron
#

because you’re not doing it correctly

misty stream
#

oh

#

what is the correct way

#

sorry still a noob

high flame
#

not in parameters

#

you can do amounttoclear: int

hasty iron
#

if your lib allows it

high flame
#

mm

misty stream
#

ill check

high flame
#

or do int(amouttoclear) when passing it to limit kwarg

misty stream
#

yep my library allows it Xd

hasty iron
#

surprising

slate swan
#

you joke?

high flame
fallow mauve
#

no i actually didnt see the typo lol

#

idk how i missed it

hasty iron
#

it isnt a typo though

#

its "not having enough python knowledge"

high flame
#

you shouldn't start with discord.py without python knowledge

fallow mauve
#

i knew that it was wrong

hasty iron
#

oh you knew

fallow mauve
#

mhm

hasty iron
#

sure

fallow mauve
#

i just didnt see it

misty stream
#

if you guy could help with 1 more issue

async def updateLoop():
    print(f"\n", end='')
    print(f"\nStarting update loop...", end='')

    await bot.wait_until_ready()
    channel = bot.get_channel(STREAMER_CHANNEL)

    while(True):
        today = datetime.datetime.today()
        weekday = today.weekday()
        now = datetime.datetime.now()
        value = MATRIX[TIMES.index(f"{now.hour}:00")+1][weekday+1]

        if (value != "" and value != None):
            await channel.purge()
            sleep(1)
            await channel.send(f"{value} is now live!\nhttps://www.twitch.tv/{value}")
            MATRIX[TIMES.index(f"{now.hour}:00")+1][weekday+1] = ""
            writeToFile()
            await updateImage()
            updatestreamerweb()
        else:
              print("randomfeature")
        future = datetime.datetime(today.year, today.month, today.day, today.hour, 0)

        await asyncio.sleep( (future-today).total_seconds() )

this will spam randomfeature
when value is empty
but instead of it spamming randomfeature i want it to execute it only once if the function is called

high flame
#

the redlines show the error

kindred epoch
#

how do i make an exp system?

fallow mauve
high flame
#

bruh then why you sent it and you didn't see it

#

meh im leaving the chat.

fallow mauve
misty stream
#

i have this error

An exception has occurred while executing command `slot`:
Traceback (most recent call last):
  File "C:\Users\Robin310\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_slash\client.py", line 1352, in invoke_command
    await func.invoke(ctx, **args)
  File "C:\Users\Robin310\AppData\Local\Programs\Python\Python39\lib\site-packages\discord_slash\model.py", line 210, in invoke
    return await self.func(*args, **kwargs)
  File "C:\Users\Robin310\Desktop\Shoutout Network\SOHelper\bot.py", line 276, in slot
    if (MATRIX[TIMES.index(time)+1][DAYS.index(day)+1]) == "":
ValueError: 'u' is not in list  

how do i fix this ?

#
@slash.slash(name='slot', description="lets users create their own stream slots", guild_ids=[SERVERS])
async def slot(ctx:SlashContext, args):
    global schedule
    if schedule:
        if (len(args) == 0) or (len(args) == 1):
            await ctx.send("Please specify the time and day!")
        else:
            time = args[1]
            day = args[0].lower()
            if (time == "GMT" or day == "GMT"):
                await ctx.send("Do not include \'GMT\'!")
                return

            if (MATRIX[TIMES.index(time)+1][DAYS.index(day)+1]) == "":
                MATRIX[TIMES.index(time)+1][DAYS.index(day)+1] = userName(ctx.message.author)

                writeToFile()

                await updateImage()
                await ctx.send(f"Successfully confirmed slot at {time} on {day}.")
                sleep(5)
                await ctx.channel.purge(limit=2)

            else:
                await ctx.send("That slot is already taken!")
    else:
        await ctx.send("schedule is disabled enable it first")

this is the code

#

the command i do is /slot sunday 18:00

final iron
kindred epoch
#

i do

#

i need a level algorithm

brazen seal
#

how i can do help command with editing message after add reaction ?

kindred epoch
unkempt canyonBOT
#

await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the message.

The content must be able to be transformed into a string via `str(content)`.

Changed in version 1.3: The `suppress` keyword-only parameter was added.
kindred epoch
#

use that when they click on a reaction on the message

final iron
brazen seal
kindred epoch
brazen seal
#

when user click reaction

final iron
kindred epoch
#

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

You would have to reverse engineer it

kindred epoch
#

@brazen seal it has a example of reaction

#

nah

#

im not down for that

final iron
#

You would have to start from scratch then

#

I doubt you could find something online

kindred epoch
#

i just need a level algorithm

fallow mauve
patent lark
brazen seal
fallow mauve
patent lark
fallow mauve
#

i dont understand how that works yet :/

patent lark
#

one second.

#

i recommend you check this out

fallow mauve
#

ok

final iron
#

There really is no difference between calling your bot object bot and client

patent lark
#

incorrect.

final iron
#

If you're starting out you should name it bot

final iron
#

It's the same object just a different name

patent lark
#

a variable name is this case wont change a thing in how your code is ran, but, like said, since discord.Client() is a thing we should use bot for the bot object, its better when it comes to the aspect of practice.

final iron
#

Yeah ik

#

But in what situation would you use discord.Client()

#

Imo if you're starting out call it bot but if you have a lot of existing code don't bother

slate swan
#

Guys I have a really weird problem.

My on_reaction_add event only works after I initate a command. When i start the code for the bot.

@client.listen("on_reaction_add")
async def open_ticket(reaction, user):
    await reaction.message.channel.send("Reaction Function")
    message = reaction.message```
#

It gives me no errors whatsoever when this happens

patent lark
#

yeah, its not worth changing if you've named in client in the past, its just better practice-wise, and im very "picky" when it comes to things like that.

final iron
#

Yeah I can respect that

#

That's my opinion also

slate swan
#

I literally made a "startup" command so that this reaction event works

#

i have 0 clue how to fix this

#

anyone got any tips or anyway to help me out here with this weird problem?

covert igloo
#

hey im trying to edit a voice channel name

#

how woul di go about doing so

final iron
#

So you can get the name of the voice channel you want to edit

#

Then you would get the voice channel and change it

fallow mauve
#

is there a way ot make it so the bot repeats whatever you say, like if i wanted to add a command like <say _____, and it would say whatever was in the blank, how would i do that?

final iron
#

In the args you would put something like *, user_message

#

Then like ctx.send(user_message)

#

Again don't copy and paste

#

Take what I say as an example

#

And learn for yourself

pliant gulch
#

!d discord.Client.get_channel

unkempt canyonBOT
pliant gulch
#

!d discord.VoiceChannel.edit

unkempt canyonBOT
#

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

Edits the channel.

You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.

Changed in version 1.3: The `overwrites` keyword-only parameter was added.

Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
acoustic ermine
#

Is it possible to check if the invite to a server is the ctx.guild

crude crater
#

rephrase that please?

lyric moat
#

how i get the role id from one of these?

    await guild.create_role(name=name)
crude crater
#

id=id

#

?

lyric moat
fallow mauve
#

how do i get the bot to react with an emoji to the command?

kindred epoch
unkempt canyonBOT
#

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

Add a reaction to the message.

The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").

You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
kindred epoch
#

Use that

fallow mauve
#

thx

slate swan
#

Anyone knows how to make a bot grab a channel using its ID and then grabbing a message in that channel using the ID of the message?

To describe what I mean i made an example code that is not valid but can be understanded what the endgoal is below..

channel = await client.fetch_channel(channelID)
message = await channel.fetch_message(messageID)

or something?

native sail
fallow mauve
lyric moat
fallow mauve
#

how do i put a emoji in the code?

lyric moat
#

await add_reaction(🐥 )

#

try that

fallow mauve
#

but i cant put an emoji in the code

lyric moat
#

await add_reaction(🤣)

#

try that

fallow mauve
#

ok

#

thx

lyric moat
#

np

fallow mauve
fallow mauve
lyric moat
#

the red dot is close to the thingy

fallow mauve
#

to what thingy?

lyric moat
#

await message.add.reaction ( 🟥 )

#

try that

fallow mauve
reef shell
lyric moat
reef shell
fallow mauve
reef shell
#

Not add.reaction

fallow mauve
#

works now

reef shell
#

!d discord.Message.add_reaction

unkempt canyonBOT
#

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

Add a reaction to the message.

The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").

You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
fallow mauve
#

thx

lyric moat
#

how do i get role id? with

        await guild.create_role(name=role) 
reef shell
#

Guild.create_role() method returns the newly created role object

#

Then you can access the role id

fallow mauve
#

gtg for today bye

reef shell
#

role_obj.id

#

!d discord.Guild.create_role

unkempt canyonBOT
#

await create_role(*, name=..., permissions=..., color=..., colour=..., hoist=..., mentionable=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Creates a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") for the guild.

All fields are optional.

You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to do this.

Changed in version 1.6: Can now pass `int` to `colour` keyword-only parameter.
final kettle
#

kool

#

bruh

final kettle
#

how would I go about setting multiple values to one field? or is that even possible?

reef shell
#

Are you talking about embeds?

final kettle
#

yea

reef shell
#

wdym mean by multiple values?

#

Lines?

final kettle
#

want something like this but i want multiple values on every day...

reef shell
#

Yes you can

final kettle
#

how?

#

this is what i got rn

#
@client.command()
async def Coaching(ctx):
    embed=discord.Embed(
        title='Available Dates',
        description='',
        color=discord.Color.blue())

    embed.add_field(name='Monday', value=m1, inline=False)
    embed.add_field(name='Tuesday', value=m2, inline=False)
    embed.add_field(name='Wednesday', value=m3, inline=False)
    embed.add_field(name='Thursday', value=m4, inline=False)
    embed.add_field(name='Friday', value=m5, inline=False)


    embed.set_footer(text='Discord: Joshua1N#1103 | Email: Joshua.Nelson2005@gmail.com')

    await ctx.send(embed=embed)
reef shell
#

what are the m1, m2....s?

#

String?

final kettle
#

yea.

#

if they do a command to fill those dates, they will be removed from embed msg

reef shell
#

You can have multiple lines

#

In one field

#

And also check this

misty quail
#

anyone know this?
TypeError: expected str, bytes or os.PathLike object, not dict

#

code is

reef shell
#

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

misty quail
#

hmm...

#

anyone know this?

final kettle
#

ok ive got my format correct, just not sure how to add a second value

slate swan
#

Anyone knows how to make a bot grab a channel using its ID and then grabbing a message in that channel using the ID of the message?

To describe what I mean i made an example code that is not valid but can be understanded what the endgoal is below..

channel = await client.fetch_channel(channelID)
message = await channel.fetch_message(messageID)

or something?

reef shell
final kettle
#

but that would still be 1 value

reef shell
#

You can't have multiple value keywords in 1 field

final kettle
#

ok

reef shell
#

Let me check

slate swan
reef shell
slate swan
#

rip

misty quail
#

anyone know TypeError: expected str, bytes or os.PathLike object, not dict
this Error?

reef shell
#

I'm wrong

slate swan
#

interesting

#

wait so i actually did the code right?

#

without even realizing? 🤣

#

discord.Client.fetch_channel

#

!d discord.Client.fetch_channel

unkempt canyonBOT
#

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

Retrieves a [`abc.GuildChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel "discord.abc.GuildChannel"), [`abc.PrivateChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.PrivateChannel "discord.abc.PrivateChannel"), or [`Thread`](https://discordpy.readthedocs.io/en/master/api.html#discord.Thread "discord.Thread") with the specified ID.

Note

This method is an API call. For general usage, consider [`get_channel()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client.get_channel "discord.Client.get_channel") instead.

New in version 1.2.
slate swan
#

LMAOOOOOO wow

misty quail
#

!d await ctx.message.author.voice.channel.connect()

final iron
#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

misty quail
#

ahh sorry

lyric moat
#

how i make a server owner only command?

#
@commands.check(is_server_owner)
#

does not work

reef shell
#

you need to define the check manually

final kettle
#

how do i edit a value in embed msg?

#

ive got the certain field set to a variable but i dont see any type of edit keyword

slate swan
lyric moat
reef shell
slate swan
reef shell
#

So you can technically edit the embed

slate swan
#

mbmb

lyric moat
slate swan
#

Pretty sure it should be
ctx.guild.owner

#

if that's what ur looking for

lyric moat
#

but how tho

slate swan
#

wdym

lyric moat
#

like how i set it up

slate swan
#

oh

slate swan
#

U put it in an if statement

reef shell
#

Bruh

slate swan
#

That's what i do..

#

example
ctx.author == ctx.guild.owner

#

it works for me

reef shell
#

You can add check

#

Decorator

#

like other checks

slate swan
#

ohh u talking about @client.check?

slate swan
#

u could just answer my question but whatever

reef shell
#

Docs answer more precisely

lyric moat
#

its not telling me how i get guild owner only command

slate swan
lyric moat
#

so is it

@commands.check.(is_guild_owner())
#
@command.is_guild_owner()```
slate swan
#

@reef shell yeah but the thing is check() is a global thing

lyric moat
slate swan
#

So it would check for the guild owner on every command used

lyric moat
#

is it

@command.is_guild_owner()
slate swan
#

well corrrection, sherlock did

#

I dont do it that way cuz i like everything to be specific

#

But whatever works i guess.

reef shell
# lyric moat its not telling me how i get guild owner only command
def owner_or_permissions(**perms):
    original = commands.has_permissions(**perms).predicate
    async def extended_check(ctx):
        if ctx.guild is None:
            return False
        return ctx.guild.owner_id == ctx.author.id or await original(ctx)
    return commands.check(extended_check)

Then add this deco. on top of your cmd func.
@commands.check(owner_or_permissions)

slate swan
reef shell
slate swan
#

or whatever ur bot decorator is

#

wait huh, what's commands.check?

#

shouldnt it be the bot decorator or am i smoking?

lyric moat
#
@commands.check_is_guild_owner()
reef shell
#

Did you read the docs?

slate swan
reef shell
#

Yes

lyric moat
reef shell
#

There is an example

slate swan
#

y e s i n d e e d

#

that's why i asked him the question

#

about the "@commands.check"

reef shell
#

Oh lol

slate swan
#

see i knew it B)

lyric moat
#

what is B)

slate swan
lyric moat
#

Bitch?

reef shell
#

Nothing, just using char. instead of emojisthinkmon

slate swan
#

bruh...

reef shell
#

LMAAOOO

slate swan
#

dis man

#

@lyric moat yk u can curse in this server right?

#

u dont have to try and bypass

lyric moat
#

oh

slate swan
#

lmao

#

im gonna say the hard r to prove it

#

jkjk

#

Anyways, @lyric moat follow the exmaple above

#

which was in the doc if u didnt read it already

lyric moat
#

lol

slate swan
#

Oh guys i have a problem myself

#
@client.listen("on_reaction_add")
async def open_ticket(reaction, user):```

My on_reaction_add event only activates to messages reacted to AFTER the bot has started. So meaning messages if messages befoire is online are reacted to this function is renderred useless. 

How do i fix that?
#

This is espiaclly aannoying for what im trying to make here

#

like if my bot restarts the whole function doesnt work so i gotta recreate the support ticket embed for the reactions to work again

#

im pretty sure its @client.event

slate swan
#

its similar to client.event

#

it allows to still use commands and other stuff

#

only difference is the event name goes in the decorator not the async def

#

otherwise same thing

#

i dont remember this in the docs

slate swan
#

well yes

fallow horizon
#

So, I'm trying to teach my friend how to make a discord bot and he's getting this error I've never seen

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'int' object is not subscriptable```
#

the code

@bot.command()
async def level(ctx):
    id = random.randint(128,73000000)
    level = requests.get(f'https://gdbrowser.com/api/level/{id}')
    result = level.json()
    if level.json == -1:
        return
    embed = discord.Embed(title=f"{result['id']}", color=0x00ffff)

    embed.add_field(name=result['name'], value=result["author"], inline=False)
    embed.add_field(name="Field2", value="hi2", inline=False)

    await ctx.send(embed=embed)
    await ctx.send(f"{result['id']}")
#

I'm trying to convert an int to a string(I've tried str() btw I'm not dumb) and It just shows this

slate swan
#

actually nvm

#

oh i think i figured it out

reef shell
#

int

#

As the error says

slate swan
#

await ctx.send(f"{result['id']}")

#

ur trying to grab a value of of something that does not

#

You dont even need the ['id'] part since its only 1 value in the variable

#

to turn it into a string you can use str() str(result), but the whole variable is already a string so that's useless

#

But i dont know what your level = requests.get() returns to you, so I could be wrong. I'd need more information there

#

You can check this doing print(results) if you want to

#

@fallow horizon does this help?

fallow horizon
fallow horizon
#

what?

slate swan
#

the error ofcourse

fallow horizon
#

line 8 of what I sent

#

hello?

slate swan
fallow horizon
#

yeah sure

slate swan
#

by print(result)

#

hm

fallow horizon
#

ummmm the values are from a rest api so we won't get the exact data

#

but it will be close

slate swan
#

send whatever you get by doing it

fallow horizon
#

yep

#
{
"name": "inpozivle papuh",
"id": "27351286",
"description": "(No description provided)",
"author": "axelciclol10",
"playerID": "19974889",
"accountID": "5818640",
"difficulty": "Insane",
"downloads": 150,
"likes": 22,
"disliked": false,
"length": "Tiny",
"stars": 0,
"orbs": 0,
"diamonds": 0,
"featured": false,
"epic": false,
"gameVersion": "2.0",
"editorTime": 0,
"totalEditorTime": 0,
"version": 1,
"copiedID": "0",
"twoPlayer": false,
"officialSong": 0,
"customSong": 593661,
"coins": 3,
"verifiedCoins": false,
"starsRequested": 10,
"ldm": false,
"objects": 0,
"large": false,
"cp": 0,
"difficultyFace": "insane",
"songName": "Xtrullor - Supernova",
"songAuthor": "Xtrullor",
"songSize": "11.89MB",
"songID": 593661,
"songLink": "http://audio.ngfiles.com/593000/593661_Xtrullor---Supernova.mp3"
}
#

here you go

#

m8?

final kettle
#

didnt mean to reply

reef shell
final kettle
#

is it allowed for someone to come to my server to test my bot?

reef shell
#

advertising is not allowed

final kettle
#

ik i wouldnt send chat in here, i would dm

reef shell
#

idk if that is allowed

final kettle
#

pls test with me :3

#

it'll be fun

#

i made a game

reef shell
#

i don't have that much time tho

#

i need to sleep

final kettle
#

it takes less than 2mins

reef shell
#

what game?

trim barn
#
                                                    elif str(rctn) == '❌':
                                                        await admin_embed.delete

Will this delete the embed if I react?

reef shell
#

there is a scam like this

#

no

#

you can delete a message

#

or edit and set embed = None as parameter/keyword arg

trim barn
#

I want it to delete the message automatically if I react to it

reef shell
#

!d discord.Message.delete

unkempt canyonBOT
#

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

Deletes the message.

Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.

Changed in version 1.1: Added the new `delay` keyword-only parameter.
ocean leaf
#

any mistake i have done in this line?

trim barn
#
admin_embed.content = None
#

so like this?

reef shell
#

no

#

what is the admin_embed variable?

ocean leaf
#

i'm getting this error

trim barn
ocean leaf
reef shell
ocean leaf
#

can't we make 2 on_message events?

trim barn
#
await admin_embed.delete()

so like this?

trim barn
reef shell
trim barn
#
embed2 = discord.Embed(
                                                    title="New Report",
                                                    color=0x6632a8
                                                )
                                                embed2.add_field(name='User ID:', value=frt_reply.content, inline=False)
                                                embed2.add_field(name='Reason:', value=snd_reply.content, inline=False)
                                                embed2.add_field(name='Additional Info:', value=more_info.content, inline=False)
                                                embed2.add_field(name='User ID of Reporter', value=ctx.author.id, inline=False)
                                                embed2.set_image(url=image.url)
                                                embed2.set_thumbnail(url=ctx.author.avatar_url_as(static_format="png"))
                                                embed2.set_footer(text='Emoji Key: (✅) = Accept, (❌) = Reject, (⛔) = Block reporter from submitting further reports, (🔄) = Add reporter to Diablo (Use only in extreme cases)')

                                                admin_embed = await self.client.get_channel(780476049943166996).send(embed=embed2)
reef shell
#

then yes.

trim barn
#

alright good

#

thank you

drifting arrow
#

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

trim barn
#
        for y in ["❗", "🔨"]:
            await start_embed.add_reaction(str(y))

        def reaction_check(rctn, usr):
            return usr.id == ctx.author.id and (str(rctn) == '❗' or str(rctn) == '🔨')

        try:
            rctn, usr = await self.client.wait_for("reaction_add", check=reaction_check, timeout=60)
        except asyncio.TimeoutError:
            embed = discord.Embed(
                title="You have timed out.",
                description="Please restart if you wish to run a new scan.",
                color=0xFF0000
            )
            await ctx.send(embed=embed)
            return
        else:
            server_members = [member.id for member in ctx.guild.members]
            offense = collection.find({"userid": {"$in": server_members}})

            for person in offense:
                member_object = (discord.utils.get(ctx.guild.members, id=person["userid"]) for person in offense)

                if bans_channel is None:
                    overwrites = {
                        ctx.guild.default_role: discord.PermissionOverwrite(send_messages=False)
                    }
                    bans_channel = await ctx.guild.create_text_channel(
                        name="diablobans",
                        topic="Lists the offenders that join the server. :warning: MIGHT BE NSFW, DISABLE AT OWN RISK.",
                        overwrites=overwrites,
                        nsfw=True
                    )

                if str(rctn) == "🔨":
                    if offense is not None:

When I react it doesn't respond idky

outer basalt
#

why is this happening ?

#

like only this cmd is not found rest cmds in the file are working fine

#

and when i remove all the cmd except the setup cmd it works

ocean leaf
#

I am getting this error. Pls tell me why this is happening

slate swan
#

rest of ur bot token

keen talon
#

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

slate swan
outer basalt
#

oh wait same name

keen talon
slate swan
#

@keen talon

#

u know full python

keen talon
#

share your code

slate swan
boreal ravine
ocean leaf
# keen talon share code man 😬
 mongo_url = 'keep dreaming'
    cluster = MongoClient(mongo_url)
    db = cluster['databasel']
    collection = db['level']
    author_id = message.author.id
    guild_id = message.guild.id

    user_id = {"_id": author_id}

    if message.author == client.user:
      return
    if message.author.bot:
      return

    if(collection.count_documents({}) == 0):
      user_info = {"id": author_id, "guildID": guild_id, "level": 1, "XP": 0}
      
      collection.insert_one(user_info)

    await message.channel.send('User has logged in!')
#

this is done under a on_message event

keen talon
#

and error ?

keen talon
#

idk mongo man sorry

ocean leaf
#

ok np

drifting arrow
ocean leaf
drifting arrow
#

Anything to do with a database I recommend going there

hoary gust
#

guys can anyone here tell me how to get the user id with the help of quart and discord oauth

#

someone plz help me

slate swan
#

while driver.find_elements_by_Text('You are being rate limited.'):

slate swan
# slate swan > ` while driver.find_elements_by_Text('You are being rate limited.'):`

error came
C:\Users\HP\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py:662: UserWarning: find_elements_by_* commands are deprecated. Please use find_elements() instead warnings.warn("find_elements_by_* commands are deprecated. Please use find_elements() instead") C:\Users\HP\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py:723: UserWarning: find_element_by_* commands are deprecated. Please use find_element() instead warnings.warn("find_element_by_* commands are deprecated. Please use find_element() instead") Traceback (most recent call last): File "c:\Users\HP\Desktop\L.T.T 8TH\astaroth\DISCORD ACCOUT MAKER_AUTO\main.py", line 96, in <module> while driver.find_elements_by_Text('You are being rate limited.'): AttributeError: 'Chrome' object has no attribute 'find_elements_by_Text'

hoary gust
elfin island
slate swan
#

24/7

elfin island
#

that doesn't make much sense

stark hearth
slate swan
#

yes

#

virtual host

#

no repl cloud

languid jungle
languid jungle
stark hearth
#

i know this is not the best hosting service for discord bots, but for starters, use a cloud hosting service like heroku

gloomy quest
#

hi

#

anyone know how to get a persons avatar url?

slate swan
unkempt canyonBOT
#
Huh? No.

No documentation found for the requested symbol.

slate swan
#

!d discord.Member.display_avatar

unkempt canyonBOT
#

property display_avatar: discord.asset.Asset```
Returns the member’s display avatar.

For regular members this is just their avatar, but if they have a guild specific avatar then that is returned instead.

New in version 2.0.
slate swan
#

U need master version for this to work

gloomy quest
#

how

#

pycord?

slate swan
#

Dpy 2.0

#

But a fork works too

gloomy quest
#

How do I installl

slate swan
#

I recommend disnake

#

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

gloomy quest
#

oh

slate swan
#

idk where to send this but

#

how do i add embeds with this i tried

#
           data = {
                'content': "Welcome",
                'username': username,
                'avatar_url': ""
            }
stone palm
#

how do i make a simple subcommand command that invokes without a subcommand

slate swan
leaden prairie
#

!d help

stone palm
slate swan
#

Yes

stone palm
#

alright

boreal ravine
drifting arrow
# slate swan ```py data = { 'content': "Welcome", ...

Or you can do this:

embed = discord.Embed(title=data['content'])
embed.add_field(name="Your username", value=data['username'])
embed.set_footer(icon_url=data['avatar_url'])
mymsg = await ctx.send("This message will self destruct in 5 seconds.",embed=embed)
mymsg.delete(delay=5)
slate swan
#

can u add an image to that

drifting arrow
#

Yes

drifting arrow
# drifting arrow Or you can do this: ```py embed = discord.Embed(title=data['content']) embed.add...

Or you can do this:

import asyncio
embed = discord.Embed(title=data['content'])
embed.add_field(name="Your username", value=data['username'])
embed.set_footer(icon_url=data['avatar_url'])
mymsg = await ctx.send("This message will self destruct in 5 seconds.",embed=embed)
await asycnio.sleep(1)
await mymsg.edit("This message will self destruct in 4 seconds.", embed=embed)
await asycnio.sleep(1)
await mymsg.edit("This message will self destruct in 3 seconds.", embed=embed)
await asycnio.sleep(1)
await mymsg.edit("This message will self destruct in 2 seconds.", embed=embed)
await asycnio.sleep(1)
await mymsg.edit("This message will self destruct in 1 second", embed=embed)
await asycnio.sleep(1)
mymsg.delete()
slate swan
#

no i jus need a description and title with an image

slate nymph
#

is danny there in the server?

drifting arrow
# drifting arrow Or you can do this: ```py import asyncio embed = discord.Embed(title=data['conte...

Or you can do this:

import asyncio
embed = discord.Embed(title=data['content'])
embed.add_field(name="Your username", value=data['username'])
embed.set_footer(icon_url=data['avatar_url'])
mymsg = await ctx.send("This message will self destruct in 5 seconds.",embed=embed)
await asycnio.sleep(1)
await mymsg.edit("Hahaha just kidding. I dont want you to have it.")
await asycnio.sleep(1)
await mymsg.edit("I'm just joshing with ya. Here it is.", embed=embed)
await asycnio.sleep(1)
await mymsg.edit("Oo! There it goes again! hahaha such a sucker.")
await asycnio.sleep(1)
await mymsg.edit("Na but for real tho. here.", embed=embed)
slate swan
#

i jus need a description and title with an image

drifting arrow
#

Like a big ass image? or an image in the corner?

#

or an image in the footer or title?

slate swan
#

big ass

drifting arrow
#

oh

#

Is it an uploaded image or the users image?

slate swan
#

wdym

drifting arrow
#

Are you uploading the image from the bots directory? or do you want to use a specific users image?

slate swan
#

uploaded

drifting arrow
#

Alright

#

You're gonna want to use something like file = discord.File("File location here", filename="whatever you want it to be called . ending"

meager whale
#

py
#this was in a cog

The below code bans player.

@commands.command()
@commands.has_permissions(ban_members=True)
async def ban(self, ctx, member: discord.Member, *, reason=None):
await member.ban(reason=reason)
await ctx.send(f'User {member} has been
py

#

The error and the code

drifting arrow
#

for example. file = discord.File("C:/MyPictures/CuteCatePicture32.png", filename="Cate32.png")

slate swan
#

cant i jus use a link

drifting arrow
#

Yes you can use a link

slate swan
#

https://cdn.discordapp.com/attachments/343944376055103488/891932847429021726/Screenshot_20210927_114900.jpg liekt his

#

how

meager whale
#

Help mee

drifting arrow
#

So assuming you have the link, use embed.set_image(url="link")

drifting arrow
meager whale
#

Ok

drifting arrow
#

@meager whale you indented your function.

meager whale
#

Oh

#

What shall I do

drifting arrow
#
@commands.command()
@commands.has_permissions(ban_members=True)
async def ban(self, ctx, member: discord.Member, *, reason=None):
     await member.ban(reason=reason)
     await ctx.send(f'User {member} has been banned.')
``` Your function needs to inline with the @commands part
meager whale
#

Ok

drifting arrow
#

Coding on a mobile makes it difficult

meager whale
#

Oh

#

Wish I had a PC

drifting arrow
#

I wish you had a PC as well 😦

meager whale
#

Yeah

meager whale
#

Like will it work

drifting arrow
#

I assume so. i just copied and pasted yours and fixed the indent

meager whale
#

Ok

#

Thanks

#

Let's see if it works

drifting arrow
#

Good luck. I need to BRB 2 mins

meager whale
#

@drifting arrow

slate nymph
#

dude u coding in mobile?

slate swan
#

LOL

supple thorn
#

@meager whale its supposed to be {}

supple thorn
slate swan
#

man is alpha @slate nymph

supple thorn
meager whale
#

Send me the updated code

supple thorn
#

Man you gotta really magnify to see the difference between brackets and paranthesis

boreal ravine
#

@meager whale bro

meager whale
#

Yeah

boreal ravine
#

y u crossposting

ocean leaf
#

i am getting this error. please help me

boreal ravine
#

on other servers

supple thorn
slate swan
boreal ravine
boreal ravine
meager whale
#

@boreal ravine I am doing because who helps me first

#

Sorry for that

supple thorn
#

Rather than here

meager whale
#

And

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

supple thorn
#

Cause thats pymongo

boreal ravine
#

simple python mistake

meager whale
#

Ok

#

@supple thorn I still have error

boreal ravine
meager whale
#

Where

#

@commands.command()
@commands.has_permissions(ban_members=True)
async def ban(self, ctx, member: discord.Member, *, reason=None):
await member.ban(reason=reason)
await ctx.send(f'User {member} has been banned.') 
Your function needs to inline with the @commands part

#

That's the new code

ocean leaf
#

i already asked like 5 times

manic wing
ocean leaf
#

no one replied

ocean leaf
meager whale
boreal ravine
#

shut up

supple thorn
manic wing
ocean leaf
supple thorn
#

The only reason we do it because we literally dont have a pc or a laptop

manic wing
fathom hound
#

is there any property that differentiates a 'normal' message;

#
  • such as this one
fathom hound
manic wing
#

!d discord.Message.reference

unkempt canyonBOT
#

The message that this message references. This is only applicable to messages of type MessageType.pins_add, crossposted messages created by a followed channel integration, or message replies.

New in version 1.5.

upbeat otter
#

Guys, this line is from one function:

rand_num = random_number(20, 300)

i want to use the same numbers in another function, how do i do that?

fathom hound
# manic wing .reference

i tried using the reference attribute but this is what it returns:
<MessageReference message_id=891477598398455818 channel_id=796229736103673901 guild_id=796229736103673896>
i can't figure how to know if it was a replied mesage

manic wing
meager whale
#

@commands.command() @commands.has_permissions(ban_members=True) async def ban(self, ctx, member: discord.Member, *, reason=None): await member.ban(reason=reason) await ctx.send(f'User {member} has been banned.')  Your function needs to inline with the @commands part

ocean leaf
meager whale
#

Help meh

ocean leaf
manic wing
meager whale
#

I want help

fathom hound
manic wing
slate nymph
meager whale
#

Nope

ocean leaf
#

thumb hurts

meager whale
#

No it doesn't

ocean leaf
boreal ravine
#

U have an invisible character in your code

meager whale
#

Ok

ocean leaf
#

when i type a command in my shell, it dosen't perform it

#

it just freezes

manic wing
#

what device are you on and what os

#

does it just pause as if its thinking

#

or does it just ignore the command

ocean leaf
#

lemme refreash page and try first

#

yes it got fixed after refreshing

manic wing
#

okay cool

#

so pip install pymongo[srv]

ocean leaf
#

yes i am doing

#

done

manic wing
#

now your error should be gone

#

try and read the error in the future, it literally tells you the command to run to install it

gloomy coral
#

guys i need help

ocean leaf
#

now what is this? i can't understand after reading

vocal plover
#

which error?

gloomy coral
#

After i react, it does nothing

#

And after 30 seconds it shows.....

upbeat otter
maiden fable
#

retry_emoji = disnake.PartialEmoji.from_str(":readthedocs:")

Doing this, but is still showing Unknown Emoji when I try to pass it in add_reaction(). Any help?

vocal plover
#

asyncio.TimeoutError?

gloomy coral
#

yea

ocean leaf
alpine locust
#

hey can anyone pls help

gloomy coral
upbeat otter
ocean leaf
#

ig i shd ask in database if someone comes there

alpine locust
#

can anyone tell me what is wrong here ?

vocal plover
#

that means that for whatever reason your bot isnt getting an even that matches the check, which could mean your check logic is wrong

gloomy coral
maiden fable
#

nvm

vocal plover
maiden fable
#

Yea I thought so

upbeat otter
ocean leaf
alpine locust
vocal plover
#

my tutorial is getting a ui upgrade soon™️ eyes_shake

ocean leaf
#

until u say hi, the bot is not gonna run and unless the bot runs, it can't check if u sent hi 😂

maiden fable
ocean leaf
vocal plover
alpine locust
#

like this

maiden fable
#

retry_emoji = disnake.PartialEmoji.from_str(":readthedocs:")

Doing this, but is still showing Unknown Emoji when I try to pass it in add_reaction(). Any help?

(The emoji is in the standard form, that is, <:name:id>. It is just discord being weird)

vocal plover
#

afaik this is the most accurate/best practices tutorial out there for dpy

maiden fable
#

Yea

#

no sarcasm

ocean leaf
ocean leaf
# alpine locust like this

until u say hello, the bot is not gonna run and unless the bot runs, it can't check if u sent hello 😂

maiden fable
#

Hey Alec, mind helping me?

fathom hound
vocal plover
#

sure, what with?

gloomy coral
#

@vocal plover i fixed it 🙂

dim cedar
#
async def youtube(ctx, *, search):
  search = search
  
  html = urllib.request.urlopen('http://www.youtube.com/results?search_query='+ search)
    # print(html_content.read().decode())
  search_results = re.findall(r"watch\?v=(S.{11})", html.read().decode())
    
    # I will put just the first result, you can loop the response to show more results
  await ctx.send('https://www.youtube.com/watch?v=' + search_results[0])```
vocal plover
# maiden fable ^^^

!paste can you put the code in here so discord doesnt screw with the emoji formatting

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.

dim cedar
#

what is wrong with this?

vocal plover
#

The first thing is that youtube doesn't allow scraping its site, because it has an api

maiden fable
maiden fable
#

Ignore the indent, it is just my copying is wrong

alpine locust
maiden fable
vocal plover
#

odd, it works for me

maiden fable
#

(This is the first time I have opened your site)

alpine locust
maiden fable
#

Hmm, idrk bro

vocal plover
#

cloudflare what are you doing to my precious site lmao

maiden fable
#

😂

#

time to DDOS that site IP

dim cedar
#

would u help me?

maiden fable
#

with my potato super computer 😄

vocal plover
maiden fable
#

wait, so no other way

#

I thought bots are able to use those emojis with PartialEmoji

vocal plover
#

for a bot to use an emoji it needs to be a default emoji or share the server

maiden fable
#

Bruh lemon_angrysad

#

I thought PartialEmoji works without sharing the emoji

boreal ravine
#

Didn't we all know this 🤔

maiden fable
#

Not me, I am a beginner

vocal plover
#

partial emoji just means that the emoji is manually populated with data, rather than using data from the api

maiden fable
#

Ah

#

Time to add that emoji to my server then :c

dim cedar
#

help?

vocal plover
#

partials in general in dpy means that you give it a few details so you can perform api operations without actually fetching the object

craggy cloak
#

every time when i restart my bot i get this error?
When i fix this error by installing pip install discord.py[voice] ,next time i get again this error?

craggy cloak
#

I don't use an env file

gloomy coral
#

@vocal plover

#

I need help again

#

OR any1 else

valid perch
#

I mean, I cant read your mind. What do you need help with

maiden fable
maiden fable
gloomy coral
#

But its not sending the victory embed, even when i guessed correct

vocal plover
#

Yeah, I'm happy to help generally but it's nice to know what I'm helping with before I agree to help :P

acoustic ermine
#

Is it possible to check if a invite to a server is the ctx.guild so if a member sends a discord server invite how can I check that the invite is for the same server and not another one

gloomy coral
#

hi

craggy cloak
dim cedar
#

how can i make a yt search command?

boreal ravine
dim cedar
#

anyone?

valid perch
gloomy coral
#

wait i think ik how to fix

boreal ravine
#

U sure you installed it?

#

Why did u delete the message

dim cedar
#

how can i make a yt search command?
anyone?

#

no one?

craggy cloak
#

I wanted to ping you because I thought you wouldn't read the chat anymore :D

dim cedar
#

............

craggy cloak
boreal ravine
#

show ss when u installed

dim cedar
craggy cloak
boreal ravine
#

That aint no error

#

Thats just a warning

gloomy coral
#

wait lemme tell u what im tryna do

craggy cloak
#

I upgrade that pip and reinstalled the discord.py[voice]

boreal ravine
craggy cloak
boreal ravine
#

Ok then

#
  • Repl.it uses an ephemeral file system.
    • This means any file you saved via your bot will be overwritten when you next launch.
boreal ravine
#

That explains why u need to keep installing pynacl ^

boreal ravine
slate swan
#

No

boreal ravine
#

why else do you think its not saving?

gloomy coral
craggy cloak
slate swan
#

When I used Repl.it and json to save data it saved and was still there on next launch

gloomy coral
boreal ravine
#

I mean data using the console or the shell

slate swan
#

Oh

#

Then yeah

lucid stream
#
async def on_ready():
    await client.change_presence(activity=discord.Activity(f"Watching over {len(client.users)}" ))
    print('we have logged in as akashgreninja'.format(client))
    ``` error-TypeError: __init__() takes 1 positional argument but 2 were given
#

yelp

craggy cloak
#

Is there any possibility that it can be fixed?

boreal ravine
lucid stream
#

line 41 to be precise that is from await

craggy cloak
boreal ravine
#

you could preinstall it using a .replit file

#

not sure how tho

slate swan
#

You could also just import os and at the top of your main.py file you can add os.system('pip install PyNaCl')

boreal ravine
#

that too

slate swan
#

?

ocean leaf
#

i sent it in #databases , now pls come there and help me

dim cedar
#

now?

#

can anyone help me with my code?

alpine locust
#

what is the problem with this now

lucid stream
#

'wfwffwffffwwf'

alpine locust
dim cedar
#

eh

#

why print?

alpine locust
ocean leaf
lucid stream
dim cedar
#

await ctx.send (" ")
do not use print

dim cedar
alpine locust
ocean leaf
lucid stream
#

try agin and send error

slate swan
dim cedar
#
async def youtube(ctx, *, search):
  search = search
  
  html = urllib.request.urlopen('http://www.youtube.com/results?search_query='+ search)
    # print(html_content.read().decode())
  search_results = re.findall(r"watch\?v=(S.{11})", html.read().decode())
    
    # I will put just the first result, you can loop the response to show more results
  await ctx.send('https://www.youtube.com/watch?v=' + search_results[0])```
#

what is the prob?

gloomy coral
#

Ill open a help channel

dim cedar
alpine locust
dim cedar
#

cmd dont works

slate swan
#

also , requests is blocking
use aiohttp instead

slate swan
dim cedar
slate swan
unkempt canyonBOT
dim cedar
slate swan
#

install it

dim cedar
#

there is one

#

error

slate swan
dim cedar
#

see

alpine locust
slate swan
boreal ravine
slate swan
dim cedar
#

how to fix that?

boreal ravine
dim cedar
#

how to make a working yt search command?

boreal ravine
#

!os

dim cedar
slate swan
#

you just didnt provide a valid search argument

dim cedar
#

=youtube cradles

#

i gave this

#

command

dim cedar
#

why not in my command?

ocean leaf
#

it has been 50 mins and no one came in #databases and helped me

#

i told ya

#

no one comes there to help

stark bobcat
#

hi

#

can i delete a category like this

await ctx.guild.category_exists.delete()```
fringe breach
#

How do I get the user on which ContextMenu is used?
I tried: ctx.target_member.id nothing happened

fringe breach
# dim cedar use

and how to get another user on which the right button is pressed ?

#

How to get the author I know

dim cedar
#

what u want

#

to do

dim cedar
#

by making a list of authors u know

#

then

fringe breach
dim cedar
#

eh

fringe breach
#

get the user on which the button was clicked

drifting arrow
#

@fringe breach if it's run in a command using ctx, use ctx.author

fringe breach
#

no!

drifting arrow
#

😦

fringe breach
#

I clicked on another user

#

And I got myself

drifting arrow
#

Well author is whoever triggered the command

fringe breach
#

And I need to get another user who was clicked on

drifting arrow
#

¯_(ツ)_/¯

fringe breach
#

To get a user to respond to messages
ContextMenuType.MESSAGE ctx.target_message.content

#

this is a click on the message

#

And I click on the user this :
ContextMenuType.USER it would be more logical to use ctx.target_user.mention

#

but it doesn't work

slate swan
#

hey i need help with discord.py

Import "discord_buttons" could not be resolved
🤔

gloomy coral
soft radish
#

How can i set a channel to a welcome channel when doing a cmd?

spring flax
#

insert the channel id

spring flax
unkempt canyonBOT
lament mesa
#

guild.category_exists isnt a thing

maiden fable
#

Yea

#

It's CategoryChannel

#

!d discord.CategoryChannel.delete

unkempt canyonBOT
#

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

Deletes the channel.

You must have [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to use this.
tropic briar
#

I want to ban someone if there's bad word by the user using my discord python bot I wonder How
and also delete the message

soft radish
heavy radish
#

Why does the embeds not allow server emoji's??

stone palm
#

What's this error?```py
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 618, in _load_from_module_spec
setup(self)
File "/home/runner/CaliberBot-Beta/cogs/help.py", line 85, in setup
bot.add_cog(Help(bot))
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 505, in add_cog
raise TypeError('cogs must derive from Cog')
TypeError: cogs must derive from Cog

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

Traceback (most recent call last):
File "main.py", line 50, in <module>
client.load_extension("cogs.help")
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 678, in load_extension
self._load_from_module_spec(spec, name)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 623, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'cogs.help' raised an error: TypeError: cogs must derive from Cog

maiden fable
stone palm
lament mesa
#

subclass commands.HelpCommand to make a help command

stone palm
#

the code works just fine on another bot tho

spring flax
stone palm
lament mesa
#

!customhelp

unkempt canyonBOT
#

Custom help commands in discord.py

To learn more about how to create custom help commands in discord.py by subclassing the help command, please see this tutorial by Stella#2000

spring flax
#

check the pins

stone palm
#

isnt that okay?

lament mesa
#

that is ok but suclassing commands.HelpCommand will make stuff easier

stone palm
gloomy coral
#

guysssss

stone palm
#

where i could add stuff apart from just commands as well

gloomy coral
hoary gust
#

someone tell me what is wrong in it ```py
@app.route('/handle_data', methods=['POST'])
async def handle_data():
projectpath = await request.form['prefix']
print (projectpath)
return redirect(url_for("test"))

gloomy coral
hoary gust
little ether
gloomy coral
#

ok

#

i see

#

@little ether again same thing

little ether
gloomy coral
#

ok wait

sick talon
#

how to know whether a user has his cam on or not ?

#

?tag self.video

#

bot is offline

cloud dawn
#

tag is !