#discord-bots

1 messages ยท Page 476 of 1

slate swan
#

mkay

#

im new sooo yuhh

#
        print('Logged on as', self.user)```
wicked atlas
#

The statuscheck file, which I assume is the first one, is a blocking file. It has an infiinite while loop, that it never breaks from. Once you import the file, it will never continue past that import

zinc flame
#

And yes, it's the first one

wicked atlas
#

You're going to want to modify your code a bit to use non-blocking loops so that they run at the same time. You can use discord.py's task system for this

zinc flame
#

Ohhhh, I see what you're saying. The while loop never lets the bot function run at all. It never gets passed it

wicked atlas
#

the time.sleep also will cause an issue should you decide to use tasks

#

If you decided to use tasks, switch to asyncio.sleep

#

but the tasks should take care of looping and intervals for you

zinc flame
#

Gotcha. I'll start reading up on it. Thank you

slate swan
#

@wicked atlas is "pip install python-dotenv" the right one?

wicked atlas
rugged tinsel
#

hey how do you make a fun fact bot

#

it will choose a random message from the list that i will put??

boreal ravine
#

yes an api

visual island
#
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from ext.context import Context

# the command
    @commands.command()
    async def invite(self, ctx: "Context", member: discord.Member) -> None:
        ...
```so the problem here was 
```py
    self.params[key] = value = value.replace(annotation=eval(value.annotation, function.__globals__))
  File "<string>", line 1, in <module>
NameError: name 'Context' is not defined

```it seems that I cant use import in `typing.TYPE_CHECKING`  for type hinting `Context`?
wicked atlas
#

the discord.py Context object should be imported like this

from discord.exts.commands import Context
#

Or, you can use it like this

from discord.exts import commands
ctx: comands.Context
visual island
#

*I used my custom Context

wicked atlas
#

I believe you might have an error though, since you are using self, but it looks like it's outside of a class

visual island
#

nah, it's just to show the command

#

i have a long class tho

#

that's why I dont include it there in my code

rough flicker
#

can someone please help me?

#

it wont send the Hello! in the server after i type !hello

slate swan
# rough flicker

okay first of all you havent set a server prefix, which you must do

rough flicker
#

uhm...how?

slate swan
# rough flicker

second of all, your if message.content.startswith('!hello'): is at the wrong indentation level

rough flicker
#

okay so bring it back one?

slate swan
slate swan
rough flicker
#

okay but also

#

even now it no work

slate swan
rough flicker
#

mhm!

slate swan
#

does it just not print anything?

rough flicker
#

WAIT

#

IT WORKED

slate swan
#

okay goodjob!

rough flicker
#

i just tested it like 5 seconds ago tho- maybe lag?

vale pendant
#

make a ping command to find out

slate swan
#

repl it is laggy

slate swan
#

just remember to set a server prefix in the future so that it will be easier to code in the future, and for other reasons

#

speaking of which, you might have to migrate so slash commands to make it worse

rugged tinsel
#

hey can someone help me with making my fun fact bot? like i want it to choose from the list i will pput

slate swan
rugged tinsel
#

oki

pliant raven
#

you can also import random

#

thats if you are using replit

#

im pretty sure

#

i only use replit so i dont know

slate swan
#

yes, but tbh please dont use fun fact lists HAHA imo they're either very laggy or do not have much facts

rugged tinsel
#

yeah im using import random for my coinflip command

#

i use replit

slate swan
#

especially if you have a few hundred items in ur list

rugged tinsel
slate swan
final iron
pliant raven
#

i have this block of code here

rugged tinsel
#

sorry sorry

rough flicker
#

at this point it works thank you

pliant raven
#

but the issue is it only appends the message straight after the command, nothing after it that has spaces

rugged tinsel
#

i have 4 days experience with replit but i think

#

u just

#

go to the um side bar i think its called

#

then you just search

final iron
pliant raven
#

oh ok

#

let me try that

final iron
#

The star will make it read everything after the command as newitem

red kraken
#

Help regarding dc.py


class graph_multi(commands.Cog):
    """The description for Bargraph goes here."""

    def __init__(self, bot):
        self.bot = bot

    @commands.command("!bar_multi")
    async def bar_multi(self, ctx, title: str, xl: str, yl: str, data: str):
        dbg = graph()
        data = data.split("#")
        ng = len(data)
        for i in range(len(data)):
            data[i] = data[i].split(",")
        keys = []
        values = []
        for i in range(len(data)):
            keys.append([])
            values.append([])

        for i in range(len(data)):
            for n in range(len(data[i])):
                if n % 2 == 0:
                    keys[i].append(data[i][n])
                else:
                    values[i].append(int(data[i][n]))
        if len(values) != len(keys):
            await ctx.send("The amount of keys and values are not the same")
        else:
            print(keys, values)
            dbg.barGraph(keys, values, title, xl, yl, ng)
            await ctx.send(file=discord.File('mygraph.png'))


def setup(bot):
    bot.add_cog(graph_multi(bot))

So i have this cog setup but its giving me this wrror

discord.ext.commands.errors.CommandNotFound: Command "bar_multi" is not found

And this is the bot code

from discord.ext import commands
import config

bot = commands.Bot(command_prefix="!")
bot.load_extension("cogs.graph_single")
bot.load_extension("cogs.graph_multi")


bot.run(config.TOKEN)
little ether
rugged tinsel
#

@red kraken can you help me with the code for making a fact bot?

red kraken
red kraken
rugged tinsel
#

oh that's alright ill ask another person

#

๐Ÿ˜„

kindred epoch
little ether
rugged tinsel
#

ok

midnight oyster
#

How can I get the title of an embed message if I have the message object?

kindred epoch
unkempt canyonBOT
kindred epoch
#

Use that

midnight oyster
#

thanks

grim oar
#

Use Embed.title attribute for getting the title

slate swan
#

message.embeds[0].title

drifting arrow
#

How would one do a tempban system? ๐Ÿค”

#

Like, what components would I need? I know I'd need the mentioned user and a role to slap on them that 'mutes' them.

#

the part I need to figure out is, the 'temp' part.

#

ideas?

slate swan
drifting arrow
#

What about asyncio? ๐Ÿค”

