#discord-bots

1 messages · Page 630 of 1

sullen shoal
#

!botvar

unkempt canyonBOT
#

Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:

bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"

@bot.command()
async def get(ctx: commands.Context):
    """A command to get the current value of `test`."""
    # Send what the test attribute is currently set to
    await ctx.send(ctx.bot.test)

@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
    """A command to set a new value of `test`."""
    # Here we change the attribute to what was specified in new_text
    bot.test = new_text

This all applies to cogs as well! You can set attributes to self as you wish.

Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!

cloud dawn
#

Getting items in on_ready is not recommeneded.

late wigeon
#

the command does nothing and if I try changing it to slash.slash it tells me it's missing ctx still

minor panther
#

tnx very

sullen shoal
#

damn people still dont use forks tf

boreal ravine
#

🤦‍♀️

cloud dawn
#

I use disnake so i don't have all these issues lol

clear rapids
#

How can I get the number of messages sent by a user in a discord server and store it in a list?

#
userMessages = []
user = discord.utils.find(lambda m: m.id== j, channel.guild.members)
async for message in channel.history(limit = 100000):
    if message.author == user:
        userMessages.append(message.content)
print(len(userMessages))
#

I'm currently using this code but it is too slow

sullen shoal
#

a better way is logging the messages using the on_message event

clear rapids
#

how exactly can I do that?

slate swan
#

can someone help me
so the function is reducing balance its just its not adding value in the column

hm = 1 
@golden.command()
async def coin(ctx):
    conn = sqlite3.connect('test.sql')
    c = conn.cursor()
    amount = 80
    player = ctx.author
    c.execute(f"UPDATE data SET balance = balance-{amount} WHERE ID = {player.id}")
    c.execute(f"UPDATE data SET golden_coin = golden_coin+{hm} WHERE ID = {player.id}")
    conn.commit()
    await ctx.send('Golden-Coin Was Successfully Added In Your Inventory')
sullen shoal
sullen shoal
boreal ravine
#

on_message only works for every new message

clear rapids
sullen shoal
#

its the server's fault if they didnt invite it before. as the owner of the bot, we have to take care so that we dont get rate limited

clear rapids
clear rapids
#

because I'm using this in a slash command

dapper cobalt
sullen shoal
#

then use channel.history ig

dapper cobalt
#

If you log commands, that's fine. But you still need to have a privacy policy and terms of use for your bot.

sullen shoal
#

async for message in channel.history(limit = 100000):
thats a massive amount though

clear rapids
#

yeah I just did that for testing

dapper cobalt
#

For each 100 messages a request is made. This number can easily ratelimit the bot.

clear rapids
#

yeah I'll set that to 5000 or less , but still this is too slow

#

it is taking 20 sec to calculate for single user

dapper cobalt
#

5,000 means 50 requests at once.

sullen shoal
#

ratelimit

clear rapids
#

so what slowing this is the limit?

sullen shoal
#

i would say to not do it at all, there is a reason no big bot does it

clear rapids
#

hm but it is necessary for my bot

dapper cobalt
#

If your bot is for public use, I don't recommend doing such a thing at all.

clear rapids
dapper cobalt
#

If only 2 users used the command at once, your bot will get ratelimited very quickly.

sullen shoal
#

also i wonder why add such a useless thing, if they can just use the search bar

clear rapids
dapper cobalt
# clear rapids

Then go with what @sullen shoal said and store user's messages count.

velvet tinsel
clear rapids
sullen shoal
#

say goodbye to em

dapper cobalt
clear rapids
#

wao😂

#

check out this bot this bot can calculate previous messages too

#

so why cant my bot do that?😅

dapper cobalt
#

Not all messages.

#

It may be counting only last 50 messages of a single user.

clear rapids
#

no I want to calculate how many messages a user have sent

dapper cobalt
#

count=50, check=lambda m: m.author.id == 12345

clear rapids
#

nope

#

it is calculating all the messages

dapper cobalt
#

You need to first get the messages.

thick sigil
#

Iterating thru channels to get messages count

clear rapids
#

how can It check if a user have sent 1000 messages

#

?

thick sigil
#

Store messages counter on on_message event

clear rapids
#

how exactly?😅

thick sigil
#

use on_message event, then figure how you want to store it ?

clear rapids
#

any api references?

thick sigil
#

on_message said it thrice

sullen shoal
#

make a dict, increase the message count of each user on message and save the items of the dict to your database every 20 minutes or so

clear rapids
#

all that for a single command?

sullen shoal
#

yes?

clear rapids
#

hm , thanks for help , I'll try that

thick sigil
#

you just check if the member has the required message amount on his interaction

clear rapids
#

😅 thats exactly what I want to do

thick sigil
#

Im not here to give any code, you got the docs

sullen shoal
#

its some basic algorithm shit, idk why someone would need help with that

clear rapids
#

I have read the docs , it said use history

thick sigil
#

devs nowadays

clear rapids
#

and I was getting the expected result but lil bit slow

sullen shoal
#

if you want your bot to be repeatedly ratelimited and then finally get banned, please use TextChannel.history

outer violet
#

How do I get the category count of a server?

spring flax
unkempt canyonBOT
#

property categories: List[discord.channel.CategoryChannel]```
A list of categories that belongs to this guild.

This is sorted by the position and are in UI order from top to bottom.
outer violet
#

Okay thank you

slate swan
#

soo the command is reducing the value in the user's balance
its just its not adding more value in the column

hm = 1
@golden.command()
async def coin(ctx):
    conn = sqlite3.connect('test.sql')
    c = conn.cursor()
    amount = 80
    player = ctx.author
    c.execute(f"UPDATE data SET balance = balance-{amount} WHERE ID = {player.id}")
    c.execute(f"UPDATE data SET golden_coin = +{hm} WHERE ID = {player.id}")
    conn.commit()
    await ctx.send('Golden-Coin Was Successfully Added In Your Inventory')```
help please
sullen shoal
slate swan
#

"-{amount}"

vocal shoal
#

can someone explain what this means?
this keeps happening randomly and i have to turn the bot back on

sullen shoal
#

you must be doing some really weird stuff if you get websocket errors

vocal shoal
#

what kind of weird like in commands or in cofig?

sullen shoal
#

idk

outer violet
#

Is there a way to get the description of a server?

vocal shoal
spring flax
unkempt canyonBOT
outer violet
#

Okay thank you

sullen shoal
#

i hope sticks isnt actuallly doing discord.Guild.description in their code

outer violet
#

Lmao no I’m not

velvet tinsel
slate swan
#

please tell me how

spring flax
slate swan
#

how it's java

#

was this a joke or smth

slate swan
sage otter
#

Probably just a shitpost. I doubt he was being serious

slate swan
#

oops

velvet tinsel
slate swan
#

thank god

velvet tinsel
clear rapids
#

I don't want to store mew messages , I just want number of messages that are already been sent

unkempt canyonBOT
#

Hey @slate swan!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

slate swan
#

Hey, i'm making a json API with synchronization with my discord bot, i make the code but the API list dont update, semeone can help me? (if needs the code please DM me)

