#discord-bots

1 messages · Page 593 of 1

maiden fable
#

The old StringIO and exec

sick birch
#

If you’re just calculating expressions, you can convert to postfix notation and use stacks to solve it without eval

outer violet
#

I forgot it wasn’t mine sorry 💀

velvet tinsel
#

How do you make a prompt for user input? For example

please select an option
-1 for thing
-2 for another thing
-3 for another thing
-4 for something 

and the user replies with, say, 1, and the bot replies with

you selected 1

and the user has 30 seconds to reply. How does that work/what is it called?

silk mauve
#

yntaxError: Non-UTF-8 code starting with '\xe2'

#

@bot.command()
async def rocklee (ctx):
embed = discord.Embed
(
title="Die Regel für den Rock Lee's Dojo Server",
description="\n\n§1 Regelwerk\n➥ Mit dem Beitritt des Discord Servers akzeptierst du automatisch die Regeln des Servers\n➥ Bei einem Regelverstoß, wird dies rechtgemäß bestraft!\n➥ Unwissenheit schützt nicht vor der Strafe, falls du gegen eine Regel verstoßen haben solltest!\n➥ Du solltest die Regeln vollständig lesen und regelmäßig auf Neuigkeit überprüfen!\n➥ Eine Verwarnung oder eine andere Sanktion ist nie unbegründet und soll stets die Betroffenen anregen über ihre Fehler nachzudenken!\n\n§2 Verhalte\n➥ Du bist dazu verpflichtet eine freundliche Umgangsweise auf dem Server zu haben!\n➥ Beleidigungen, Drohungen und Provokationen sind strengstens untersagt!!\n➥ Wird in einem Text-Kanal gespammt, so werden die betroffenen Personen für einen bestimmten Zeitraum gemutet und verwarnt!\n➥ Teammitglieder haben immer das letzte Wort!\n ➥ Rassismus, Sexismus oder Pornografie sind auf diesem Server verboten!\n\n§3 Nicknames\n➥ Nicknames müssen taggbar sein und dürfen nicht nur aus Sonderzeichen und Emojis bestehen!\n➥ Es ist strengstens Untersagt sich als eine andere Person auszugeben!\n\n§4 Datenschutz\n➥ Private Daten, wie zum Beispiel Adressen, Handynummern, Passwörter, etc. sind verboten öffentlich ausgetauscht zu werden oder gar veröffentlicht zu werden!\n§5 Support\n➥ Der Support ist beendet, sobald du von einem Teammitglied in den Support Beendet Kanal verschoben wurdest!\n➥ Im Support werden Probleme und Fragen geklärt! Das Ausnutzen des Supports wird rechtgemäß sanktioniert\n➥ Du bist dazu verpflichtet einen respektvollen Ton im Support an den Tag zulegen!\n➥ Im Support zu lügen ist ebenfalls strengstens Verboten!\n➥ Um Jemanden zu melden seid ihr dazu verpflichtet ein handfesten Beweis, wie z.B. Screenshots vorlegen zu können!\n➥ Das Ausnutzen des Report Systems ist strengstens untersagt und wird mit einem Warn inklusive Mute geahndet.\n➥ Den Support darf man weder aufnehmen noch anderweitig verbreiten und wird mit einem Ban sanktioniert.\n\n§6 Werbung\n➥ Werbung jeglicher Art ist Verboten, darunter zählt die private und öffentliche Werbung!\n\n§7 Scamming\n➥ Scamming ist strengstens untersagt!\n➥ Scamming kann nur gemeldet werden wenn klare und handfeste Beweise vorliegen!\n\n§8 Echtgeldhandel\n➥ Das Handeln mit Echtgeld ist serverweit verboten und wird mit eine rechtgemäßen Strafe bestraft!\n\n§10 Doppelaccounts\n➥ Doppelaccounts sind verboten, vor allem um sich Vorteile im Tipico Bereich zu verschaffen}n➥ Beim Verstoß der oben genannten Regel werdet ihr gebannt.\n\n§15 Falsche Channels\n➥ Bots werden nur im #┃bot-channel benutzt, andernfalls wird eine Missachtung dieser Regel verwarnt\n➥ Dazu zählt genauso das Feedback-System, mit dem Befehl !suggest werden ausschließlich Feedbacks oder Ideen geduldet, wird dies missachtet wird das mit einer Verwarnung bestraft!",
colour=discord.Colour.dark_purple()

)
embed.set_image(
    url='https://c.tenor.com/R_46y_WzEn4AAAAC/line-colors.gif')
embed.set_footer(text= "Zeatman • 11.11.2021" ,icon_url="https://images-ext-1.discordapp.net/external/cJBUV5cIOm0u_YlsUia0EW4MpIM05dHrdb0maocfo3o/%3Fsize%3D1024/https/cdn.discordapp.com/avatars/371597683548225537/a_cc7d8579fb009c8f667ba781da9565c9.gif")
await ctx.send(embed=embed)
velvet tinsel
#

wth is that

silk mauve
#

This is my code/i wanted to do the rules for a server

#

yntaxError: Non-UTF-8 code starting with '\xe2'

silk mauve
#

Its showing me this error

velvet tinsel
silk mauve
#

I saw it but idk

velvet tinsel
#

welp

#

idk

silk mauve
#

Still dont know

velvet tinsel
#

nope :/

maiden fable
#

!d discord.ext.commands.Bot.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
velvet tinsel
#

wait

#

what

maiden fable
slate swan
#

What do you want exactly?

maiden fable
velvet tinsel
#

If you haven't noticed yet....

velvet tinsel
maiden fable
#

Anyways it's 2 here. Gn

slate swan
velvet tinsel
#

nightyy

slate swan
#

Or just use checks 🤷‍♂️

velvet tinsel
slate swan
velvet tinsel
#

mmm

#

here's an example

#
select option 1 or 2 or 3
#

1

#
wow you selected 1 well done 
slate swan
#

Yes use checks

velvet tinsel
#

okkee

velvet tinsel
#

ty

slate swan
#

Yw

#

@velvet tinsel you can do is on a message it will ask for the inputs and when you do it will react with 1 2 3 emojis and when you tap it the bot checks it and says what input you gaved

velvet tinsel
#

oh yes...wait_for innit?

#
def check_if_it_is_me(ctx):
    return ctx.message.author.id == 85309593344815104

@bot.command()
@commands.check(check_if_it_is_me)
async def only_for_me(ctx):
    await ctx.send('I know you!')

wait, what will this do?

#

will it just say I know you if I message?

slate swan
#

I think

velvet tinsel
#

ok...

#

but how to sense user text?

sage otter
#

Doesn’t this guy want to get the input from a user

#

How does that have anything to do with what he wants

velvet tinsel
#

(I was thinking about the Dank memer prompt thing using the cell phone)

slate swan
#

He wanted to check msgs

velvet tinsel
sage otter
#

I mean yeah I know what you’re talking about. We're in a channel that says discord bots.

velvet tinsel
#

Ok 😛

slate swan
#

He is tho?

#

Hes talking about a multichoice question for his bot that he wants to check with checks

#

Isnt that related to discord bots?

sage otter
#