slate swan
drifting arrow
#

Why not?

slate swan
#

Because it's a sleep method

#

!d discord.ext.tasks.loop is better

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=0, minutes=0, hours=0, count=None, reconnect=True, loop=None)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/stable/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
drifting arrow
#

I ran a quick test and it doesn't stop the bot from receiving more commands

slate swan
#

It just isn't

sleek ore
rough flicker
#

hey uhm i have a code that sends Hello! whenever someone says !hello right? but i wanna be able to run multiple commands anyone happen to know how to do that?

rough flicker
#

yes

#

is there an alternative?

slate swan
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
slate swan
#

This is what we use as a command handler

rough flicker
#

okay

#

please tell me more

slate swan
#

You define async functions as commannds

#

Here's a tutorial to go through

rough flicker
#

okay

#

thanks!

#

for now though can you run me through this person to person?

#

how would i use the command to make this run multiple commands?

spring flax
#

example

rugged tinsel
#

can anyone help me with the code for the fact bot i want? please?

spring flax
# rough flicker
@bot.command() #this is the decorater
async def ping(ctx): #this is defining the command name and thea arguemnts in this case it is only ctx (Context)
  await ctx.send("Pong") #this sends "pong" to the channel the command was invoked in
rough flicker
#

okay

#

so by using this

#

whenever the bots command that i put gets typed into the chat

#

it will send Pong?

rugged tinsel
#

yes i can see just by looking

rough flicker
#

okay thanks!

#

OH MY GOD THAT HELPED SO MUCH

spring flax
#

if you command prefix is !
And you do !ping it will send pong

rough flicker
#

THANK YOU SO MUCHHHH!!!!!

rugged tinsel
#

@rough flicker first time?

rough flicker
#

mhm!

#

but with that it just like flew open so many doors

rugged tinsel
#

same but i started 4 days ago so i know a bit

rough flicker
#

OH

#

my friend requested the bot have a meme generator

spring flax
rough flicker
#

how could i set that up?

rugged tinsel
#

this is my first ever thing i put into the bot

#

@client.command(aliases=["Ping"])
async def ping(ctx):
await ctx.channel.send("Pong!")

spring flax
rough flicker
#

anywhere really

slate swan
rough flicker
#

just a random meme generator

slate swan
#

!d discord.ext.commands.Bot - all methods and attiributes for it

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
slate swan
#

!pypi requests

unkempt canyonBOT
rough flicker
#

walk me through it please?

slate swan
spring flax
#

are you going to be writing some facts down or using requests to get them?

rugged tinsel
spring flax
#

okay so

#
import random

#bot construction
async def fact(ctx):
  facts = #put your facts in a list here
  random_fact = random.choice(facts)
  await ctx.send(random_fact)
rugged tinsel
#

๐Ÿ˜ฎ ty

#

ill see if i get any errors

shell wing
#

I a server owner and im making a music bot for it..the bot works..i need 3 such bots...so i wanted to ask that can i run 3 bots from 1 single code ?

shell wing
drifting arrow
#
 @commands.command()
    @commands.has_any_role('bot','Bot','Owner')
    async def tempmute(self, ctx,  member : discord.Member, length = 60):
        senderrole = ctx.author.roles
        targetrole = member.roles
        guildroles = ctx.guild.roles
        
        senderroleindex = 0
        targetroleindex = 0
        for i in guildroles:
            for a in senderrole:
                if a == i:
                    if senderroleindex < guildroles.index(i):
                        senderroleindex = guildroles.index(i)
            for a in targetrole:
                if a == i:
                    if targetroleindex < guildroles.index(i):
                        targetroleindex = guildroles.index(i)

        if senderroleindex > targetroleindex:
            await ctx.send(f"Muted: {member.mention} for {length}seconds.")
            await member.add_role("test")
        elif senderroleindex == targetroleindex or senderroleindex < targetroleindex:
            await ctx.send("Cannot mute someone with the same or greater role than you.")

What am I doing wrong? I can't seem to add the role to the mentioned user.

rugged tinsel
#

it works ty diabloical

drifting arrow
#

Same issue

maiden fable
#

Cz it is member.add_roles

maiden fable
drifting arrow
#

do i have to get the role ID instead?

slate swan
shell wing
maiden fable
drifting arrow
#

gah so now I gotta get the "mute" role ;-;

shell wing
slate swan
#

Replit is just bad

#

Nothing more to say

shell wing
shell wing
maiden fable
#

There u go. A big tag warning

slate swan
#

You should not use Repl.it to host your bot.

While this may seem like a nice and free service, it has a lot more caveats than you might think, such as:

  • The machines are super underpowered.

    • This means your bot will lag a lot as it gets bigger.
  • You need to run a webserver alongside your bot to prevent it from being shut off.

    • This isn't a trivial task, and eats more of the machines power.
  • Repl.it uses an ephemeral file system.

    • This means any file you saved via your bot will be overwritten when you next launch.
  • They use a shared IP for everything running on the service.
    This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. *Including you.

https://intuitiveexplanations.com/tech/replit/

maiden fable
#

But yea, it's worth reading it

shell wing
#

oooo

#

so the lag and underpowered machines are same for premium users ?

maiden fable
#

Well, never used premium sooo idk

shell wing
#

ok

#

lol mind telling me how to run multiple bots from 1 code

slate swan
#

Make multiple bot instances

#

Bad practice and looks bad

#

Make separate project in different folder

shell wing
shell wing
#

how do they do this ??

shell wing
drifting arrow
#

alright now to make a database \o/

rugged tinsel
#

hey @spring flax when I put something random like bear in the code u sent it said bear was not defined. do u know how to fix this?

spring flax
#

Code?

rugged tinsel
#

yeah the one u sent me

#

the facts one

spring flax
#

Can i see it what you have

rugged tinsel
#

alright can u wait 2-3 min? im getting called

spring flax
#

Sure

rugged tinsel
#

dont mind my tabs

#

@spring flax

slate swan
#

They must be strings

#

You haven't defined any of these variables

#
["blah", "blah", ...]
#

The bare minimum of python knowledge is required

rough flicker
#

HEY!

#

can i get help?

rugged tinsel
rough flicker
#