#

how can we get user banners?

velvet tinsel
slate swan
#

its not a complicated question

velvet tinsel
#
user.banner.url # the URL of the banner```
slate swan
#

ty
ig

opal skiff
#

discord.Embed(add_field(name = "test",value="other test",inline=False)) idk how to add fields to embeds

velvet tinsel
#

Stop pinging me please, you can just ask

#

And no.

#

Unless they have it connected to their discord

#

🤷‍♂️

velvet tinsel
#

There is Sherlock that might help you

#

…no…you said how to get url…

velvet tinsel
opal skiff
sage otter
#

Yeah

velvet tinsel
#

That’s what I said.

#

Oh, connected. I missed that. My apologies.

opal skiff
#

How do i change colors of an embed?

slate swan
opal skiff
#

can you give me an example please

slate swan
# opal skiff can you give me an example please

default = 0
teal = 0x1abc9c
dark_teal = 0x11806a
green = 0x2ecc71
dark_green = 0x1f8b4c
blue = 0x3498db
dark_blue = 0x206694
purple = 0x9b59b6
dark_purple = 0x71368a
magenta = 0xe91e63
dark_magenta = 0xad1457
gold = 0xf1c40f
dark_gold = 0xc27c0e
orange = 0xe67e22
dark_orange = 0xa84300
red = 0xe74c3c
dark_red = 0x992d22
lighter_grey = 0x95a5a6
dark_grey = 0x607d8b
light_grey = 0x979c9f

opal skiff
#

ok do i dodiscord.Embed().Colour("0xe74c3c")?

slate swan
opal skiff
#

ok ty

slate swan
#

Yw

velvet tinsel
#

Not self bots

slate swan
velvet tinsel
#

You can just do discord.Colors.insert_color_here()

velvet tinsel
#

But using hex is recommended if there is no good colors

slate swan
velvet tinsel
slate swan
velvet tinsel
velvet tinsel
#

I hate hex

slate swan
velvet tinsel
#

You want me to bm that pika as well?

#

I like the pika

velvet tinsel
#

Oh, yes.

sage otter
#

That was deprecated

#

Can’t even access that info on there.

#

Read the post

#

Anytime you try to access discord.Profile attributes you will always get None

#

It’s a discord limitation

velvet tinsel
#

I hate it when you’re about to do something fun and then it says: Against ToS

#

I nearly broke the TOS of many websites

#

Scratch: tried to exploit a GitHub code

#

Discord: nearly self botted myself

#

Various websites: tried to break in

#

And some GitHub resps

slate swan
velvet tinsel
#

I bookmarked it

#

Deal with it

slate swan
velvet tinsel
#

Google has no limits

#

😂

#

What

#

?

#

Ok

#

Bug

#

Most possibly

opal skiff
#

how can i make the bot do an action on a message the bot has sent itself?

outer violet
velvet tinsel
#

Change it to client

#

You can use emojis from different servers in your bots, right?

outer violet
#

Oh oops

slate swan
#

it's just

#

self.client = client

#

whatchu doing there sir

velvet tinsel
#

Ok

manic wing
#

bots have nitro

#

essentially

slate swan
#

I don't

velvet tinsel
#

Oh sweet

opal skiff
#

how do i make it that the bot reacts to a message sent by itself?

slate swan
#

just use on_message

#

remove the the two lines where it returns when the message is from itself

opal skiff
#

ok

outer violet
velvet tinsel
slate swan
#

LearnPython(None)

velvet tinsel
#

There is no Bot.kumo lmao

velvet tinsel
twin mica
#

hello guys

#

please help me

slate swan
#

ask without asking to ask

twin mica
#

im newbie in Python

#

@client.command()
async def setdelay(ctx, seconds: int):
await ctx.channel.edit(slowmode_delay=seconds)
await ctx.send(f"Set the slowmode delay in this channel to {seconds} seconds!")

slate swan
#

then practice python first

twin mica
#

add please embed

slate swan
#

!d discord.Embed

unkempt canyonBOT
#

class discord.Embed(*, colour=Embed.Empty, color=Embed.Empty, title=Embed.Empty, type='rich', url=Embed.Empty, description=Embed.Empty, timestamp=None)```
Represents a Discord embed.

len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.

bool(b) Returns whether the embed has any data set.

New in version 2.0.

Certain properties return an `EmbedProxy`, a type that acts similar to a regular [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.9)") except using dotted access, e.g. `embed.author.icon_url`. If the attribute is invalid or empty, then a special sentinel value is returned, [`Embed.Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty").

For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.9)") for you.
outer violet
slate swan
#

you make an embed by making a variable

#

embed = discord.Embed(kwargs)

slate swan
#

then you send that with
await ctx.send(embed=embed)

opal skiff
#

how do i make the bot react to a message?

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

yep

twin mica
slate swan
twin mica
#

😦

velvet tinsel
#

Bruh

#

Learn basic python BEFORE dpy.

opal skiff
#

oh typo

modern galleon
#

How do you add this to a bot?

#

and that on / commands your commands pop up?

opal skiff
#

my bot tells me this discord.errors.HTTPException: 400 Bad Request (error code: 10014): Unknown Emoji i use await message.add_reaction("👍")

manic wing
opal skiff
#

unicode? what is that?

opal skiff
modern galleon
#

If emoji is built in in discord you can use :emoji_name:

manic wing
#

It’s only unicode afaik

modern galleon
#

oh yeah that only works for messages

opal skiff
#

ok i found some website where you can copy unicode

velvet tinsel
marble cradle
worthy moat
#

can someone help me ?
this code doesn't work
Code:

@bot.command()
async def captcha(ctx):
    user = (ctx.author.id)
    if captcha == '1':
        await ctx.send(f'Aby się zweryfikować patrz dm')
        await ctx.send(f'Jeżeli wiadomość nie przychodzi zgłoś się do Dewelopera')
        embed = Embed(title = 'Captcha', color=998514)
        embed.description = f'aby się zweryfikować napisz co tu jest napisane'
        embed.set_image(url="attachment:captchafiles/captcha1.png")
        embed.set_footer(icon_url=ctx.author.avatar_url, text=f"{ctx.author.name}#{ctx.author.discriminator}")

        await user.send(embed)
    if captcha == '2':
        embed = Embed(title='Captcha', color=998514)
        embed.description = f'aby się zweryfikować napisz co tu jest napisane'
        embed.set_image(url="attachment:captchafiles/captcha2.png")
        embed.set_footer(icon_url=ctx.author.avatar_url, text=f"{ctx.author.name}#{ctx.author.discriminator}")

        await user.send(embed)

I use random, discord.py

#

files are correct

#

and variable too

golden badge
#
def FunFact():
    return random.choice(FunFacts)

FunFact()
print(FunFacts)

This works. However when trying to call if from my discord script. Nothing is printed.