Yeah but command checks still holds no relevance towards that

velvet tinsel
#

oh

#

2 mins of typing

#

I thought you were going to do some complex algorithm explaining

sage otter
#

What was brought up earlier is still relevant. .wait_for() is what you're looking for.

#

For the event you can use reaction_add or just message.

slate swan
velvet tinsel
#

Ohhh...I see

#

I looked it up on Stack Overflow

slate swan
velvet tinsel
#

(more like I googled it but we don't talk about that)

#

ok ty guys 🙂

slate swan
#

Np best of luck

sage otter
velvet tinsel
#

Can I use logical operators with the wait_for()?

#

For example, I wanted different options, would I use wait_for("1" or "2")?

sage otter
#

You can in the check that you pass in

velvet tinsel
#

ahhh ok

slate swan
#

I see

#

@sage otter sorry for the ping but thank you for showing me the correct way

velvet tinsel
#
@client.event
async def on_message(message):
    def check(m):
         return m.content == 'hello' and m.channel == channel

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

what am I supposed to send in order to get a response again? lemon_eyes

#

nvm I googled it

valid niche
#

these are never defined

velvet tinsel
#

Ok

#
client.command()
@commands.cooldown(1, 60, commands.BucketType.user)
# cooldown of 60 seconds to stop mass robbing.
async def bankrob(ctx, member:discord.Member):
    await open_account(ctx.author)
    await open_account(member)

    bal = await update_bank(member)

    if bal[0] < 1000:
        messag = discord.Embed(title="Not worth it...", description="They're too poor", color=discord.Color.red())
        await ctx.send(embed=messag)
        return

    earnings = random.randint(0, bal[0])

    await update_bank(ctx.author, earnings)
    await update_bank(member, -1*earnings, "bank")
    num = random.randint(1, 10)
    if num == 2:
        rob_embed = discord.Embed(title="Robbed!", description=f"You stol {earnings} from {member}!",
                                     color=discord.Color.green())
        stolen_embed = discord.Embed(title="Oh no!",
                                   description=f"{ctx.author} stole {earnings}",
                                   color=discord.Color.red())
        await member.send(embed=rob_embed)
        await ctx.send(embed=stolen_embed)
    else:
        fail_embed = discord.Embed(title="Failure.", description="You failed to rob the bank.", color=discord.Color.red())
        await ctx.send(embed=fail_embed)

after a user uses !rob, how do I make it so nobody can use the command on the same user (in the member argument)?

valid niche
#

you will need to make a custom cooldown system

velvet tinsel
#

Ty!

silent ermine
#

since you are using message in the async def commandName()

kindred epoch
slim whale
#

Hello, I am trying to make a command that prints the bots in a guild.

@bot.command()
async def bots(ctx):  
  bots =([m for m in ctx.guild.members if m.bot])
  
  print(bot)
``` When I print `bot` it prints this: [<Member id=892459054344048670 name='DuckyBot' discriminator='8851' bot=True nick=None guild=<Guild id=908019906862256138 name='DuckyBot・Soporte' shard_id=None chunked=True member_count=8>>]. How i can convert that into DuckyBot#8851?
sage otter
#

In the list comprehension change the first m to f"{m.name}#{m.discriminator}"

slim whale
#

list comprehension never heard that xd

sage otter
#

bruh

slim whale
#

oh yes xd

#

[] like this

#

bots =([f"{m.name}#{m.discriminator}" for m in ctx.guild.members if m.bot]) @sage otter

sage otter
#

Yeah

slim whale
#

<discord.ext.commands.bot.Bot object at 0x7ffb536585b0> now it prints this

#

i fixed it

#

nevermind xd

#

['DuckyBot#8851'] with this now i can do things

#

thanks! @sage otter

sage otter
#

Honestly

#

You probably didn’t even need to do any of that

#

If you casted the object to a string it would of done the same thing

tulip oracle
#

is there any support for catching if the command used was in a reply. then sending back to that person replied to. with discord.Message?

#

i see message.reply but i dont see anyway of checking for a reply and getting the user replied to

lunar helm
#

im using discord ipc to talk to my bot from my website

#

but i can only get variables to work if i transfer guild_id

#

if i try and add more it says

#

TypeError: Client.request() takes 2 positional arguments but 5 were given

#

await ipc_client.request("set_setting", value, guild_id, "cumulative")

#

where is 5 coming from

#

and this is where the function is

#

async def set_setting(data):

#

you are suppoed to do data.<variable> to get the args

valid perch
#

You need to make everything but the request route a key word argument

#

Iirc

tulip oracle
#

is there anyway to catch if a message was a reply and get the replied author if possible in d.py? obviously i saw await reply but nothing for checking it or an attr on messageable @valid perch

valid perch
#

Give me a min

tulip oracle
#

how would i use this with on_message? since it doesnt look bool

valid perch
#

What

#

You can just do if message.reference

slate swan
lunar helm
valid perch
#

I'd need to look at my code to be sure otherwise. It's just what I seem to remember having todo

valid perch
lunar helm
#

bruh now it works

#

i tried it yesterday and it didn't work

slate swan
valid perch
slate swan
tulip oracle
# valid perch You can just do `if message.reference`

ah thank you. another q, trying to notify the most recent guild booster by just slicing the either first or last element. and both are not the most recent one. done some testing and checking. im not sure if the boost by that user being a second or third boost has anything to do with it. but the list doesnt seem correct

valid perch
#

Now go sort your list based on that go get the boost order

wanton marten
#

Hey everyone, I just had a question about if its possible to have a youtube video play inside of an embed that you create with discord.py. I'm making a kind of music bot for my server that gives out multiple links to things like spotify and apple music, and I thought it would be nice to have the song playable inside of the embed like when you just send a youtube link directly

jolly saffron
#

hi

slate swan
#

why is this happening all of a sudden

#

ive uninstalled ind installed the lib multiple times

slate swan
slate swan
# slate swan

And your bot var should look like this:
bot = commands.Bot(commands_prefix="") the basic one

slate swan
#

I think when I installed nextcord earlier today it couldve messed with discords module

#

I had to uninstall all discord related modules then reinstall

#

Did you fix it?

#

yea

#

Good for you

#

just had to reinstall module

#

Nice

#

thanks though

slate swan
loud junco
#

how do i make a command with several name

#

like i and inv

#
@bot.command(name=['inv', 'i'])
```this is not working
pliant gulch
#

get_name is a method of your class

#

You access it through self

#

self.get_name

#

And your command doesn't have a self parameter

#

It should be the first one, before ctx

#

Same with get_name

#

No no you access it via self.get_name when your calling it.

#

Like where if (get_name) is

#

And like I said earlier

#

Your missing self in your methods

#

All methods of a class must have self as the first parameter

#

Unless they are staticmethod

#

Or a classmethod

timber kindle
#

what is Parameter 'coro' unfilled?

graceful gulch
#

did it load your cogs?, are you using discord.Client or commands.Bot?

boreal ravine
#

do you have an on_message event

graceful gulch
#

that wont make it not recognize the commands unless hes inheriting commands.Bot into a class

bronze pilot
#

I see coro in a lot of places such as documentation and error messages, I'm using bot.command. Can someone explain what coro is?

loud junco
#

coroutine object?

#

Coroutine objects are what functions declared with an async keyword return.

bronze pilot
#

damn it, I was confused cause I kept reading it in a Mexican accent

#

I understand it now though

kindred epoch
#

Third option has the same name as the second option

#

And the error clearly says what's wrong

loud junco
#

how do i make command for rpm craft 1, rpm craft 2 in the commandrpm craft

#

or i need to make a new one?

slate swan
#

is pkhex file inside the folder named cogs

#

cool

slate swan
#

!d discord.ext.commands.Group

unkempt canyonBOT
#

class discord.ext.commands.Group(*args, **kwargs)```
A class that implements a grouping protocol for commands to be executed as subcommands.

This class is a subclass of [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") and thus all options valid in [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") are valid in here as well.
slate swan
#

ah i see

loud junco
#
@bot.group(pass_context=True)
  async def First(ctx):
    if ctx.invoked_subcommand is None:
      await bot.say('Invalid sub command passed...')

  @First.command(pass_context=True)
    async def Second(ctx):
      msg = 'Finally got success {0.author.mention}'.format(ctx.message)
       await bot.say(msg)
#

this?

slate swan
#

outdated , but yes

loud junco
#

is there any new ones?

slate swan
#

click on the link in the embed from bot

slate swan
loud junco
#
@bot.group(pass_context=True)
async def First(ctx):
    if ctx.invoked_subcommand is None:
        await bot.say('Invalid sub command passed...')

@First.group(pass_context=True)
async def Second(ctx):
    if ctx.invoked_subcommand is Second:
        await bot.say('Invalid sub command passed...')

@Second.command(pass_context=True)
async def Third(ctx):
    msg = 'Finally got success {0.author.mention}'.format(ctx.message)
    await bot.say(msg)
slate swan
#

its still wrong

loud junco
#

hmm

#

the api is tons of small stuff

#

i need to puzzle them

#

;-;

slate swan
#

I'm having trouble with the bot removing the user's reaction in line 136. How do I resolve this issue?

#

How do I do that?

slate swan
#

!d discord.Message.remove_reaction takes emoji and user object

unkempt canyonBOT
#

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

Remove a reaction by the member from 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").

If the reaction is not your own (i.e. `member` parameter is not you) then the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission is needed.

The `member` parameter must represent a member and meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
slate swan
slate swan
#

The message doesn't get edited

#

is pages a list of embeds?

#

Yes

#

possibly u already have the embed sent you wanted in the edit

#

It still didn't work sadly

#

lemme try running the code

#

could u sent it in text form pls?

#

`def check(reaction, user):
return user == ctx.author

    i = 0
    #await ctx.send(embed = pages[0])
    message = await ctx.send(embed = pages[i])
    await message.add_reaction('⏮')
    await message.add_reaction('◀')
    await message.add_reaction('▶')
    await message.add_reaction('⏭')

    while True:
        reaction, user = await client.wait_for("reaction_add", timeout = 60, check = check)
        if str(reaction.emoji) == '⏮':
            i = 0 
        elif str(reaction.emoji) == '◀':
            if i > 0:
                i -= 1
        elif str(reaction.emoji) == '▶':
            if i < (len(clist)) - 1: 
                i += 1
        elif str(reaction.emoji) == '⏭':
            i = len(clist) - 1
        
        message1 = await ctx.channel.fetch_message(message.id)
        await message1.remove_reaction(reaction.emoji, user)
        await message1.edit(embed = pages[i])

`

slate swan
#
elif str(reaction.emoji) == '◀':
                if i > 0:
                    i -= 1```

this may be the issue 
since the value of i may not be greater than 1 at starting stage
#

so it does not do -1

#

Oh

#

I used ◀ and that worked but I think removing rections could be an issue

sturdy tapir
#

How do I make it when someone says the command the bot deletes it

#

I tried doing this

#
ctx.message.delete()
bronze pilot
sturdy tapir
#

yeah i'm dumb

#

forgot that

bronze pilot
#

Happened to me many times

sturdy tapir
#

lmao

bronze pilot
#

For future reference, if you get any errors saying "x" was never awaited, it's probably because you forgot to use await

sturdy tapir
#

I dont remember the error exactly

bronze pilot
#

Just in case you'll come across that error anyway

#

that's the reason 🙂

humble dune
#

hlo

#

can i ask my problem

boreal ravine
#

Sure

#

Don't ask to ask just ask

sturdy tapir
#
@client.command()
async def allscripts(ctx):
        myfile = open("alltext.txt","r")
        data = ""
        lines = myfile.readlines()
        for line in lines:
            data = data + line.strip()
        await ctx.send(lines)

it sends []
not
the content of the text file

slate swan
#

Maybe you want to use your variable data sometimes

humble dune
sturdy tapir
#

o

slate swan
#

It's not type hinted

boreal ravine
#

wont it still work if it isnt typehinted

humble dune
#

i cannot get the id of my user

slate swan
#

A string does not have the id attribute

slate swan
humble dune
slate swan
#

In the parameters

boreal ravine
humble dune
slate swan
#

I just did it

slate swan
sturdy tapir
#
Traceback (most recent call last):
  File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\bot.py", line 939, 
in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\core.py", line 94, 
in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message
#
@client.command()
async def allscripts(ctx):
        myfile = open("allscripts.txt","r")
        data = ""
        lines = myfile.readlines()
        for line in lines:
            data = data + line.strip()
        await ctx.send(data)
slate swan
#

And it has nothing to do with discord.py, it's basic python

sturdy tapir
slate swan
#

It is

sturdy tapir
slate swan
#

Otherwise you wouldn't get that error :)

sturdy tapir
#

not empty 🙂

#

how's that

slate swan
#

That's not the content of data

#

That's your text file

sturdy tapir
#

I want the content of the text file

slate swan
#

So you're not reading it's content properly

sturdy tapir
#

so can I just do

#
with open("allscripts.txt", "r") as f:
  print(f.read())
slate swan
#

No

#

f would be the file

sturdy tapir
#

o wit

slate swan
#

You still need readlines

#

or just .read()

#

How to make an event so my bot sends a message every 2 hours?

#

And give that as output

slate swan
sturdy tapir
#
in wrapped
    ret = await coro(*args, **kwargs)
  File "d:/code/RbxMods/RbxMods.py", line 21, in allscripts
    with open (allscripts, 'r') as script:
TypeError: expected str, bytes or os.PathLike object, not Command

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

Traceback (most recent call last):
  File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\bot.py", line 939, 
in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\core.py", line 94, 
in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: expected str, bytes or os.PathLike object, not Command
#
@client.command()
async def allscripts(ctx):
        with open (allscripts, 'r') as script:
            data = script.readlines()
            await ctx.send(data)
#

I did this

#

what does the error mean

slate swan
#

Pass the correct argument to the with open

#

Error says it all, it expects a string

#

You didn't give a string for the file name

sturdy tapir
#

oh

#

alr 1 sec

slate swan
#

And you can probably just use .read()

sturdy tapir
#

again

#

the bot says this []

#
@client.command()
async def allscripts(ctx):
        with open ("allscripts.txt", 'r') as script:
            data = script.readlines()
            await ctx.send(data)
slate swan
#

Where is the file you run located and the file you're trying to open

sturdy tapir
#

the same folder

#

this is what it contains

#

what should I do

barren meteor
#

what discord code app I use?

#

wait never mind...

slate swan
#
@tasks.loop(seconds=69)
async def hi():
	await channel.send("Hi")
hi.start()```
#

i tried py print("hi") and that loop worked

barren meteor
#

To make a bot

#

what to pick?

slate swan
#

Python 3

barren meteor
#

ok thank you

humble dune
#

hlo are there any modules or libraries for storing data in discord.py

slate swan
#

Database

humble dune
tawdry perch
#

what is the correct permission for this, because that seems to be incorrect? ```py
manage_channel=False

slate swan
#

If you use MongoDB it will be a different library than if you use MariaDB

humble dune
slate swan
#

Personal preference, there id no better

#

Both have their positive and negative points

humble dune
slate swan
slate swan
slate swan
tawdry perch
slate swan
#

!resources To learn Python 👇

unkempt canyonBOT
#
Resources

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

tawdry perch
#

Now it works! Thx 😄

high pollen
#

Any good hosting services?

#

replit + uptime is just too slow

maiden fable
high pollen
#

need free

prisma spoke
#
from PIL import Image, ImageDraw, ImageFont

level = 1
rank = 7
final_xp = 1000
xp = 400
user_name = "NinjaIsBack?"
discriminator = "#2007"

# C:\Users\admin\Downloads\rog.jpg
# C:\Users\admin\Downloads\trx_white_on_black-2.png

# background and logo
background = Image.open("C:/Users/admin/Downloads/rog.jpg")
logo = Image.open("C:/Users/admin/Downloads/trx_white_on_black-2.png").resize((550, 550))
bigsize = (logo.size[0] * 3, logo.size[1] * 3)
mask = Image.new("L", bigsize, 0)
draw = ImageDraw.Draw(mask)
draw.ellipse((0, 0) + bigsize, 255)
mask = mask.resize(logo.size, Image.ANTIALIAS)
logo.putalpha(mask)

background.paste(logo, (1275, 970), mask=logo)

# font styles 
big_font = ImageFont.truetype("arial.ttf", 60)
medium_font = ImageFont.truetype("arial.ttf", 40)
small_font = ImageFont.truetype("arial.ttf", 30)

# Placing level number
text_size = draw.textsize(str(level), font=big_font)
offset_x = 1000 - 15 - text_size[0]
offset_y = 10
draw.text((offset_x, offset_y), str(level), font=big_font, fill="#11ebf2")

background.show()```
hy i was making a rank carrd for python but this wont display the text
#

no errors

prisma spoke
barren meteor
#

how to download python?

prisma spoke
slate swan
prisma spoke
slate swan
slate swan
slate swan
#

can anyone help me how do I use dropbox api and send files as an output when requested in my discord bot

high pollen
#

not 24/7

slate swan
slate swan
high pollen
slate swan
slate swan
slate swan
#

Is that image getting saved somewhere

#

i have a folder in which there are 200 images named by number wise e.g..
image 1
images 2
i want to use the api and send anyone of the image when requested

slate swan
#

you can also use rest of 250 hours to host other stuff

high pollen
#

ya

slate swan
high pollen
slate swan
#

!d discord.File < then use this

unkempt canyonBOT
#

class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.

Note

File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
slate swan
high pollen
#

i cant link card

#

will use 2 accs

slate swan
#

total 1000 hours you can host any other projects wth the rest of 250

high pollen
#

ok got it ty

slate swan
#

anyways it gives 1k hours once you link card

slate swan
slate swan
#

they took 25 cents when i linked my card

high pollen
#

i cant link

slate swan
high pollen
#

2 accs it is

#

does it have a good db?

slate swan
pliant nacelle
#

how can i host my bot 24/7 for free ?

high pollen
slate swan
high pollen
#

scroll up discussion about it

high pollen
pliant nacelle
#

can u send a tuto video in private pls

slate swan
slate swan
#

and use github repo so heroku can see the coding files

pliant nacelle
#

should i upload my project file there ? @slate swan

high pollen
#

y

#

no

high pollen
#

upload to github

pliant nacelle
pliant nacelle
slate swan
pliant nacelle
slate swan
#

select py file

slate swan
pliant nacelle
#

continue

slate swan
#

upload the github link

#

select py file

#

and start hosting

#

use there CLI to see the console

pliant nacelle
#

thanks bro

slate swan
pliant nacelle
#

@slate swan self hosting or heroku

slate swan
#

@pliant nacelle

ocean leaf
#

but i watched a tutorial in which the person used avatar_url_as

#

here is the vdo

sturdy tapir
#
@client.command()
async def request(ctx,request1, *, message = None):

    guild_owner = client.get_user(int(ctx.guild.owner))
    message = f"{ctx.author} Has requested a script his request : {request1}"
    await guild_owner.send(message)

this is the error

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

Traceback (most recent call last):
  File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\bot.py", line 939, 
in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\core.py", line 94, 
in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
ocean leaf
#

what do u want to do?

#

get the owner id?

sturdy tapir
#

no

#

the username so I can dm them using the bot

#

like I'm doing a request for video

#

they'll request what kind of video

#

and it will get dmed to me

boreal ravine
#

cant be an integer

#

anyways

sturdy tapir
#

I didn't try

boreal ravine
#

guild owner is none for some reason

sturdy tapir
#

making it an integer?

#

can I just define my self as the user

sullen shoal
#

so it was invoked in dms?

boreal ravine
sturdy tapir
#

I don't remember

#

using get_user

#

o

#

nvm

#

in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'get_member'

#
@client.command()
async def request(ctx,request1, *, message = None):

    guild_owner = client.get_member(int(ctx.guild.owner))
    message = f"{ctx.author} Has requested a script his request : {request1}"
    await guild_owner.send(message)
sullen shoal
sturdy tapir
#

They'll

#

type in the channel

#

in the discord server

#

.request (their request)

#

it will get the request and send it to me

#

in dms

slate swan
sturdy tapir
#

so it's get user

slate swan
#

So ctx.guild.get_member()

sturdy tapir
#

oh

slate swan
#

And just go ctx.guild.owner

#

It gives the owner already

slate swan
#

Can directly do ctx.guild.owner.send(...)

sturdy tapir
#
in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\core.py", line 94, 
in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: get_member() missing 1 required positional argument: 'user_id'
#
@client.command()
async def request(ctx,request1, *, message = None):

    guild_owner = ctx.guild.get_member()
    message = f"{ctx.author} Has requested a script his request : {request1}"
    await guild_owner.send(message)
slate swan
#

No need to use get_member

sturdy tapir
#

I have intents

boreal ravine
slate swan
#

Just do ctx.guild.owner.send(...)

sturdy tapir
#

I did intents

sullen shoal
#

this guy staright up ignored the solution

sturdy tapir
#

o alr

slate swan
slate swan
slate swan
#

Look at what I replied to

sturdy tapir
slate swan
#

Smh

slate swan
sturdy tapir
#

It worked.

sullen shoal
#

its optional so it can be None too

slate swan
#

¯_(ツ)_/¯

sturdy tapir
#
@client.command()
async def request(ctx,request1, *, message = None):

    message = f"{ctx.author} Has requested a script his request : {request1}"
    await ctx.guild.owner.send(message)
slate swan
#

¯\_(ツ)_/¯

sturdy tapir
#

thanks

#

Why do I keep making simple mistakes

#

bruh

sullen shoal
#

read the docs carefully

sturdy tapir
#

Okay

slate swan
#

Why do you have a message argument though?

#

It's pretty much not needed

stark bobcat
#

Is is possible to rename the default help command

boreal ravine
#

i mean

boreal ravine
boreal ravine
#

well I subclassed the help command > added a super init > changed it

stark bobcat
#

o

#

i didn't understand

boreal ravine
#

well

#

i subclassed the default help command commands.HelpCommand and then changed it's attributes using super

boreal ravine
#

!super

#

!tag super

boreal ravine
cyan bay
#

how do you make the bot save data, like for example, if you have an xp system, how do you make it so that it remembers your xp, and only YOUR xp

cyan bay
#

i have no idea how to use a database

boreal ravine
#

¯_(ツ)_/¯

cyan bay
#

can u show me a little bit of code, say, if the user inputs data, the bot saves that data

#

like if the user says hello, the bot saves it for that user only

#

so if another user says hi, its stored as hi and not hello

boreal ravine
#

well

#

i have no idea

cyan bay
#

oh ok np

boreal ravine
cyan bay
#

ohk ty

shadow wraith
#

hey can someone help me whenever i run my bot and do any command it wont send the message

#

this is kinda troublingm e

small crane
#
import discord
from discord.ext import commands
from discord_slash import SlashCommand, SlashContext
import asyncio

client = commands.Bot(command_prefix='.', intents=discord.Intents.all())
slash = SlashCommand(bot)

@slash.slash(name="test")										
async def _test(ctx: SlashContext):
    embed = discord.Embed(title="embed test")
    await ctx.send(content="test", embeds=[embed]) 
#

Can anyone tell what did I do wrong?
Bot doesn't comes online

shadow wraith
#

no error message in the terminal

slate swan
shadow wraith
#

hmm i said any command

#

but yes i do have an on_messsage here's the event

boreal ravine
#

your on_message might be blocking your other comands from running

slate swan
#

Put this at the bottom of your event.
await bot.process_commands(message)

shadow wraith
#

here it is py @bot.event async def on_message(message): if message.author == bot.user: return message_split = message.content.split(" ") for message_word in message_split: for bad_word in bad_words: if(bad_word == message_word.lower()): await message.delete() await message.channel.send(">:( wtf bro why u gotta swear")
bad_words list exists tho

boreal ravine
#

dont put it inside the loop

#

just put it inside the function

shadow wraith
#

oh

#

let me see if that works

#

lmao it works

#

thanks guys

boreal ravine
#

ok

small crane
boreal ravine
#

hm

humble dune
#

Ignoring exception in command gamble:
Traceback (most recent call last):
File "C:\Users\Pragith\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Pragith\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 855, in invoke
await self.prepare(ctx)
File "C:\Users\Pragith\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 789, in prepare
await self._parse_arguments(ctx)
File "C:\Users\Pragith\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 697, in _parse_arguments
transformed = await self.transform(ctx, param)
File "C:\Users\Pragith\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 542, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.

@bot.command()
async def gamble(self, ctx, money: int):
"""Gambles some money."""
economy = self.bot.get_cog('Economy')

    await economy.withdraw_money(ctx.author)

class Economy(commands.Cog):

async def withdraw_money(self, ctx):
    # implementation here
    await ctx.send("money withdrawn")

async def deposit_money(self,ctx):
    # implementation here
    await ctx.send("money deposited")

last two are my codes first is my error help me

acoustic ermine
#

How can i change my bots name without going to dev portal

humble dune
boreal ravine
#

was quite obvious

humble dune
#

how to use cogs??

boreal ravine
unkempt canyonBOT
#

class discord.ext.commands.Cog(*args, **kwargs)```
The base class that all cogs must inherit from.

A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/master/ext/commands/cogs.html#ext-commands-cogs) page.

When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
slate swan
#

AttributeError: 'MyClient' object has no attribute 'get_context'

`#chatbot
async def on_message(self, message):
# don't respond to ourselves
if message.author == self.user:
return

    if message.content.lower() == 'hi':
        await message.channel.send('hello')


    if message.content.lower() == 'hii':
        await message.channel.send('hii')


    self.get_context(message)
    context = await self.create_context(message)
    if context.valid:
        await self.invoke(context)
        return
    with open("/Users/bai/Documents/log.txt", 'a') as f:
        f.write(message.content + '\n')`
#

Anyone know how to fix this? Please help me, im new to discord.py :/

dusk dust
#

how can I make the bot wait for both reactions? Example: I click on 🟥 and it does nothing but if I click on 🟩 the messages are deleted:

msg = await ctx.send(embed=embed)
    confirm = await msg.add_reaction('🟩')
    await msg.add_reaction('🟥')    
    await client.wait_for('reaction_add', check=confirmar)
    await msg.delete()
    await ctx.channel.purge(limit=amount + 1)
    await client.wait_for('reaction_add', check=voltar)
    await msg.delete()
gaunt herald
#

How to make on error command?

tawdry perch
tawdry perch
gaunt herald
tawdry perch
#

on specific command?

vale glen
slate swan
tawdry perch
#

don't copy others code without knowing how it works

slate swan
#

then whats the command for it?

#

...

tawdry perch
#

¯_(ツ)_/¯

gaunt herald
vale glen
#

dont just copy code without knowing what it does, you wont get anything out of it

tawdry perch
slate swan
#

then how to get messages that arent in the manually inputted list

#

?

tawdry perch
#

elaborate

slate swan
#

?

tawdry perch
#

be more specific what you actually mean

slate swan
#

So basically when people send 'hi', it will reply hello.
If people send 'hii', it will reply 'hii.

I want to collect chat data.
If people send anything else, that is not 'hi' or 'hii', then copy message into /Users/bai/Documents/log.txt.

#

This is to help me improve my chat bot*

tawdry perch
#

so you can check if message starts with x and send y as response ```py
if message.content.startswith('x'):
await message.channel.send('y')

slate swan
#

I want it to auto write into the text file, all the messages, sent in all channels and guilds the bot is in.

tawdry perch
#

that would be API abuse to send it to literally everywhere

slate swan
#

But then how can I collect huge chat data?

tawdry perch
#

you are listening it every guild the bot is in by default, but make it only respond to channel it was sent it

humble dune
#

@commands.command()
async def withdraw_money(ctx):
# implementation here
await ctx.send("money withdrawn")

discord.errors.ClientException: Callback for withdraw_money command is missing "ctx" parameter.

i have ctx writen

slate swan
#

I need tons of conversations, listed into a text file.

tawdry perch
humble dune
#

thx

tawdry perch
slate swan
#

Is it possible to collect huge conversation data?

tawdry perch
#

technically why not

slate swan
#

conversation meaning messages in discord/or chat msg

#

How?

tawdry perch
#

use on message event

slate swan
#

message event wont work for my bot

tawdry perch
#

why not?

slate swan
#

cuz then i will have to change so many things

#

no guilds/events commands/code lines

#

and then i will have to shut down my bot, which ppl will complain :/

tawdry perch
#

Then I don't have time to explain any other methods, hunting the hunter might be able to explain

slate swan
#

Please :/

tawdry perch
#

but they are on dnd mode so I don't ping em here

slate swan
#

Is it possible for you to explain , please 😦

#

it would help alot :))

tawdry perch
#

on message is the easiest way I would use

slate swan
#

how?

tawdry perch
#
@commands.Cog.listener()
async def on_message(self, message):
#

That is only for cogs*

slate swan
#

how do i stop a running discord bot?

tawdry perch
#

via terminal?

slate swan
#

needs to be automated

tawdry perch
#

in what way

slate swan
#

is there like a client.stop() method

slate swan
#

thanks for the infoo

tawdry perch
#

this should work

slate swan
#

thanks

tawdry perch
#

np

shadow wraith
#

how do you make an embed with clickable text which leads to a link

tawdry perch
#

(text)[link] I'd say

shadow wraith
#

do we just use html <a href> or some other syntax

tawdry perch
#

or other way around

shadow wraith
#

o

tawdry perch
#

try both

shadow wraith
#

no its (text)[link] i remember now using discohook

tawdry perch
#

ah, good

shadow wraith
#

can you help me

tawdry perch
#

what did you do?

#

share the embed code*

shadow wraith
#

basically i have this embed description which shows a wikipedia guide of tictactoe

tawdry perch
#

plus result

shadow wraith
#

i didnt want it too be too long so i did a few lines of the wikipedia then did a ... read more for the link

tawdry perch
#

I mean (text)[link] and [text](link)

#

try both

shadow wraith
#

hmm

tawdry perch
#

actually try the last one

shadow wraith
#

yea i think its that one

#

hey it works! the last one works! :D

slate swan
#

can anyone tell me how do I make the bot say which file has been given as a output in the console?

@bot.command()
async def test(ctx):
    number = random.randint(0, 100)
    wow = random.randint(100, 140)
    f = discord.File("./vote_rewards/reward "+ str(number)+".jpeg", filename="vote_rewards.jpeg", spoiler=True)
    g = discord.File("./vote_rewards2/reward "+ str(wow)+".jpeg", filename="vote_rewards2.jpeg", spoiler=True)
    await ctx.send(file=f) or await ctx.send(file=g)
shadow wraith
#

whos idea was it to put an or await

boreal ravine
shadow wraith
#

btw f-g means foreground

#

😎 im smart

tawdry perch
boreal ravine
#

🤨

slate swan
#

!d discord.Attachment.filename

unkempt canyonBOT
slate swan
#

!d discord.Message.attachments

unkempt canyonBOT
shadow wraith
#

i knew it who's idea was it to put an or await i knew it

slate swan
#

but there are 140 files

#

real what i wrote again

#

variable = ctx.send(....

shadow wraith
#

to have over 100 files

#

not saying you shouldn't

slate swan
slate swan
rose shale
#

hey ,
i was trying to build a game in discord.py , so i have buttons and waiting for 2 users to click and at tha same time, i want to show the remaining time (from 10s).

iam waiting for both players input using a while loop also i wanted to edit embed after every second to update tha time, if i use time.sleep , it will stop the excecution of the program for 1 s rite, so is there any other way?

slate swan
#

its printing everything except the file name

#

the embeds bot sent

slate swan
#

like printing channel name,server name,channel id everything

#

oh

slate swan
slate swan
#

!d asyncio.sleep this is non blocking

unkempt canyonBOT
#

coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.

If *result* is provided, it is returned to the caller when the coroutine completes.

`sleep()` always suspends the current task, allowing other tasks to run.

Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.

Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [What’s New in 3.10’s Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.

Example of coroutine displaying the current date every second for 5 seconds:
slate swan
#

its a coro , so you gotta await it

rose shale
rose shale
#

inside while loop?

slate swan
rose shale
#

ok

slate swan
#

a friend wanna learn it

opal pewter
slate swan
rose shale
slate swan
dapper cobalt
rose shale
rose shale
#

so i mean i need to get click from 2 players

#

so...

#

how is it possible

slate swan
#

yeah one of them does not include comment explanations , it was just drafted maybe

slate swan
loud junco
#
@bot.command(name ='start')
@commands.cooldown(1, 1, commands.BucketType.user)
async def start(ctx: commands.Context):
  userid = ctx.author.id
  area = db[f'{userid}area']
  if area > 0:
    await ctx.channel.send(f'**{ctx.author.name}** feels like doing this all over again =.=')
  else:
    names = ['pogchop', 'cooked_pogchop', 'beef', 'steak', 'wool', 'treasure_map','wither_skull', 'blaze_rod', 'blaze_power', 'ender_pearl', 'eye_of_ender', 'cobble','coal', 'iron', 'diamond', 'gold', 'netherite_scraps', 'netherite_ingot', 'redstone', 'soul_sand', 'wood', 'bed', 'bedrock', 'bedrock_trophy', 'pog_champ']

    for name in names:
      db[f'{userid}{name}'] = 0
    db[f'{userid}area'] = 1
    db[f'{userid}areaDone'] = 1
#
  area = db[f'{userid}area']
  if area > 0:
```this part is wrong
#

cuz not everyone has the variable area

#

how do i make it works

rose shale
slate swan
#

i want to make a mute command but idk where to start pithink like how to convert the 1s to secs and 2h to hours and stuff

loud junco
#
@bot.command(name ='start')
@commands.cooldown(1, 5, commands.BucketType.user)
async def start(ctx: commands.Context):
  userid = str(ctx.author.id)
  names = ['pogchop', 'cooked_pogchop', 'beef', 'steak', 'wool', 'treasure_map','wither_skull', 'blaze_rod', 'blaze_power', 'ender_pearl', 'eye_of_ender', 'cobble','coal', 'iron', 'diamond', 'gold', 'netherite_scraps', 'netherite_ingot', 'redstone', 'soul_sand', 'wood', 'bed', 'bedrock', 'bedrock_trophy', 'pog_champ']

  for name in names:
    db[f'{userid}{name}'] = 0
  db[f'{userid}area'] = 1
  db[f'{userid}areaDone'] = 1
  await ctx.message.send(f'**{userid}** has reseted his account :D')
```why is this not working
dense swallow
loud junco
#

how to disable error handler

#

its not showing error

dense swallow
#

also u don't need to mention commands.Context for ctx

dense swallow
loud junco
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

loud junco
dense swallow
dense swallow
#

3600*

#

60*60

loud junco
#

sry

dense swallow
loud junco
#

wdym

#

there is no error in my console

#

even i write the wrong command

#

normally there will be
error command None

spring obsidian
#

!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/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.

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

?

spring obsidian
#

!d discord.ext.commands.HelpCommand

unkempt canyonBOT
#

class discord.ext.commands.HelpCommand(*args, **kwargs)```
The base implementation for help command formatting.

Note

Internally instances of this class are deep copied every time the command itself is invoked to prevent a race condition mentioned in [GH-2123](https://github.com/Rapptz/discord.py/issues/2123).

This means that relying on the state of this class to be the same between command invocations would not work as expected.
dense swallow
loud junco
#

btw u know how to fix it ?

dense swallow
loud junco
#

i also dun know the error

dense swallow
#

Idk how to use replit db

loud junco
spring obsidian
loud junco
#

start

spring obsidian
loud junco
#
@bot.command(name ='start')
@commands.cooldown(1, 5, commands.BucketType.user)
async def start(ctx: commands.Context):
  userid = str(ctx.author.id)
  names = ['pogchop', 'cooked_pogchop', 'beef', 'steak', 'wool', 'treasure_map','wither_skull', 'blaze_rod', 'blaze_power', 'ender_pearl', 'eye_of_ender', 'cobble','coal', 'iron', 'diamond', 'gold', 'netherite_scraps', 'netherite_ingot', 'redstone', 'soul_sand', 'wood', 'bed', 'bedrock', 'bedrock_trophy', 'pog_champ']

  for name in names:
    db[f'{userid}{name}'] = 0
  db[f'{userid}area'] = 1
  db[f'{userid}areaDone'] = 1
  await ctx.channel.send(f'**{userid}** has reseted his account :D')
spring obsidian
loud junco
#

db is database

spring obsidian
#

in the command

loud junco
#

thats the problem

boreal ravine
#

its ctx.send

#

you cant send smth to a message object

slate swan
loud junco
#

its working now

slate swan
#

i made a mute command but idk how to convert time to secs like if a user inputs 1h how to get it out of the text and stuff

boreal ravine
loud junco
#

idk how my code works

spring obsidian
loud junco
slate swan
#

no ?

#

not the best way afaik

boreal ravine
#

yes

boreal ravine
#

🤨

spring obsidian
#

okay lemme mention my prob

#

so, how do i make fields in an embed as a grid layout?

#

like it is killing me for a day

#

still I can't solve it

amber stump
#

Anyone here?

spring obsidian
#

yessir

boreal ravine
#

i dont understand what u mean by that

spring obsidian
boreal ravine
amber stump
#

Let's say i have a folder which contains the code and a png file

#

How can i set the image of an embed to that png file

boreal ravine
#

age?

amber stump
#

Cus it says, that it has to be an http/https

sage otter
#

Image

spring obsidian
#

he meant image

sage otter
#

!d discord.File

unkempt canyonBOT
#

class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.

Note

File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
amber stump
#

Yes sorry

sage otter
#

Use that and attach it to the message

spring obsidian
#

btw @boreal ravine this is prob

amber stump
#

Ah

sage otter
#

Then on the set_image()

boreal ravine
amber stump
#

Thx

spring obsidian
sage otter
#

Do url="attachment://file.png

amber stump
#

i type that "attachement"?

sage otter
#

Yeah

spring obsidian
#

pls help

amber stump
#

Ook

boreal ravine
boreal ravine
spring obsidian
boreal ravine
#

👍

amber stump
# unkempt canyon

I store that ina variable right? Then call it in set image (variable.png)

sage otter
#

Just read the example I gave you. It’s everything you need to do.

#

The second argument you pass into the the constructor is the name of the file you want it to be.

amber stump
#

Ook i understand

#

Ty

#

Ohhhh

sage otter
#

Tbh, you don’t even need that if you don’t wanna re-name it.

#

Just pass in the path

amber stump
#

"Pass in the pass" cool

sage otter
#

And in the set_image() put the file attachment://name.ext

amber stump
#

Ook

#

It's clear now

#

Thx

loud junco
#

why cant i get error

boreal ravine
#

do you have an error handler?

loud junco
#

the try ?

boreal ravine
#

ok then

boreal ravine
#

thats python im talking about dpy here

slate swan
loud junco
#
@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.CommandOnCooldown):
        await ctx.send(f'This command is on cooldown, you can use it in **{round(error.retry_after, 2)}** seconds')
boreal ravine
#

thats blocking it

loud junco
#

how do i make it work

slate swan
#

add an py else : raise error and you'll be fine

loud junco
#

idk

#

its in the source code

full valley
#

Hey guys, I'm trying to make a queue system, where players can do a command to queue up, once the command hits 6 players an action happens... Any ideas? I want to be able to have multiple q's in the same channel.

boreal ravine
loud junco
boreal ravine
loud junco
#

and some tutorial

sage otter
slate swan
#

the 2 is used for rounding off till x decimals iirc

boreal ravine
#

I mean I get what your trying to do

slate swan
#

yes

boreal ravine
#

yes

sage otter
#

Or hundedth place whatever you wanna call it

boreal ravine
#

!e

a=5
print(f"{a: .2f}")
unkempt canyonBOT
#

@boreal ravine :white_check_mark: Your eval job has completed with return code 0.

 5.00
boreal ravine
#

^

slate swan
#

imagine using disnake and importing commands from discord.ext to make commands

boreal ravine
loud junco
#

!e
a=5
print(f"{a: .100f}")

unkempt canyonBOT
#

@loud junco :white_check_mark: Your eval job has completed with return code 0.

 5.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
sage otter
boreal ravine
slate swan
# boreal ravine discord?

yeah i mean 😂i just did that and was wondering why the command does not get registered ```py
from discord.ext.commands import command
from . import Cog # imported disnake.ext.commands.Cog

class Thecog(Cog):
@command()``` i had something like this

sage otter
#

I mean it can be. But calling round is cleaner.

slate swan
#

ikk , that should have been disnake but i did discord

boreal ravine
#

lmao

maiden fable
#

Ok so

boreal ravine
#

yes

maiden fable
boreal ravine
#

lmfao

slate swan
#
    async def cog_command_error(self, ctx, error):
        return await ctx.send(embed=discord.Embed(title='oh no an error occured',description=error,color=0x992d22))
    ``` heres my hanlder for around 10 commands
loud junco
#

alright

#

thanks

slate swan
#

!e

import math as pi
print(f"{pi.pi:.100f}")```
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

3.1415926535897931159979634685441851615905761718750000000000000000000000000000000000000000000000000000
loud junco
#

lol

slate swan
#

oh sucks

loud junco
#

disappointment

slate swan
#

indeed

loud junco
#

:D

#

this is only part of them

slate swan
#
    @commands.command()
    async def gay(self,ctx, member : discord.Member) -> str:
        lst = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]
        embed = discord.Embed(title='',description=f'{member.mention} is {random.choice(lst)}% gay :rainbow_flag:')
        await ctx.send(embed=embed)
        await asyncio.sleep(4)
        await ctx.message.delete()``` i want it either to work on the user thats using it or the mentioned i forgot how to do that , should i pass the default argument as  if member is None member = ctx.author or 
member = member or ctx.author ?
loud junco
#

:(

slate swan
#

😔

loud junco
#

im trying to show u

slate swan
#

and yes , the last part you sent

slate swan
#

theres another way

slate swan
#

!e py def func(thing= None): thing = thing or 'other' print(thing) func() func('supplied')

unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

001 | other
002 | supplied
slate swan
#

same goes for your member arg

slate swan
#

!e

x = None
c = 'something'
z = x or c
print(z)```
unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