my chat bot can take 1 word commands such as fine or bad right?

#

but i want it to be liek !im fine not just fine

#

cuz the input method is !fine not !im fine

rugged tinsel
#

what

slate swan
#

Make a command group

rough flicker
#

and i dont know how to set up multiple word commands

rugged tinsel
rough flicker
#

look

rugged tinsel
#

i dont get it

slate swan
# rugged tinsel dont mind my tabs

Read the error , also if you want to make your commands case insensitive , use case_insensitive=True in commands.Bot instead of using aliases

rugged tinsel
#

ok

rough flicker
rugged tinsel
#

ill set it like that

#

so u can only do

#

!hi and not !hi hello

#

is that what u mean?

rough flicker
#

no no

#

saw where i said Im good

#

and it didnt reply?

#

i want it to reply to that

rugged tinsel
#

oh

slate swan
#

How about just dropping the prefix and just reply based on message content. And set a channel where the bot can only answer.

rough flicker
#

mhm! cuz i want it to be a realistic chat bot

#

OH BIG BRAIN

#

HOW DO THAT I?

#

please tell me?

slate swan
unkempt canyonBOT
#

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

This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.

Warning

Your botโ€™s own messages and private messages are sent through this event. This can lead cases of โ€˜recursionโ€™ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
rough flicker
#

okay so .. now im thinking do you think if i set it so that you have to say demelos (the bots name) then the messege and i set replies to what you say .. it will work like that?

quasi pawn
#

why is command not found?

slate swan
quasi pawn
#

I see thanks

slate swan
#

how can i make it so an argument requires a link

pale turtle
#

Make a custom converter that checks with regex if the cpntent of the arg is a link

slate swan
#

csnt i just do if "https://" not in icon

#

No because then someone could just send hellohttps://hello

#

You can do
if argument.startswith("https")

#

But I suggest NIR's way

pale turtle
#

The hardest part is regex I guess

brisk helm
slate swan
#

And that's why there are already pre-made regex

vale pendant
#

by using commands.MissingRequiredArgument is there a way to tell what argument i'm missing?

pale turtle
#

!d discord.ext.commands.MissingRequiredArgument it is in the docs

unkempt canyonBOT
#

exception discord.ext.commands.MissingRequiredArgument(param)```
Exception raised when parsing a command and a parameter that is required is not encountered.

This inherits from [`UserInputError`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.UserInputError "discord.ext.commands.UserInputError")
pale turtle
#

Ptobably param

maiden fable
#

Dude, I had almost written it all

vale pendant
slate swan
maiden fable
maiden fable
slate swan
#

Vsc i guess

maiden fable
maiden fable
#

I want to know which one haha

stark bobcat
#

hlo

#

i know improper token but i gave it a correct token i swear

#

i even changed applications

spark estuary
#

hey guys i am a beginner in bot making and am stuck in my code so can someone pls check my error and help me?

slate swan
#

and try again

spark estuary
#

@slate swan can you help me with my code pls?

slate swan
#

YES

drifting arrow
stark bobcat
slate swan
maiden fable
maiden fable
slate swan
#

Oh

drifting arrow
#

Been busy figuring out how to do this db crap in python xD

slate swan
drifting arrow
#

My current issue is: figuring out how to convert a string that represents a datetime into a datetime xD

maiden fable
#

Haha!

slate swan
#

Good luck

drifting arrow
#

ty

#

I need to somehow convert: 2021-09-17 14:36:42.648345
into a datetime object

stark bobcat
#

now

#

i did this

drifting arrow
#

Alright

#

where did you get the token from?

slate swan
stark bobcat
stark bobcat
drifting arrow
#

oh

#

lol yeah i didnt see those

slate swan
#

bot.run(TOKEN)

stark bobcat
#

ok lemme try that

drifting arrow
#

So I've setup my command to tempmute someone.
setup my auto loop.
setup my database. Now for the fun part \o/ unmuting someone lol

quiet rain
stark bobcat
#

does nothing

#

i was testing my bot on replit because when i tried to host my bot on heruko my bot did not go online

lucid stream
lucid stream
#

yea that

#

lets see

stark bobcat
#

one min

#

thanks

#

i restarted replit and works

#

thanks

lucid stream
#

oh oki

quasi pawn
#

why is it sending in the console ?

slate swan
#

most probably because you didn't load the cog?

slate swan
#

And add self parameter

#

Instead of client.event

maiden fable
#

Also yr indent bro

late echo
#

It is is not Java script

#

@maiden fable

maiden fable
#

Yea?

late echo
#

It is python not Java script

maiden fable
lyric moat
#

why it gives an error?

@client.command()
async def emoji(ctx, emoji: Union[discord.Emoji, discord.PartialEmoji, str]):
    """Post a large size emojis in chat."""
    if not isinstance(emoji, str):  # if it is a custom discord emoji
        d_emoji = cast(discord.Emoji, emoji)
        ext = "gif" if d_emoji.animated else "png"
        url = d_emoji.url
        filename = f"{d_emoji.name}.{ext}"
    else:  # use the twitter emoji api
        try:
            cdn_fmt = "https://twemoji.maxcdn.com/2/72x72/{codepoint:x}.png"
            url = cdn_fmt.format(codepoint=ord(str(emoji)))
            filename = "emoji.png"
        except TypeError:
            return await ctx.send("That doesn't appear to be a valid emoji")
    try:  # read it with BytesIO so you dont need to save the image
        async with aiohttp.ClientSession() as session:
            async with session.get(url) as resp:
                image = os.BytesIO(await resp.read())
    except Exception:
        return await ctx.send("That doesn't appear to be a valid emoji")
    file = discord.File(image, filename=filename)
    await ctx.send(file=file)```
late echo
late echo
#

O

#

Ok

maiden fable
#

Also don't copy code from next time

maiden fable
late echo
#

Nothing my bad leave

maiden fable
#

-> There are intents in Python also ๐Ÿคฆ
-> I wrote indents, not intents

lyric moat
maiden fable
#

Haha it's fine. I just wanted to tell them that the indents are off

maiden fable
#

Also don't copy code please

zenith hare
#

how i can do fix this?

lyric moat
#