@client.event
async def on_message(message):
    openers = "hello", "hi", "hey"
    username = str(message.author).split("#")[0]
    user_message = str(message.content)
    channel = str(message.channel.name)

    print(f"{username}: {user_message} ({channel})")

    if message.author == client.user:
        return
    if user_message.lower() in openers:
        await message.channel.send(f"Hello {username} lets get started!")
        time.sleep(1.0)
        await message.channel.send("What would you like to talk about? Weather, Nutrition, Jokes or Facts?")
    if user_message.lower() in choiceJoke:
        FunFact()
        Fact = FunFact()
        print(Fact)
        await message.channel.send(Fact)
        time.sleep(1.0)
        await message.channel.send("What would you like to talk about? Weather, Nutrition, Jokes or Facts?")```
Why does the function not work when called from the discord bot
worthy moat
#

there isn't any error

#

when i use my command bot do not print anything

brisk helm
#

Do you have on_message event

unkempt canyonBOT
#

Hey @worthy moat!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

slate swan
#

.d discord.wait_for

worthy moat
#

where i need to add it

#

.d discord.wait_for

slate swan
slate swan
worthy moat
#

thats the all thing for captcha

random1_2 = ['1', '2']
captcha = (random.choice(random1_2))
brisk helm
brisk helm
#

.

worthy moat
#

ok

cerulean osprey
#

How can I make a bot wait 60 seconds before running on_typing again?

slate swan
#

captcha = random.choice(random1_2)

cerulean osprey
#

Its says undefined name "sleep"

slate swan
worthy moat
#

still doesn't work

cerulean osprey
#

What do I import exactly? import sleep?

slate swan
#

from asyncio.tasks import sleep

golden badge
worthy moat
golden badge
#

FunFacts is the returned fact from FunFact. I know bad naming xd

slate swan
golden badge
#

As i said. The code works outside of the discord code block. However inside it prints nothing and discord errors that it cant send a blank message

worthy moat
#

npe

golden badge
#

I even tried having the Function in the same script. Control C code outside of the discord. It works. Control C code into the discord block. No return

slate swan
#

Openers = ["hey","hello"]

#

ect..

golden badge
#

However discord bot functions are supposed to work exactly like this so

slate swan
golden badge
#

Its literally just calling a function. I dont know how much else i could miss lol

old badge
#

hi i have a question. is it still possible to make a custom music bot or youtube wiped their whole discord api support

golden badge
#

I say lol but im crying inside

slate swan
slate swan
#
def FunFact():
    return random.choice(FunFacts)

FunFact()
print(FunFacts)
slate swan
slate swan
cerulean osprey
slate swan
velvet tinsel
#

okimii being pro 😄

full lily
slate swan
slate swan
cerulean osprey
slate swan
cerulean osprey
slate swan
#

@cerulean osprey btw dont use time.sleep() as its not async and will stop your whole bot so use asyncio.sleep() as its async

velvet tinsel
slate swan
slate swan
cerulean osprey
cerulean osprey
#
await asyncio.sleep(60)
slate swan
#

Show the full codejam_cavedude

velvet tinsel
slate swan
cerulean osprey
#
@client.event
async def on_typing(channel, user, when):
    if channel.id == 909685766244945921:
        await channel.send(f'Woah, {user.mention}! Before you send your message, just be warned, you will be softbanned if you message here!')
        await asyncio.sleep(60)
velvet tinsel
slate swan
#

Let me check

slate swan
#

add user : discord.Member

slate swan
velvet tinsel
slate swan
#

As its just pointing at the asyncio.sleep()

slate swan
cerulean osprey
#

It works already, Im talking abt asyncio.sleep()

slate swan
#

Idk

sage otter
#

type hinting doesn’t do anything at run time.

slate swan
#

from asyncio.tasks import sleep

slate swan
sage otter
#

It’s just to help your IDE and documentation.

slate swan
#

It works for me tho

#

No need

#

@cerulean osprey

import asyncio
velvet tinsel
#

okimii being smort

slate swan
slate swan
cerulean osprey
#

Still didnt work sadly

slate swan
slate swan
velvet tinsel
slate swan
sage otter
slate swan
cerulean osprey
cerulean osprey
velvet tinsel
#

cooldown?

cerulean osprey
#

Something like that ye

velvet tinsel
#

its an event sorry

sage otter
#

And who said sleeping it would not allow the event to be triggered again?

slate swan
sage otter
#

That defeats the whole point of async programming

velvet tinsel
#

make a check and check every 60 seconds if a variable is True

cerulean osprey
slate swan
cerulean osprey
#

Make the bot wait 60 seconds before running on_typing again

sage otter
#

Consider making your own throttling for this.

velvet tinsel
slate swan
#

Use commands.cooldown(0,0) i think it is

sage otter
#

these are for commands

velvet tinsel
sage otter
#

Not events

slate swan
#

stroke

cerulean osprey
velvet tinsel
#
a = False
await asyncio.sleep(60)
a = True
if a:
  stuff
  a = False
else:
  something idk
#

I dont know I quick coded it :/

slate swan
velvet tinsel
slate swan
#

Or it will just say await blah blah blah is not in a async function

velvet tinsel
#

fine

slate swan
#

That was happends when you do a global var with await

velvet tinsel
#
@client.event
async def on_ready():
  a = False
  time.sleep(60)
  a = True
  if a:
    stuff
  a = False
  else:
    something idk

logic

#

...or not

slate swan
velvet tinsel
#

ahhhh

slate swan
#

And i don't recommend doing it on ready

velvet tinsel
#

I mean time.sleep() would work?

cerulean osprey
#

Ok now it just waits 60 seconds before doing it Pain

velvet tinsel
velvet tinsel
slate swan
velvet tinsel
slate swan
velvet tinsel
#

idk my code sucks I only use logic 😦

slate swan
velvet tinsel
#

mm

#

they have to check tho :/

cerulean osprey
#

Still doesnt wait for 60 seconds Pain

slate swan
cerulean osprey
#
@client.event
async def on_typing(channel, user, when):
    if channel.id == 909685766244945921:
        a = True
        if a:
            await channel.send(f'Woah, {user.mention}! Before you send your message, just be warned, you will be softbanned if you message here!')
        a = False
        
        await asyncio.sleep(60)
        a = True
    else:
        return
``` prob did it wrong but this what I did
slate swan
#

You can only sleep a command with the cooldown decorator which doesnt work for commands

cerulean osprey
#

But its not a command Pain

slate swan
cerulean osprey
#

2DSad Damn alr, thanks for trying

slate swan
#

@velvet tinsel can you think a way of delaying a event cuz i cant tbhpithink

#

Do you know tylershipit

velvet tinsel
slate swan
velvet tinsel
#

I found asyncio.sleep() and time.sleep()

slate swan
velvet tinsel
slate swan
#

Andy do you?

pliant gulch
#

A bit advanced but you could use an asyncio.Lock

#

Atleast that's what I would use

slate swan
pliant gulch
#

!d asyncio.Lock

unkempt canyonBOT
#

class asyncio.Lock```
Implements a mutex lock for asyncio tasks. Not thread-safe.

An asyncio lock can be used to guarantee exclusive access to a shared resource.

The preferred way to use a Lock is an [`async with`](https://docs.python.org/3/reference/compound_stmts.html#async-with) statement:

```py
lock = asyncio.Lock()