something
slate swan
#

best way 🙏

slate swan
humble dune
#

who all here are developing discord bots or learning to make pls dm me

full valley
#

Hey guys I'm trying to make a queue system here, anyone know whats going wrong:

inProgress = False
qsize = 6
teamsize = 3
busy = False

@bot.command()
async def q(ctx):
    player = ctx.message.author
    queue = []
    game = []
    if player in q:
        await ctx.send("{} is already in queue.".format(player.display_name))
    if busy == True and player in game:
        await ctx.send ("{} is already in a game.".format(player.display_name))
        return
    await ctx.send("{} added to queue. ({:d}/{:d})".format(player.display_name, qsize, teamsize))
    if len(queue) == qsize:
        ctx.send ("Queue is now full! Type {prefix}captains or {prefix}random to create a game.".format(
                prefix=bot))```
full valley
# humble dune error pls
Ignoring exception in command q:
Traceback (most recent call last):
  File "~", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "~", line 27, in q
    if player in q:
TypeError: argument of type 'Command' is not iterable

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

Traceback (most recent call last):
  File "C:\Users\~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: argument of type 'Command' is not iterable 
humble dune
#

if player in q:

try for player in q

lament mesa
boreal ravine
#

just realized i was talking in the wrong chat

#

😔

full valley
humble dune
fair axle
#

Can anyone give me a example of a select menu/drop down menu
(using dislash.py)

full valley
slate swan
#

There is an example on the GitHub page of the project...

full valley
#

Whats the code to grab the message authors name

slate swan
#

message.author.name

full valley
#

oh KEKW

slate swan
#

or just message.author if you want the discriminator

full valley
#

Yeah but I originally had message.author

#

and it gave it as an object

slate swan
#

Because you should use f-strings

#

!f-strings

unkempt canyonBOT
#

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

full valley
#

?

#

Where

slate swan
#

Instead of .format()

#

Use f-strings to add variables in a string

full valley
#

I'm trying to append the username to the queue list

#

The messages sent by the bot are fine

slate swan
#

And you can just use str(message.author) to get the username and discriminator

#

But yeah, if you just need the username it doesn't matter

full valley
#

so would py queue.append(ctx.message.author.name) work?

boreal ravine
#

if queue is a list then yes

full valley
#

ah yep, cheers

dusk dust
#

can any1 send message to specific channel example?

slate swan
#

Use get_channel(id) save it in a variable and then use .send() on that variable

boreal ravine
#

¯_(ツ)_/¯

slate swan
#

Well you know, searching on your own is complicated

fair axle
slate swan
#

Try it and see

fair axle
#

as i want to permanently track the options so i can edit the output

fair axle
#

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'MessageWithComponents' object has no attribute 'on_dropdown'

#

i copied the code from the example given and replaced it with on_dropdown

#

@slate swan is there any other way i can do it?

slate swan
#

Click on the exact link I sent, you will get to the section of the example

fair axle
slate swan
#

Literally just click on the link I gave........

#

If you want I can copy the code here if it's too complicated

fair axle
#

no

slate swan
#
from discord.ext import commands
from dislash import InteractionClient, SelectMenu, SelectOption

bot = commands.Bot(command_prefix="!")
inter_client = InteractionClient(bot)

@bot.command()
async def test(ctx):
    msg = await ctx.send(
        "This message has a select menu!",
        components=[
            SelectMenu(
                custom_id="test",
                placeholder="Choose up to 2 options",
                max_values=2,
                options=[
                    SelectOption("Option 1", "value 1"),
                    SelectOption("Option 2", "value 2"),
                    SelectOption("Option 3", "value 3")
                ]
            )
        ]
    )
    # Wait for someone to click on it
    inter = await msg.wait_for_dropdown()
    # Send what you received
    labels = [option.label for option in inter.select_menu.selected_options]
    await inter.reply(f"Options: {', '.join(labels)}")

bot.run("BOT_TOKEN")
slate swan
#

As you can see, there is no on_dropdown

slate swan
fair axle
#

but

slate swan
#

If you don't do what we say, why should we help you...

fair axle
#

it is there docs page

boreal ravine
#

does a deleted channel have a mention attr

vocal plover
fair axle
vocal plover
#

but the client wont render it

slate swan
#

hello pppl
i got a error which i dont understand :(

heres the code

boreal ravine
maiden fable
#

@tawdry perch

#

Oops, sorry bro

slate swan
#

You're probably missing a ) or similar

tawdry perch
maiden fable
tawdry perch
#

No problem

#

Cya 👋

maiden fable
#

Cya

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
#

how shud i send long msg

#

:( welp

dense swallow
#

U mean code?

slate swan
#

yes yes

#

Read what's written

dense swallow
#

!paste

unkempt canyonBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

slate swan
slate swan
#

Indentation is not correct

#

See the mainhelp line

#

oo

#

its 4 spaces itselff

#

oh yeah got it now

#

THANKS A LOT :D

slim whale
#
@bot.command()
@commands.is_owner()
async def test(ctx):
  await ctx.send(
    "This is a button",
    components = [
      Button(style=ButtonStyle.blue, label = 'Click Me!')
    ]
  )
  interaction = await slef.bot.wait_for("button_click", check=lambda i: i.components.label.startswith("Click"))
  await interaction.respond(Content="Button Clicked!")```why my button doesnt work?