error again

        d_emoji = cast(discord.Emoji, emoji)
slate swan
#

import the library cast is from

#

then from (library) import cast

lyric moat
#

error

slate swan
#

most likely because you didnt import the library cast is from

maiden fable
#

What's the problem? I don't understand that language, sorry ๐Ÿ˜…๐Ÿ˜…

vale pendant
#

es espaรฑol creo

maiden fable
#

English Please

vale pendant
#

but itโ€™s just saying a invite was deleted and who the owner the invite is and how many uses

maiden fable
#

Ah

vale pendant
#

i believe they are not getting the owner nor uses which is the problem

maiden fable
#

Could be they don't have the intents

#

!d discord.Intents.invites

unkempt canyonBOT
vale pendant
#

most likely

zenith hare
#

ohh, i see, thank u guys

maiden fable
#

(:

soft galleon
#

hey, so im starting to learn how to split code into mulitple files without the use of Classes, but this type of error keeps happening:
bot not defined, any tips?

boreal ravine
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
soft galleon
#

no i did

boreal ravine
#

code?

soft galleon
#

its in my main file

#

but as i said i splitt code into multiple files

boreal ravine
#

yeah but you cant define bot from another file

soft galleon
#

this is the event_end.py file

async def event_end():
  code```
#

ok what i sent dont really help out muich

remote dock
#

Hey guys im having a problem with the bot joining the voice channel im in. It sends an error and doesnt join. Could someone help me?

soft galleon
boreal ravine
remote dock
#

wait let me send error first

#

@boreal ravine @maiden fable

rugged tinsel
quasi pawn
#

is it possible for a command to have a diff prefix from the other commands?

rugged tinsel
#

i dont think its possible

boreal ravine
spark estuary
#

hey guys i am learning how to make a discord bot so that it shows the current time....its working but can someone help me to change its timezone?

rugged tinsel
#

it sounds very intresting

spark estuary
rugged tinsel
#

ncc

spark estuary
remote dock
maiden fable
maiden fable
reef shell
#

It's not a discord bot related question , but anyways...
How can i activate those parallal lines in vis. studio code?

rugged tinsel
spark estuary
rugged tinsel
#

yeah

#

my goal is to have more than 150 commands ๐Ÿ™‚

spark estuary
#

nice

rugged tinsel
#

so yeah

spark estuary
remote dock
maiden fable
reef shell
rugged tinsel
remote dock
maiden fable
#

Ah its a different error

remote dock
#

oh ok

spark estuary
reef shell
#

there might be a timezone keyword

#

I'm not familiar with this doe

maiden fable
#

Get the voice channel object and do vc.connect

spark estuary
spark estuary
# rugged tinsel <@!470549314901377035>

new_message = datetime.now()
currentTime = new_message.strftime("%H:%M:%S")
if message.content.startswith('$time'):
await message.channel.send(f"Time{currentTime}")

rugged tinsel
#

tysm :>

spark estuary
reef shell
#

anyone else use vsc?

spark estuary
#

tz' and what not

rugged tinsel
#

@spark estuary i tried copying and pasting then writing it down but it still gave me an indentation error

reef shell
#

If you're trying to show the current time then there is an attribute for messages
created_at

spark estuary
rugged tinsel
#

hmm

spark estuary
#

put a apace after if

rugged tinsel
#

yeah i noticed that

#

the error still there tho

spark estuary
#

space before if and await

#

try that

rugged tinsel
#

yeah im done doing that

#

idk whats wrong

fathom hound
#

hi! is there any way to edit a message while preserving its original attributes?
for example, if i wanted to change the content='' argument, i would pass it in the discord.Message.edit() method, it would change only the message in the content attribute (leaving any other attributes, i.e embed, file, etc. untouched from the original message instead of resetting them).

maiden fable
#

Just tried it

fathom hound
#

ohh, right, tysm for the help
im not sure since how long its been that way, i couldve sworn it used to reset the whole thing, or maybe i am just being forgetful again haha

maiden fable
#

Ah, I also used to think it would remove everything, but seems like they updated it or something

fathom hound
#

yeah same, either way thanks a lot i really appreciate it

maiden fable
#

(:

edgy steppe
#

What your import looks like?
If it is import datetime

You should write yout first line as new_message = datetime.datetime.now()

stark bobcat
#
def check(m):
    return m.content == ['yes' , 'no']
     
    message = await bot.wait_for('message', check=check)
    if m.content=='yes':
       await ctx.send("ok")```
#

why doesn't this work

hasty iron
#

cuz message.content will never be a list

#

i think you meant in rather than ==

#

(check function)

stark bobcat
#

hm

stark bobcat
hasty iron
#

in rather than ==

#

im not sure what you donโ€™t understand there

stark bobcat
#

i will do that

#
        def check(m):
            return m.content in ['yes' , 'no']
        
        message = await bot.wait_for('message', check=check)
        if m.content=='yes':
            await ctx.send("ok")```
#

so this should work

#

it does not work

#

@hasty iron

willow vine
#

for reason commands aren't working for me

#

what do i do

hasty iron
slate swan
#

if its in a cog then self.bot

stark bobcat
#

wym

hasty iron
#

define it = define it

#

if you canโ€™t understand that you should learn english

willow vine
#

my code seems to be running without any errors, listener is working but not commands

#

anyone know what could be the reason?

#

nvm i deleted the process commands line

magic jasper
#

hi? how do i get the id of the button clicker -- discord components

slate swan
#

Hey i wanted to make a command that my bot sends the same message every 2 hours ive been researching how to do it but i didnt get it my only "working" command is sp!reminder "text" and he will send it everytime and i dont really want it to be like that so if someone could explain me how to do that it would be very nice! Thanks

vagrant brook
#

!d discord.ext.tasks.loop

unkempt canyonBOT
#

discord.ext.tasks.loop(*, seconds=0, minutes=0, hours=0, count=None, reconnect=True, loop=None)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/stable/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
vagrant brook
#

This would help ๐Ÿ™‚

boreal ravine
slate swan
boreal ravine
#

thanks

slate swan
#

sys.version or platform.python_version() <-- Python version

stark bobcat
#

how do i create a category at the end of all caterogry's

stone palm
#

is there any good youtube lib for discord?

stark bobcat
#

youtube_dl?

slate swan
#

is making a bot to spam 5 spam channels at the same time against tos??????!?!!?

lofty heron
#

um depends on context lol

#

but mostly yes

slate swan
#

its my server and my spam channels

lofty heron
#

then no lol

#

is there really a point

slate swan
#

5 minutes of spamming later....

lofty heron
#

๐Ÿ‘€

jolly glacier
slate swan
#

goog

lofty heron
#

anybody know how to print a unix timestamp using python kek

slate swan
#

15 minutes of spamming later...

#

about 3 minutes later

#

im heading to 1m messages

lofty heron
#

why??????????????????

vagrant brook
#

That's API abuse for sure

slate swan
#

@slate swan you should stop

#

You may get a warning from Discord.

boreal ravine
#

is it icon_url=url or icon.url=url in 2.0?

slate swan
#

It's like member.avarar.url, guild.icon.url

boreal ravine
slate swan
#

Not icon in the start

#

Oh no

#

The kwargs stay the same

boreal ravine
#

hm

reef shell
#

stop posting about it here

reef shell
boreal ravine
reef shell
boreal ravine
#

o

#

@slate swan stop pls its api abuse and no irrelevant messages herekthx

reef shell
#

we don't support or discuss about something that breaks ToS of any platform

stark bobcat
#

how do i know that my bot has been invited to a server

#

i want to create a channel in the server bot has invited to

lament mesa
unkempt canyonBOT
#

discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client "discord.Client") joins a guild.

This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
stark bobcat
timid ravine
lofty heron
#

does anybody know how to make a bot send a unix timestamp?
i tried await ctx.send (int(time.time()))

lament mesa
lofty heron
#

never mind

#

spelt time wrong ๐Ÿคฆโ€โ™‚๏ธ

#

big brein

stark bobcat
#

how do i make a category as the last category's of the category

red kraken
#

is buttons and gui elements available on discord.py?

hasty iron
#

yes

#

2.0 has them

red kraken
#

how to use that?

unkempt canyonBOT
hasty iron
#

ur just not using it

red kraken
#

Whats the pip?

hasty iron
#

for 2.0

red kraken
#

oooh

wide bloom
#

hi

wide bloom
valid niche
#

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

#

for 2.0 (master branch)

stark bobcat
#

why doesn't this work

#
@commands.Cog.listener()
    async def on_guild_join(self, ctx):
        await ctx.guild.create_category('Mailer')```
valid niche
#

what doesn't work?

valid niche
#

and what about it doesn't work?

stark bobcat
#

no error

stark bobcat
#

when

valid niche
#

do you have Intents.guilds?

stark bobcat
#

i reinvite my bot

slate swan
stark bobcat
valid niche
#

i'm asking if you enabled guilds intent which isn't priviledged

stark bobcat
#

hmm

#

where can i enable that

heavy island
#

im hosting my bot in heroku but im getting this error:

File "/app/main.py", line 1, in <module>
app[worker.1]:     from core import *
app[worker.1]:   File "/app/core.py", line 1, in <module>
app[worker.1]:     import discord
app[worker.1]: ModuleNotFoundError: No module named 'discord'
red kraken
heavy island
#

how can i install discord module in heroku

valid niche
#

master branch doesn't have components support

heavy island
#

yes

red kraken
heavy island
#

oh am i supposed to list the modules in requirements.txt

stark bobcat
valid niche
#

heroku is just straight up horrible

valid niche
#

!d discord.Intents

unkempt canyonBOT
#

class discord.Intents(**kwargs)```
Wraps up a Discord gateway intent flag.

Similar to [`Permissions`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions "discord.Permissions"), the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools.

To construct an object you can pass keyword arguments denoting the flags to enable or disable.

This is used to disable certain gateway features that are unnecessary to run your bot. To make use of this, it is passed to the `intents` keyword argument of [`Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client "discord.Client").