# ... later
async with lock:
    # access shared state
```...
velvet tinsel
#

me neither

slate swan
#

I seepithink

velvet tinsel
#

ty andy

slate swan
#

I love how it just says: NOT THREAD SAFE

pliant gulch
#

I'll get on my computer and see if I can write a quick example

pliant gulch
#

prob a bad example but here it only prints the second time if the lock is released

#

And the lock is only released after waiting 5 seconds

pliant gulch
#

This isn't an IDE its the ipython repl thing

slate swan
pliant gulch
#

Its like how you type python in your terminal and a repl pops up

slate swan
#

Ah I see

#

Looks clean tho

pliant gulch
#

Depends on how the terminal is customized i'd say

pliant gulch
slate swan
#

Thats cool,never heard of that ide before

pliant gulch
#

Should check it out, very productive although it's a unconventional IDE compared to what I assume you usually use

slate swan
#

You probably know what i use jam_cavedude

pliant gulch
#

Vscode?

slate swan
pliant gulch
#

Ah yea then its gonna be pretty much wildly different

slate swan
#

How?🤔

pliant gulch
#

Its a lot more minimal then Vscode and there isn't really and clickables

#

You have to do everything you want on the keyboard

slate swan
#

Ah i seepithink

worthy moat
#

can someone help me ?
this code doesn't work
Code:


@bot.command()
async def captcha(ctx):
    user = (ctx.author.id)
    if captcha == '1':
        await ctx.send(f'Aby się zweryfikować patrz dm')
        await ctx.send(f'Jeżeli wiadomość nie przychodzi zgłoś się do Dewelopera')
        embed = Embed(title = 'Captcha', color=998514)
        embed.description = f'aby się zweryfikować napisz co tu jest napisane'
        embed.set_image(url="attachment:captchafiles/captcha1.png")
        embed.set_footer(icon_url=ctx.author.avatar_url, text=f"{ctx.author.name}#{ctx.author.discriminator}")

        await user.send(embed)
    if captcha == '2':
        embed = Embed(title='Captcha', color=998514)
        embed.description = f'aby się zweryfikować napisz co tu jest napisane'
        embed.set_image(url="attachment:captchafiles/captcha2.png")
        embed.set_footer(icon_url=ctx.author.avatar_url, text=f"{ctx.author.name}#{ctx.author.discriminator}")

        await user.send(embed)

I use random, discord.py
files are correct
and variable too

slate swan
#

Nvm

#

how i remove a key from a dict?

slate swan
slate swan
slate swan
hollow agate
#
@client.command()
async def hi(ctx):
    await ctx.message.delete()
    has_perms = False
    for role in ctx.author.roles:
        if role.name == "Sr. Admin" or role.name == "Admin" or role.name == "Jr. Admin" or role.name == "Sr. Mod" or role.name == "Mod" or role.permissions.administrator:
            has_perms = True
        if has_perms:
            if "ticket" in ctx.channel.name:
                    db = await aiosqlite.connect('database.db')
                    cursor = await db.execute("SELECT user_ids FROM tickets WHERE user_ids=?", (ctx.author.id,))
                    rows = await cursor.fetchone()
                    if rows is None:
                        cursor = await db.execute('INSERT INTO tickets VALUES (?,?);', (ctx.author.id, 1))
                        await db.commit()
                        await db.close()
                        await ctx.send(f'{ctx.author.mention} will be assisting you today.')
                        return
                    else:
                        cursor = await db.execute('UPDATE tickets SET number=number + ? WHERE user_ids=?', (1, ctx.author.id))
                        await db.commit()
                        await db.close()
                        await ctx.send(f'{ctx.author.mention} will be assisting you today.')
                        return
            else:
                await ctx.send(f"{ctx.author.mention}, this isn't a ticket!", delete_after=5)
                return
        else:
            await ctx.send(f"{ctx.author.mention}, you don't have permission!", delete_after=5)
            return``` The ```py
        else:
            await ctx.send(f"{ctx.author.mention}, you don't have permission!", delete_after=5)``` meaning I don't have permissions, which I do.
slate swan
slate swan
slate swan
slate swan
slate swan
slate swan
slate swan
#

Yeah i figured

#

Idrk because i wouldn't use a dict as a db as it always gets cleared after you restart your terminal

visual island
slate swan
visual island
#

show how banList looks like

slate swan
#

you say

dict = {"ban": { "player":"97724" }}
#

?

slate swan
visual island
#

hmm, it shows that i is a dict in your error and banList is a list not a dict

slate swan
visual island
#

show your banList it should be a list as in the error

slate swan
visual island
#

what, your error says its list

visual island
slate swan
#

In the disnake support server it says when your going to download disnake to delete dpy and leave disnake why is that so?

#

Maybe name errors?

slate swan
#

Idk does it work

slate swan
#

As it works as normal and as intended

#

Maybe

#

Yeah

slate swan
#

They say not to forget to uninstall dpy but no reason is given and i will like to know why?

kindred epoch
#

Because disnake has different things than discord.py

pliant gulch
#

But that shouldn't matter

#

You access disnake things through disnake and you access discord.py things through discord

slate swan
#

Yeah thats my point

#

Why exactly

pulsar shell
#

equenos

slate swan
pulsar shell
#

Srry I meant to send that in google chrome search engine

slate swan
dark pawn
#

im using replit and their database. for some reason when i reset my database and initialize some data into it, i have to rerun my code 2 more times before it pulls the data out correctly

#

anyone heard of this before?

hollow agate
#
@client.command()
async def mute(ctx, member: discord.Member, time=None, *, reason=None):
    format = datetime.now(tz=pytz.timezone('America/Tijuana'))
    formatted = format.strftime("%I:%M %p")
    b = DT.datetime.now().timestamp()
    modlogs = client.get_channel(872909569196707870)
    db = await aiosqlite.connect('database.db')
    cursor = await db.execute('SELECT * FROM mutes')
    rows = await cursor.fetchall()
    muted = discord.utils.get(ctx.guild.roles, name="Muted")
    farmer = discord.utils.get(ctx.guild.roles, name="Farmers")
    apprentice = discord.utils.get(ctx.guild.roles, id=907127783849861120)
    if ctx.message.author.guild_permissions.administrator:
        if member is None:
            e = await ctx.reply('You must mention someone to mute!')
            await asyncio.sleep(5)
            await e.delete()
            await ctx.message.delete()
            return
        if time is None:
            a = await ctx.reply('Please state a time for a timed mute or a reason for a permanent mute!')
            await asyncio.sleep(5)
            await a.delete()
            await ctx.message.delete()
            return
        if reason is None:
            if time[-1] in ['s', 'm', 'h', 'd']:```

So, when I use 
.mute @hollow agate Spam Bot
It thinks that it's `if time[-1] in ['s', 'm', 'h', 'd']:` thing, what's the best way to fix this?
hollow agate
slate swan
#

If its a server scale bot you would be fine but if you choose to expand to multiserver that would be ideal

#

Hi

#
@bot.listen("on_message")
async def o(ctx):
    if ctx.reference == "D":
        await ctx.channel.send("Thanks for the reply!")
```So I want my discord bot to say Something when someone replies to my bot's msgs except it must be specifically a "D". So far this is my code, which obviously doesnt work. How can I fix this?
#