#

traceback: Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke await ctx.command.invoke(ctx) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke await injected(*ctx.args, **ctx.kwargs) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped raise CommandInvokeError(exc) from exc discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: Object of type Button is not JSON serializable

slate swan
#

Why do you even use self.bot if you're not in a cog

slim whale
#

in the interaction = ?

#

i followed a tutorial XD

slate swan
#

Just don't blindly copy paste

slim whale
slate swan
#

Doubt, have seen this code multiple times already

slim whale
#

xd

slate swan
#

Yeah, that's copy pasting

#

Just not ctrlc ctrlv

slim whale
#

ik but i heard what he was saying

boreal ravine
#

Is there a way to fetch an invite?

slate swan
#

!d discord.ext.commands.Bot.fetch_invite

unkempt canyonBOT
#

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

Gets an [`Invite`](https://discordpy.readthedocs.io/en/master/api.html#discord.Invite "discord.Invite") from a discord.gg URL or ID.

Note

If the invite is for a guild you have not joined, the guild and channel attributes of the returned [`Invite`](https://discordpy.readthedocs.io/en/master/api.html#discord.Invite "discord.Invite") will be [`PartialInviteGuild`](https://discordpy.readthedocs.io/en/master/api.html#discord.PartialInviteGuild "discord.PartialInviteGuild") and [`PartialInviteChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.PartialInviteChannel "discord.PartialInviteChannel") respectively.
boreal ravine
#

hm thanks

#

wait is there not a get version of it

slate swan
#

No

#

Invites cannot really be added in the cache of the bot

#

Or just make your own "caching" system and save/delete invites once new are created/deleted with the correct event

boreal ravine
#

hm

#

thanks