New in version 1.5...
stark bobcat
valid niche
stark bobcat
valid niche
#

you can go only one step worse than heroku, and that's replit

#

but both are horrible

stark bobcat
valid niche
#

add the print statement in the on guild join and trigger it again

stark bobcat
#

ok

stark bobcat
#

if it works it's great

heavy island
valid niche
#

read this @stark bobcat

valid niche
stark bobcat
#

other platforms cost money

valid niche
#

hosting costs money

#

hosting isn't free

heavy island
valid niche
#

tho it's dirt cheap like at most a coffee a month

valid niche
#

literally a coffee a month would be enough for most

#

or a raspberry pi if you're more into a one time purchase

stark bobcat
#

ohh

valid niche
#

here is a list of some of the most well known worldwide hosts

stark bobcat
#

waiiii mb

#

i did not load the cog

#

oops

boreal ravine
#

I have this "jishaku" cog and I want the bot the remove that cause it doesn't look nice. How do I do this?

heavy folio
#

okay idk what on earth is wrong with replit, but this keeps happening:

#

running on local has no problems, the bot runs successfully and theres no error at all

slate swan
#

how can i make my bot dm user who just joined? Or added him to a server?

boreal ravine
unkempt canyonBOT
#

await send(content=None, *, tts=False, embed=None, file=None, files=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/stable/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/stable/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

If the `embed` parameter is provided, it must be of type [`Embed`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed "discord.Embed") and it must be a rich embed type.
slate swan
boreal ravine
slate swan
slate swan
heavy folio
boreal ravine
slate swan
#

whats your bots prefix?

boreal ravine
#

NVM

boreal ravine
slate swan
#

ok

heavy folio
#

@slate swan

slate swan
#

wat

slate swan
#

it may be a error in the lib

boreal ravine
#

can I hide this or no?

slate swan
vagrant brook
#

โ€‹

#

use this character

heavy folio
lucid stream
#
    async def _loop(self, ctx: commands.Context):
        """Loops the currently playing song.
        Invoke this command again to unloop the song.
        """

        if not ctx.voice_state.is_playing:
            return await ctx.send('Nothing being played at the moment.')

        # Inverse boolean value to loop and unloop.
        ctx.voice_state.loop = not ctx.voice_state.loop
        await ctx.message.add_reaction('โœ…')
``` guys my loop is not working any fix?
slate swan
heavy folio
heavy radish
#

Where is the arg missing?

#
@bot.command(aliases=['e'])
async def enchant(ctx, arg):
  rarities = ["Normie",
"Good", "Great", "Mega", "Epic", "Hyper", "Ultimate", "Perfect", "Edgy", "Ultra-Edgy", "Omega", "Ultra-Omega", "Godly"]
  embed = discord.Embed(title="", description="You've enchanted your sword for 3,000 coins", color=0x109319)
  rng = random.choice(rarities)
  embed.set_author(name="CEO", icon_url= "https://i.imgur.com/jszzFTz.png")
  embed.add_field(name=f"โœจ ~-~> {rng} <~-~ โœจ", value="You've enchanted your sword for 3,000 coins", inline=False)
  await ctx.send(embed=embed) 
heavy radish
#

arg is a required requirement which is missing

lucid stream
boreal ravine
#

u dont even need it lol

heavy radish
#

oh shit

#

Aghhhhhhhhhhhhhhhhhhh

slate swan
heavy folio
slate swan
#

thats the problem

heavy folio
#

its fine running on local, but when i did on replit, it shows that

#

and last time theres also this error

boreal ravine
#

If is a required requirement which is missing comes up you probably forgot or didn't type in the command correctly

heavy folio
#

running on local is fine

slate swan
#

stap pinging i just want to code in piece ๐Ÿ˜ข

boreal ravine
#

i dont think u can do that yet

dense walrus
#

is there a Message.type of a spotify listen along invitation?

stiff nexus
hasty iron
#

what

#

also dont crosspost

stiff nexus
hasty iron
#

ask in one place

foggy kestrel
#

guys task loop stop working how can i fix it ?

noble helm
noble helm
#

solved

opaque trail
#
import asyncio as l

import discordSuperUtils as i
import time as q

p = print
g = q.time
z = l.sleep
s_ = i.SpotifyClient
c_ = i.YoutubeClient


async def j(c, a):
    b = g()
    v = await c.get_query_id(a)
    p('searched in', g() - b)

    s = g()
    b = await c.get_video(v)
    p('got video in', g() - s)
    if 'streamingData' in b:
        return b['streamingData']['adaptiveFormats']


async def r():
    c = c_()
    s = s_(client_secret="MY TOKEN", client_id="ANOTHER TOKEN")
    a = await s.get_songs('MY PLAYLIST')

    p('started')
    start = g()
    o = await l.gather(*[
        j(c, t) for t in a
    ])
    p(g() - start, 'end')
    p(len(o), len(a))
    p(o[0])

    await z(5)
    await c.session.close()


l.run(r())

hi guys please help me whats wrong with my code??

noble helm
#

whats the error

slate swan
opaque trail
#

i do not understand coding why cant i just become rich without code

opaque trail
slate swan
#

What are you trying do?

opaque trail
#

i dont know myself actually

noble helm
#

well whats the error of your code

slate swan
#

How can help then? ๐Ÿ˜„

noble helm
opaque trail
#

ye men thats the case pls help i need to complete this!!

noble helm
#

well this doesnt seem like its a disord bot, so i think Tsekis was right, so i cant tell what you were trying to do with your code
so what is this supposed to do?

noble helm
#

so you got code from the internet and dont know how it even works?

#

or wtf are you doing that you got code which you have no idea of how it works, what its supposed to do and is hard to read due to bad var naming

#

i found no client event on the docs to check for that but there might be sth else

#
discord.on_user_update(before, after)
Called when a User updates their profile.

This is called when one or more of the following things change:

avatar

username

discriminator

This requires Intents.members to be enabled.

Parameters
before (User) โ€“ The updated userโ€™s old info.

after (User) โ€“ The updated userโ€™s updated info.``` i found this tho
#
This function is a coroutine.

Requests previously offline members from the guild to be filled up into the Guild.members cache. This function is usually not called. It should only be used if you have the fetch_offline_members parameter set to False.

When the client logs on and connects to the websocket, Discord does not provide the library with offline members if the number of members in the guild is larger than 250. You can check if a guild is large if Guild.large is True.


This method is deprecated. Use Guild.chunk() instead.

Parameters
*guilds (Guild) โ€“ An argument list of guilds to request offline members for.

Raises
InvalidArgument โ€“ If any guild is unavailable in the collection.``` Found sth!
noble helm
#

you need to get the guild, get yourself, and then you should be able to canstantly check if youre in there and werent before

#

ok

sweet pilot
noble helm
sweet pilot
#

if you want us to help, we want to know your destination

noble helm
#

i also dont know why he needs to finish it !!!

#

has what

sweet pilot
noble helm
#

and the names of the variables

#

thats so hard to read/understand

sweet pilot
#

code readability and proper variable naming comes at very high levels. but the purpose of the code?

noble helm
#

have you figured out what that code is doing?
or what you want to do?

opaque trail
#

no man it was a joke

noble helm
#

thats fucked up

#

where did you find this poopmountain of a script

hasty iron
#

what is the context here

opaque trail
#

i wrote it!!!

boreal ravine
#

tsekis more like sekis

noble helm
opaque trail
#

its a good script dont even lie bro

noble helm
#

i dont know what its doing

#

lol

hasty iron
#

what even is that

noble helm
#

hard to read

#

and nothing more

sweet pilot
opaque trail
#

i just wrote some youtube client

hasty iron
#

if youโ€™re trying to be esoteric thatโ€™s not how you do it

sweet pilot
#

I've done it personally I think

lament mesa
noble helm
#

oh there are both

opaque trail
#

read my code ๐Ÿ™„ KEKW

lament mesa
noble helm
#

read my text ๐Ÿ™„

#

back to testing my code

#

bad joke

opaque trail
#

ytdl is pretty poop for discord bots

#

my youtube client fetches 500 players in like 10 seconds instead of 2 mintues on ytdl

hasty iron
#

ok

noble helm
#

didnt that one popular ytdl music bot got shut down lately

lament mesa
#

youtube now cares about breaking of their tos

opaque trail
#

uhh groovy has its own youtube client

#

most of the popular bots make their own

hasty loom
#

what is the equiv of bot.get_message (like bot.get_channel etc)

hasty iron
#

you mean something that gets you the message?

manic wing
#

what

#

await channel.fetch_message?

hasty iron
manic wing
#

i wish get_all_channels was a dict

hasty iron
#

why

manic wing
#

generals = bot.get_all_channels()['general'] and it returns a list of all general channels

#

i can make it but i really cant be fucked rn

hasty iron
#

that sounds like a very dumb idea

manic wing
#

why

hasty iron
#

having keys consisting of anything other than ids is inconsistent

#

considering that the whole library caches based on id

#

and also doesnโ€™t that return an iterator?

#

like the actual thing

#

!d discord.Client.get_all_channels

unkempt canyonBOT
#

for ... in get_all_channels()```
A generator that retrieves every [`abc.GuildChannel`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.GuildChannel "discord.abc.GuildChannel") the client can โ€˜accessโ€™.

This is equivalent to:

```py
for guild in client.guilds:
    for channel in guild.channels:
        yield channel
```   Note

Just because you receive a [`abc.GuildChannel`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.GuildChannel "discord.abc.GuildChannel") does not mean that you can communicate in said channel. [`abc.GuildChannel.permissions_for()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.abc.GuildChannel.permissions_for "discord.abc.GuildChannel.permissions_for") should be used for that.
hasty iron
#

you can just filter whatever you want from that

manic wing
#

i like the idea of it ยฏ_(ใƒ„)_/ยฏ

#

i might make it that

sweet pilot
#

@manic wing what's your end goal?

manic wing
rugged tinsel
#

hey can anyone help me with making the code for a fact bot where I don't have to write the facts 1 by ? please tag or dm me ๐Ÿ™‚ tysm

drifting arrow
#

How can I target messages from a specific user?

stark bobcat
#

hlo

lofty heron
#

hi does anybody know how to only allow a user with a certain role to use a command?i need to do that for my eval command

boreal ravine
stark bobcat
lofty heron
#

alright tenks man

boreal ravine
stark bobcat
boreal ravine
stark bobcat
#

i am using on_guild_join

slate swan
#

hey there!
im getting this track recently. someones knows?

stark bobcat
slate swan
boreal ravine
stark bobcat
slate swan
stark bobcat
#
@commands.Cog.listener()
    async def on_guild_join(self, ctx):
        await ctx.guild.create_category('Mailer')
        print('test')```
lament mesa
stark bobcat
lament mesa
#

and why **'Mailer'?

stark bobcat
#

ok thanks lemma try

boreal ravine
#

sorry I didn't know it was an event

slate swan
lament mesa
stark bobcat
#

hmm

boreal ravine
stark bobcat
#

ok thanks

slate swan
stark bobcat
#

@lament mesa

#
@commands.Cog.listener()
    async def on_guild_join(self):
        await guild.create_category('Mailer')
        print('test')```
boreal ravine
slate swan
slate swan
stark bobcat
slate swan
#

Show code @slate swan

stark bobcat
slate swan
#
async def on_guild_join(self, guild)
#

that should work

#

its take my to there

#

@slate swan

boreal ravine
slate swan
#

use an api

rugged tinsel
#

ok

slate swan
stark bobcat
unkempt canyonBOT
dapper cobalt
stark bobcat
quasi pawn
#

is async def on_message(ctx, message): if message.attachment and if ctx.channel.id is 887626373991120946: await message.add_reaction("๐Ÿ˜ฉ")

correct?

slate swan
#
async def on_message(message):
        if message.attachment and message.channel.id == 887626373991120946:
            await message.add_reaction("๐Ÿ˜ฉ")
``` this is correct
quasi pawn
#

Thanks

slate swan
#

wait no

#

thats correct

quasi pawn
#

thankss

slate swan
patent ivy
#

quick question how can I get the most recent message id?

#

specifically the most recent 100

hasty iron
#

!d discord.TextChannel.history

unkempt canyonBOT
#

async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/stable/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destinationโ€™s message history.

You must have [`read_message_history`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.

Examples

Usage...
hasty iron
#

defaults to 100

placid star
#

There's a large issue facing all discord bots, especially those using discord.py and similar, that could lead to all of those projects dying.
I want to spread the word, and have users fight back against this. I made a petition against the decision (effective april of 2022) http://chng.it/4gZpLmW5vJ
Please consider making your voice heard.

hasty iron
#

seems fishy

slate swan
placid star
#

i contacted a mod first

#

@hasty iron good on you for being vigilant tho :P

slate nymph
#

msg = message.content @client.event async def on_message(message): if msg.startswith("-hello"): await message.channel.send("Hi")
Whats wrong with msg variable?

lyric moat
#

how i make my bot say something in the server as they added it?

patent ivy
#

with the message_purge method, do I need to setup to need manage permissions

#

or will it automatically have it

dapper cobalt
#

!d discord.Guild.system_channel

unkempt canyonBOT
#

system_channel```
Returns the guildโ€™s channel used for system messages.

If no channel is set, then this returns `None`.
dapper cobalt
#

!d random.choice

unkempt canyonBOT
#

random.choice(seq)```
Return a random element from the non-empty sequence *seq*. If *seq* is empty, raises [`IndexError`](https://docs.python.org/3.10/library/exceptions.html#IndexError "IndexError").
hasty iron
quasi pawn
slate swan
#

then multiple

#

stuff

patent ivy
#

๐Ÿ˜ฆ

quasi pawn
boreal ravine
patent ivy
#

how to get current channel id?

slate swan
#

i would just get multiple channels like
c1
c2
c3
and do stuff

patent ivy
#

one a mesage was sent in

boreal ravine
#

ctx.channel.id

patent ivy
#

ctx is undefined

#

im trying to define channel

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.

boreal ravine
patent ivy
#
if message.content.startswith(f"{prefix}delete"):
        await channel.purge(limit=1)
        await message.channel.send('Deleted {} message(s)'.format(len(deleted)))```
#

channel on line 2

slate swan
#

yeah

patent ivy
#

how to command?

slate swan
#

then events arent your best way to go

boreal ravine
#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
keen talon
patent ivy
dapper cobalt
slate swan
#
@bot.command()
async def yourcommandnamr(ctx):
  await ctx.send("yes")
```bot or client depends on what you set it as
boreal ravine
keen talon
boreal ravine
#

Just an extension to discord.py

patent ivy
#

what is an extension

boreal ravine
keen talon
#

I meant it might run some programs in background

slate swan
boreal ravine
patent ivy
#

again

#

been using this all of 10 minutes

#

if there is some tutorial I can follow

#

oh submodule got it

boreal ravine
#

yes

dapper cobalt
keen talon
#

?

dapper cobalt
#

It's on Pypi so it's safe. Also they have a link to the source code.

keen talon
#

any other similar libraries ?

dapper cobalt
#

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

supple storm
#
@client.command(name = "setxp")
@commands.is_owner()
async def setxp_command(ctx, amount : int = 10, user : discord.User = None):
    if not user:
        cursor = expstorage.cursor()
        cursor.execute(f"UPDATE expstorage SET userxp = {str(amount)} WHERE client_id = {str(ctx.message.author.id)}")
        expstorage.commit()
        embed=discord.Embed(color=0x01e418, description = f"Set `userxp` = `{amount}` for {(ctx.message.author).mention} !")
        await ctx.send(embed = embed)
        return amount,user
    elif user:
        cursor = expstorage.cursor()
        cursor.execute(f"UPDATE expstorage SET userxp = {str(amount)} WHERE client_id = {str(user.id)}")
        expstorage.commit()
        embed=discord.Embed(color=0x01e418, description = f"Set `userxp` = `{amount}` for {user.mention} !")
        await ctx.send(embed = embed)

@setxp_command.error
async def setxp_command(ctx, error):
    if isinstance(error, commands.BadArgument):
        embed=discord.Embed(description = f'''
        {(ctx.message.author).mention} | Invaild Command !
        *Your previous command :  
        ''', color=0xf50a0a)
        await ctx.message.delete()
        await ctx.send(embed=embed, delete_after = 5)
    elif isinstance(error, commands.NotOwner):
        embed=discord.Embed(description = f'{(ctx.message.author).mention} | You aren\'t this owner bot !', color=0xf50a0a)
        await ctx.message.delete()
        await ctx.send(embed=embed, delete_after = 5)

how can i get the command that user used bcz i want to print it again in error

lofty heron
#

i'm not sure why it says i am lacking perms when my id is 727484628486848552

@client.command()
async def ownertest(ctx):
  if ctx.message.author.id == ('727484628486848552'):
    await ctx.send('weifjousdibh')
  else:
    await ctx.send('you are lacking perms')
dapper cobalt
gritty flame
supple storm
lofty heron
dapper cobalt
slate swan
slate swan
gritty flame
dapper cobalt
#

You can do @commands.is_owner() to check.

patent ivy
#

@boreal ravine can I dm you

boreal ravine
supple storm
#

i want to get all

slate swan
supple storm
slate swan
supple storm
slate swan
#

pls

slate swan
supple storm
#

i don't know about node

slate swan
# slate swan

i aint really sure but seems like your bot client was unable to connect to the wavelink server

#

but why

supple storm
#

i used await ctx.message.delete() before that command so..

supple storm
slate swan
supple storm
#

i don't know about node but i will try to help u

slate swan
slate swan
slate swan
supple storm
#

hmm

#

i don't know about this xD

ashen gale
#

so you guys couldnt help me with youtube shit for my bot

#

could yall help me with spotify or is that bad too

boreal ravine
ashen gale
#

alright, what do i import?

boreal ravine
#

I think

ashen gale
#

is it spotipy?

boreal ravine
hasty iron
#

and its also against their tos

ashen gale
#

son of a bitch

hasty iron
#

copyright laws dont just apply to youtube

boreal ravine
hasty iron
#

literally anywhere on the internet

patent ivy
#
@client.command()
async def purge(ctx):
    await ctx.purge(limit=1)
    await ctx.send(f'Deleted {} message(s)')```
#

how do I make this so that the user can go $purge 5

#

and it will delete 5 messages

hasty iron
#

give the command an argument

boreal ravine
hasty iron
#

and pass it in purge

patent ivy
hasty iron
#

what

boreal ravine
#

in the arguments

hasty iron
#

you dont know how to add an argument to a function?

patent ivy
#

into purge(ctx, limit)

#

yes?

boreal ravine
#

mhm

patent ivy
#

then what

boreal ravine
#

pass the arg in limit

slate swan
#

where can i install AVConv

patent ivy
boreal ravine
slate swan
patent ivy
#

then py async def function(ctx, string, number):

boreal ravine
#

no

patent ivy
#

then string = hello and number = 5

#

I dont get it

boreal ravine
#

amount:int

slate swan
boreal ravine
patent ivy
#

I am not sure how it understands the user message

boreal ravine
hasty iron
#

!d random.choices

unkempt canyonBOT
#

random.choices(population, weights=None, *, cum_weights=None, k=1)```
Return a *k* sized list of elements chosen from the *population* with replacement. If the *population* is empty, raises [`IndexError`](https://docs.python.org/3.10/library/exceptions.html#IndexError "IndexError").

If a *weights* sequence is specified, selections are made according to the relative weights. Alternatively, if a *cum\_weights* sequence is given, the selections are made according to the cumulative weights (perhaps computed using [`itertools.accumulate()`](https://docs.python.org/3.10/library/itertools.html#itertools.accumulate "itertools.accumulate")). For example, the relative weights `[10, 5, 30, 5]` are equivalent to the cumulative weights `[10, 15, 45, 50]`. Internally, the relative weights are converted to cumulative weights before making selections, so supplying the cumulative weights saves work.
hasty iron
#

its a builtin

patent ivy
#
@client.command()
async def purge(ctx, amount:int=1):
    await ctx.purge(amount)
    await ctx.send(f'Deleted {amount} message(s)')```
boreal ravine
#

r danny is way easier than this omg

patent ivy
#

did I do line 2 correctly?

hasty iron
#

purge is a method of TextChannel

boreal ravine
patent ivy
#

ik

#

oh my bad

boreal ravine
#

Command raised an exception: AttributeError: 'Context' object has no attribute 'purge' lol