does anyone know how to get rid of the inbuilt help command?

#

Yes I know

#

i made am embedded help command myself but dont know how to get rid of the othher 1

slate swan
#

bot.remove_command("help")

#

Both work

#

thanks guys

#

Yw

#

Yow

slate swan
#

Nah already fixed

#

Alr

#

But thanks for trying to help tho

#

Yw ig

#

Yw?

#

Yw=Your welcome

#

Ohhh

#

I'll use them for the good then

shrewd chasm
#
from discord.ext import commands
from discord.ext.commands import Bot
import asyncio

client = commands.Bot(command_prefix='#', intents = discord.Intents.all())

@commands.command()
async def bruh(ctx):
     await ctx.send(file=discord.File('text.txt'))



client.run('token')```

I want my Discord bot send a text file but I got error command not found
Can I know what's wrong here? Thanks
slate swan
slate swan
#

To this day I still don't know how to fix it

slate swan
#

No need for that import

#

Ohhh

#

Command not found

#

And dont call your bot instance client

slate swan
#

Not no file or directory

#

Wow

#

Because if its not its @client.command()

#

Now I know,I can now live happily

slate swan
shrewd chasm
slate swan
#

Then why add a cog decorator?

#

Ofc it will send the error if its not a cog

shrewd chasm
slate swan
#

Sad

slate swan
shrewd chasm
dapper cobalt
humble compass
#

i installed discord and checked the list and it was there but i import discord into vsc and it says Import "discord" could not be resolved

#

ive coded before on windows 10 is it a problem if im on 11?

dapper cobalt
#

It's an issue with Visual Studio Code. Just reload the window and it will work. If you're on windows, click ctrl + p then, choose Developer: window reload.

dapper cobalt
humble compass
#

Alright thanks I’ll try

#

What do I do now?

dapper cobalt
#

I believe ctrl p opens the commands list? Anyhow, to get away from this hassle, just restart visual studio code.

humble compass
#

Alright thanks

#

😊

vast gale
#

python.analysis.restartLanguageServer

dapper cobalt
vast gale
#

got sick of restarting my terminal lol

pliant gulch
#

So it was an LSP problem? Back when I used VSC I just switched the python interpreter and that seemed to fix it, although I might have experienced a different issue then what is happening here

humble compass
#

im tryna use channel.send for a png but it just says "channel" is not defined. ik what it means but how do i define it?

hollow agate
#
@client.command()
async def someone(ctx, member: discord.Member, time: typing.Optional[TimeConverter] = None, *, reason=None):
    format = datetime.now(tz=pytz.timezone('America/Tijuana'))
    formatted = format.strftime("%I:%M %p")
    b = DT.datetime.now().timestamp()
    modlogs = client.get_channel(872909569196707870)
    db = await aiosqlite.connect('database.db')
    cursor = await db.execute('SELECT * FROM mutes')
    rows = await cursor.fetchall()
    muted = discord.utils.get(ctx.guild.roles, name="Muted")
    farmer = discord.utils.get(ctx.guild.roles, name="Farmers")
    apprentice = discord.utils.get(ctx.guild.roles, id=907127783849861120)
    if ctx.message.author.guild_permissions.administrator:
        if member is None:
            e = await ctx.reply('You must mention someone to mute!')
            await asyncio.sleep(5)
            await e.delete()
            await ctx.message.delete()
            return
        if time is None:
            e = await ctx.reply('You must state a time/reason!')
            await asyncio.sleep(5)
            await e.delete()
            await ctx.message.delete()
            return
        else:
            if time == 0:
                await ctx.reply(reason)``` When i run the command

.mute @hollow agate Spam Bot

it returns reason as `Bot`, how would I make the reason be the full reason rather than the reason after the first word?
dapper cobalt
dapper cobalt
#

Just add an extra word to the reason.

hollow agate
#

Is there any way around this?

#

I want it to be just a simple command rather than be annoying if you feel me.

.mute @hollow agate Testing Stuff
rather than
.mute @hollow agate Testing Testing Stuff

maiden fable
humble compass
#

so i was trying to make a chatbot. it works, but it shows all of this.

#

someone said you have to index list and dict but idk how to do that im rlly new

#

any help? im using code with swastik's code btw

maiden fable
humble compass
#

how do i check? i think its randomstuff

maiden fable
#

Oh, hmm

humble compass
#

yeah

pliant gulch
#

Seems like the API returns a dict, which means you can do dict["key"] to get the value of key

#

So if I wanted message, I would do data["message"]

#

Although, since the dict is inside of a list you first need to access the first element

#

Which you would do again with square brackets

#

Indexes start at 0

humble compass
#

would you like me to show my code?

hollow agate
maiden fable
humble compass
#
from prsaw import RandomStuff

bot = commands.Bot(command_prefix=">")
api_key = "my api key"
rs = RandomStuff(async_mode = True, api_key = api_key)

@bot.event
async def on_message(message):
    if bot.user == message.author:
        return

    if message.channel.id == chennel id:
        response = await rs.get_ai_response(message.content)
        await message.reply(response)
    
    await bot.process_commands(message)


TOKEN = "my token"
bot.run(TOKEN)```
slate swan
#

Is there a way to get access to a users Custom Status? I‘m not talking about the Online, brb, dnd, offline Statusses. I‘m talking about those where you can input an emoji aswell. Can I ger acces to that status by a bot?

pliant gulch
unkempt canyonBOT
#

property activity: Optional[Union[discord.activity.Activity, discord.activity.Game, discord.activity.CustomActivity, discord.activity.Streaming, discord.activity.Spotify]]```
Returns the primary activity the user is currently doing. Could be `None` if no activity is being done.

Note

Due to a Discord API limitation, this may be `None` if the user is listening to a song on Spotify with a title longer than 128 characters. See [GH-1738](https://github.com/Rapptz/discord.py/issues/1738) for more information.

Note

A user may have multiple activities, these can be accessed under [`activities`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member.activities "discord.Member.activities").
maiden fable
#

!d discord.CustomActivity

unkempt canyonBOT
#

class discord.CustomActivity(name, *, emoji=None, **extra)```
Represents a Custom activity from Discord.

x == y Checks if two activities are equal.

x != y Checks if two activities are not equal.

hash(x) Returns the activity’s hash.

str(x) Returns the custom status text.

New in version 1.3.
slate swan
#

isnt this only the „Playing/watching“ thing?

maiden fable
jaunty terrace
#

What language is rs?

maiden fable
jaunty terrace
#

Oops, forgot to go to off topic channel

jaunty terrace
hollow agate
maiden fable
hollow agate
#

No? I want to change Test Test to Test Test :P

sullen shoal
#

bruh what

slate swan
#

Am i tripping?

hollow agate
#

Oml.

slate swan
#

Test Test == Test Test

sullen shoal
#

!e print("hello world".title())

unkempt canyonBOT
#

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

Hello World
sullen shoal
#

this?

slate swan
sullen shoal
hollow agate
#
@client.command()
async def someone(ctx, member: discord.Member, time: typing.Optional[TimeConverter] = None, *, reason=None):
    format = datetime.now(tz=pytz.timezone('America/Tijuana'))
    formatted = format.strftime("%I:%M %p")
    b = DT.datetime.now().timestamp()
    modlogs = client.get_channel(872909569196707870)
    db = await aiosqlite.connect('database.db')
    cursor = await db.execute('SELECT * FROM mutes')
    rows = await cursor.fetchall()
    muted = discord.utils.get(ctx.guild.roles, name="Muted")
    farmer = discord.utils.get(ctx.guild.roles, name="Farmers")
    apprentice = discord.utils.get(ctx.guild.roles, id=907127783849861120)
    if ctx.message.author.guild_permissions.administrator:
        if member is None:
            e = await ctx.reply('You must mention someone to mute!')
            await asyncio.sleep(5)
            await e.delete()
            await ctx.message.delete()
            return
        if time is None:
            e = await ctx.reply('You must state a time/reason!')
            await asyncio.sleep(5)
            await e.delete()
            await ctx.message.delete()
            return
        else:
            if time == 0:
                await ctx.reply(reason)```  Is my code currently. I want the reason to just be `Spam Bot`

For this command to work, you do 

.mute @hollow agate Spam Bot

It then puts `Bot` as the reason, so I'm confused on how I can make `Spam` be included into the reason somehow.
sullen shoal
#

run a for loop

hollow agate
maiden fable
unkempt canyonBOT
#

str.count(sub[, start[, end]])```
Return the number of non-overlapping occurrences of substring *sub* in the range [*start*, *end*]. Optional arguments *start* and *end* are interpreted as in slice notation.
sullen shoal
#

i was talking to okimii

hollow agate
#

Ah

brave vessel
unkempt canyonBOT
#

@brave vessel :white_check_mark: Your eval job has completed with return code 0.

Hello world!
brave vessel
#

this converts title case to sentence case ^^

#

oh wait you weren't asking how to do that lol

maiden fable
#

Huh? They wanted to know how to prevent repeated words lol

slate swan
#

Yeah

brave vessel
#

sorry, I got confused

maiden fable
hollow agate
#

Well, not exactly. I guess.

slate swan
maiden fable
unkempt canyonBOT
#

@maiden fable :white_check_mark: Your eval job has completed with return code 0.

3
hollow agate
#

Time is removing the Spam and I somehow need make it to where it's not removed.

maiden fable
#

O

spring flax
#

first of all
I suggest not making a connection to your database on each command @hollow agate

maiden fable
#

You really can't fix it ngl

hollow agate
hollow agate
slate swan
hollow agate
#

M- welp.

slate swan
maiden fable
#

Ofc slash commands are there tho

hollow agate
#

How does Dyno and other bigger bots do it? I know they don't use python, but there must be a way.

maiden fable
slate swan
maiden fable
slate swan
maiden fable
#

So I don't really know how they do it, but it's related to some typing annotations related

spring flax
#

wait

maiden fable
spring flax
#

what's happening?

slate swan
spring flax
#

the reason you are putting is going into the time argument?

maiden fable
#

Not talking to you sorry

slate swan
spring flax
#

so why not typehint to int?

maiden fable
#

Anyways I'mma go play some CoD, catch y'all later

spring flax
#

wait one second

slate swan
sullen shoal
#

dang typing code on mobile is so ficking annoying

spring flax
lapis socket
#

I got till here

@client.event
async def on_message(message):
  if message.author == client.user:
    return

  if message.content('$typewrite ') ```

I want the bot to type a message in a specified channel.
#

Would go like this: "$typewrite (channel) (message)

hollow agate
quick gust
slate swan
slate swan
sullen shoal
slate swan
slate swan
sullen shoal
#

but im still gonna do it

lapis socket
slate swan
slate swan
#

Works the same

slate swan
slate swan
slate swan
#

how to resolve this?

AttributeError: 'Member' object has no attribute 'VoiceState'```
slate swan
slate swan
slate swan
slate swan
#

ok ?

slate swan
#

Im not a "god" tbh

slate swan
#

tokhm dari bya iran

slate swan
spring flax
slate swan
#

wait, changing to vsc

#

Don't really know about vc relates stuff

hollow agate
sullen shoal
#

hm i will do it when im on my pc, mobile sucks

slate swan
#

how to resolve this

#
  File "D:\acrella\bot.py", line 1373, in <module>
    bot.notes[guild.id] = {}
AttributeError: 'Bot' object has no attribute 'notes'
[Finished in 2.7s]```
#

¯_(ツ)_/¯

spring flax
#

@slate swan the full error would be better

slate swan
#

neverminddd

spring flax
#

@slate swan uhmm how did you get notes

slate swan
#

File "C:\Users\Bruh\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)

#

im silly, it was bot.notes = {}

slate swan
#

forgot

#

!traceback @slate swan

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.

A full traceback could look like:

Traceback (most recent call last):
    File "tiny", line 3, in
        do_something()
    File "tiny", line 2, in do_something
        a = 6 / b
ZeroDivisionError: division by zero

The best way to read your traceback is bottom to top.

• Identify the exception raised (in this case ZeroDivisionError)
• Make note of the line number (in this case 2), and navigate there in your program.
• Try to understand why the error occurred (in this case because b is 0).

To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.

slate swan
#
hm = 1
@blue.command()
async def ticket(ctx):
    conn = sqlite3.connect('test.sql')
    c = conn.cursor()
    amount = 150
    player = ctx.author
    c.execute(f"UPDATE data SET balance = balance-{amount} WHERE ID = {player.id}")
    c.execute(f"UPDATE data SET blue_ticket = +{hm} WHERE ID = {player.id}")
    conn.commit()
    conn.close()
    await ctx.send('Item Purchased Successfully')```
sooo the command is removing balance and adding 1 item in the column its just used repeatedly its not more than 1 value help please
#

any1?

spring flax
slate swan
#

i purchased item 5 times and the value in the column is 1

slate swan
spring flax
#

Two things. I suggest using aiosqlite as it's not blocking

#

!blocking

unkempt canyonBOT
#

Why do we need asynchronous programming?
Imagine that you're coding a Discord bot and every time somebody uses a command, you need to get some information from a database. But there's a catch: the database servers are acting up today and take a whole 10 seconds to respond. If you do not use asynchronous methods, your whole bot will stop running until it gets a response from the database. How do you fix this? Asynchronous programming.

What is asynchronous programming?
An asynchronous program utilises the async and await keywords. An asynchronous program pauses what it's doing and does something else whilst it waits for some third-party service to complete whatever it's supposed to do. Any code within an async context manager or function marked with the await keyword indicates to Python, that whilst this operation is being completed, it can do something else. For example:

import discord

# Bunch of bot code

async def ping(ctx):
    await ctx.send("Pong!")

What does the term "blocking" mean?
A blocking operation is wherever you do something without awaiting it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts.

async libraries
The standard async library - asyncio
Asynchronous web requests - aiohttp
Talking to PostgreSQL asynchronously - asyncpg
MongoDB interactions asynchronously - motor
Check out this list for even more!

slate swan
#

hmmm what is key?

#

ohh

#

any way to take inputs from a person on discord.py?

sage otter
#

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

ty

velvet tinsel
#

event must be "message"

brave flint
#

why it give An error occurred: Command raised an exception: AttributeError: 'Utility' object has no attribute 'member'

velvet tinsel
#

it's because "Utility" has no attribute called "member" and you still used it

#

I don't see anything. You may have not sent the full code.

brave flint
#

wait

brave flint
ruby thorn
#

Hello! By chance, does anyone know why I am receiving a AttributeError: 'Command' object has no attribute 'CommandNotFound' error when I copied it exactly from a tutorial video. I am trying to add an error message that responds to the user that types a command that is not programmed into the bot (yet, optionally). Here is the code that I have for example.

velvet tinsel
velvet tinsel
brave flint
velvet tinsel
slate swan
#

you wont learn anything that way

velvet tinsel
ruby thorn
#
from discord.ext import commands

TOKEN = '(token)'

client = commands.Bot(command_prefix = 'it')
client.remove_command('help')


@client.event
async def on_ready():
    print('{0.user} is now online!'.format(client))

@client.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandNotFound):
        await ctx.send(f'This is not a command.  If you have an idea for a command, you can tell Finami and suggest it!')

@client.command()
async def ping(ctx):
    await ctx.send(f'Pong! `{round(client.latency * 1000)}ms`')

@client.command()
async def info(ctx):
    await ctx.send(f'I am a bot created by Finami!  He uses Python so that I can output any command that you do!')

@client.command()
async def isee(ctx):
    await ctx.send(f'https://tenor.com/9uWN.gif')

@client.command()
async def help(ctx):
    await ctx.send(f'If you have ran into a problem with your device and are looking for troubleshooting assistance, check out [#908222838706667560](/guild/267624335836053506/channel/908222838706667560/) to check out how I work, what I can do and what I cannot do.  Then, move over to the [#907920566349090876](/guild/267624335836053506/channel/907920566349090876/) channel and open a new ticket to request assistance!')

@client.command()
async def commands(ctx):
    await ctx.send(f'ping\ninfo\nisee\nhelp\nspecs\ncommands (This is what you are looking at right now. -_-)')

@client.command()
async def specs(ctx):
    await ctx.send(f'My personal PC:\nIntel i5-6600\nNvidia GTX 1060 (3 GB version)\n8 GB DDR3 2133 Mhz RAM\n4 TB HDD\n1 TB SSD\n250 GB SSD')


client.run(TOKEN)```
ruby thorn
brave flint
velvet tinsel
#

not how you learn

#

that's exactly how you got the error.

brave flint
velvet tinsel
ruby thorn
velvet tinsel
#

I think you need to add that

velvet tinsel
#

next time don't just copy off a tutorial

brave flint
#

i cant copy whole file right

velvet tinsel
ruby thorn
velvet tinsel
#

wait you did

pliant gulch
#

The error is due to the command you registered named “commands”

ruby thorn
#

Yeah I did.

pliant gulch
#

Change the name of that to something else

velvet tinsel
#

use a getattr

velvet tinsel
velvet tinsel
ruby thorn
#

Is it one of the commands that I have programmed and its confused?

pliant gulch
visual island
visual island
#

and change the func name to _commands or something

brave flint
#

like when i made its cogs

velvet tinsel
velvet tinsel
ruby thorn
#

wait, crap, I have it to take the info from the discord.ext and import the commands module.

brave flint
velvet tinsel
#

I was looking at the wrong bit of the StackOverflow question

ruby thorn
#

Then I use the commands module to tell me to use this prefix.

velvet tinsel
#

you don't need to fully remove it

#

"Commands in a cog are still methods of an instance of the cog. The first argument passed to them is always the instance"

brave flint
#

hmmm

ruby thorn
brave flint
#

i think thats not the problem

velvet tinsel
pliant gulch
#

You have a command that is named “commands”, I'm asking you to rename it which would then fix the error you are getting

velvet tinsel
ruby thorn
brave flint
pliant gulch
#

Look at your client.command(), stuff you'll find one that decorates a function of which is named “commands” rename it to something else

velvet tinsel
#

you can try it out to see if it works. If not, I don't really know :/

pliant gulch
#

That's shadowing the commands module which is causing the error, like I said earlier

pliant gulch
#

👍

velvet tinsel
#

happy days

ruby thorn
#

I'll have to add an exception in order for me to format the word "commands" to use it as a command on my server or something.

pliant gulch
#

No you can just pass an alias to the command decorator

#

The alias would be “commands”

ruby thorn
# pliant gulch The alias would be “commands”

oh ok. I don't think I have heard of that element before but of course, I learned python from MC and learning it from a text book which has different elements than a video or a book that is involved with programming a discord bot.

pliant gulch
ruby thorn
pliant gulch
#

Yes, if you take a look at the bottom of the message I just sent you can see me doing that

ruby thorn
visual island
#

hi, is there a way to get the raw annotations of the argument given? For example i have a command:

async def a(ctx, arg, arg2):

and if I invoked it like a 1 hi, can I somehow get {arg: 1, arg2: "hi"} from the Context?

pliant gulch
#

!d discord.ext.commands.Context.args

unkempt canyonBOT
brave flint
#

how to get bot avatar url?, used bot not client, arl tried
bot.user.avatar_url

visual island
wary ice
#

Good evening I want to put on the mnm that the bot sends to Ticket to have an emoji 🔒 and go and close it but it does not do why does it not have the emoji?

velvet tinsel
pliant gulch
bitter depot
#

:lock: is a standard emoji, meaning every user (including bots) has it

pliant gulch
wary ice
velvet tinsel
velvet tinsel
#

🔒

#

🤷‍♂️

bitter depot
#

That's it

velvet tinsel
bitter depot
#

Or unicode or whatever fancy way, but :lock: will work too

velvet tinsel
#

🔒

#

🔓

visual island
#

oh and also, I have the first image in donation.py and second in main.py and this both prints the same id which is 1889934034768? Python also makes the a to the same value of LT where it should not

brave flint
#

oh nvm i get it

visual island
wary ice
velvet tinsel
velvet tinsel
#

like what tiggy said

wary ice
#
async def close(reaction, user):
    if reaction.message.channel.name.startswith("ticket"):
        if(reaction.emoji == "👋"):
            await reaction.message.channel.delete()```
wary ice
#

where

velvet tinsel
#

I forgot how to use the !d command 😢

wary ice
#

what am I doing

velvet tinsel
visual island
# velvet tinsel show the code for the class please.
from ext.errors import UnexpectedArgument


class LiteralMeta(type):
    """A metaclass for custom Literal"""
    def __getitem__(self, item):
        self.values = item
        return self


class Literal(metaclass=LiteralMeta):
    """A class for custom Literal"""
    @classmethod
    async def convert(cls, ctx, argument):
        """Converts the argument to any of the exact value given"""
        if argument in cls.values:
            return argument
        raise UnexpectedArgument(f"\"{argument}\" is not a valid argument. "
                                 f"Possible argument(s): {', '.join(cls.values)}")
``` not much
wary ice
#

what to see from there most of all?

velvet tinsel
velvet tinsel
slate swan
#

java sucks

velvet tinsel
bitter depot
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**...
visual island
velvet tinsel
#

ty

bitter depot
#

I assume that's what you wanted

velvet tinsel
wary ice
#
async def close(reaction, user):
    if reaction.message.channel.name.startswith("ticket"):
        wait_for ('reaction')
            await reaction.message.channel.delete()
#

this ??? who ?

slate swan
#

What is "ty" ||(i'am brazilian)||

velvet tinsel
velvet tinsel
visual island
slate swan
velvet tinsel
visual island
visual island
velvet tinsel
grim oar
#

but why tho pithink

velvet tinsel
visual island
#

*and don't force me to use 2.0

velvet tinsel
visual island
velvet tinsel
#

or just read the code for typing.literal

velvet tinsel
visual island
velvet tinsel
#

No idk the answer, try claiming a help channel 😦

visual island
#

okay wait

digital forge
#

is it possible to make an account a bot

maiden fable
digital forge
maiden fable
digital forge
maiden fable
#

Not u

maiden fable
visual island
maiden fable
#

I know my answers, thanks

visual island
#

19

maiden fable
digital forge
velvet tinsel
#

self botting is against the ToS of discord.

visual island
maiden fable
maiden fable
velvet tinsel
#

!ot

unkempt canyonBOT
velvet tinsel
#

got there before you >:)

#

I'm good at this now

digital forge
#

is there any other library for making discord bots other than discord.py

sullen shoal
#

yeah

pliant gulch
velvet tinsel
sullen shoal
sullen shoal
velvet tinsel
#

stop being so smart myxi 😭

sullen shoal
#

: |

grim oar
#

i will never understand typing stuff ¯\_(ツ)_/¯

slate swan
#

How do I make my bot down like be invisible

velvet tinsel
slate swan
#

My code is stopped but the bot still have an online status

#

How do I stop this

grim oar
#

it will go down eventually

slate swan
#

Oh ok

velvet tinsel
velvet tinsel
slate swan
#

Hmm ok then

opal skiff
#

how do i get the profile pic url of the message author?

grim oar
#

str(message.author.avatar_url)

opal skiff
#

ok

maiden fable
grim oar
#

Wrong for 2.0

maiden fable
#

If u r using 2.0, then message.author.avatar.url

opal skiff
#

ok ty

maiden fable
#

Yea

opal skiff
#

how do i start a thread on a message?

slate swan
#

Guys

#

How do I make a 15 sec cooldown of a command?

visual island
#

!d discord.ext.commands.cooldown

unkempt canyonBOT
#

@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")

A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").

If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.

A command can only have a single cooldown.
visual island
#

pass per to 15

serene lynx
#
Ignoring exception in on_ready
Traceback (most recent call last):
  File "d:\dittttbeta\env\lib\site-packages\discord\client.py", line 359, in _run_event
    await coro(*args, **kwargs)
  File "d:\dittttbeta\database\prefix.py", line 19, in on_ready
    await aiopg.create_pool("dbname=prefix user=postgres password=083806637610")
  File "d:\dittttbeta\env\lib\site-packages\aiopg\pool.py", line 296, in from_pool_fill
    await self._fill_free_pool(False)
  File "d:\dittttbeta\env\lib\site-packages\aiopg\pool.py", line 332, in _fill_free_pool
    conn = await connect(
  File "d:\dittttbeta\env\lib\site-packages\aiopg\connection.py", line 65, in connect
    connection = Connection(
  File "d:\dittttbeta\env\lib\site-packages\aiopg\connection.py", line 746, in __init__
    self._loop.add_reader(self._fileno, self._ready, self._weakref)  # type: ignore
  File "C:\Users\andan\.pyenv\pyenv-win\versions\3.9.6\lib\asyncio\events.py", line 504, in add_reader
    raise NotImplementedError
NotImplementedError
Exception ignored in: <function Connection.__del__ at 0x0000020EC7AE2040>
Traceback (most recent call last):
  File "d:\dittttbeta\env\lib\site-packages\aiopg\connection.py", line 1140, in __del__
    self.close()
  File "d:\dittttbeta\env\lib\site-packages\aiopg\connection.py", line 961, in close
    self._close()
  File "d:\dittttbeta\env\lib\site-packages\aiopg\connection.py", line 945, in _close
    self._loop.remove_reader(self._fileno)
  File "C:\Users\andan\.pyenv\pyenv-win\versions\3.9.6\lib\asyncio\events.py", line 507, in remove_reader       
    raise NotImplementedError
NotImplementedError:```
#

why is this?

opal skiff
#

how do i add a timestamp to an Embed?

spring flax
#

!d discord.Embed.timestamp

unkempt canyonBOT
#

The timestamp of the embed content. This is an aware datetime. If a naive datetime is passed, it is converted to an aware datetime with the local timezone.

spring flax
#

@opal skiff ^

opal skiff
#

ok ty

slate swan
opal skiff
# spring flax <@!772386889817784340> ^

await message.channel.send(embed=discord.Embed(color=0xe74c3c,title="Poll",description=message.content.replace("T!poll",""),author=message.author).set_author(name=message.author,icon_url=message.author.avatar_url).timestamp(datetime.datetime)) it doesnt work

spring flax
#

wow

#

uh okay let me see

#

timestamp(datetime.datetime()))

slate swan
#

it's datetime.datetime.now() , or any datetime object

#

Not just the class

opal skiff
#

ok ty

#

TypeError: '_EmptyEmbed' object is not callable i get this error with discord.Embed.timestamp(datetime.datetime.now())

spring flax
#

oh wait

opal skiff
# spring flax what's the code you put?

await message.channel.send(embed=discord.Embed(color=0xe74c3c,title="Poll",description=message.content.replace("T!poll",""),author=message.author).set_author(name=message.author,icon_url=message.author.avatar_url).timestamp(datetime.datetime.now()))

visual island
#

<@&831776746206265384>

bitter depot
opal skiff
spring flax
visual island
opal skiff
# spring flax can i see the whole command? Just curious
        await message.delete()
        awaitpoll = True
        await message.channel.send(embed=discord.Embed(color=0xe74c3c,title="Poll",description=message.content.replace("T!poll",""),author=message.author).set_author(name=message.author,icon_url=message.author.avatar_url).timestamp(datetime.datetime.now()))```
normal folio
#

is there any way to get from last command specific message part?

opal skiff
spring flax
bitter depot
opal skiff
spring flax
opal skiff
bitter depot
spring flax
#

it's not efficient

opal skiff