#discord-bots

1 messages · Page 1080 of 1

sand sun
#

I was thinking of putting up some ads on top.gg but their payment system doesn't work

shrewd apex
#

try and reach a deal with some big server moderators so they add your bot in their server

sand sun
#

To twitter!

shrewd apex
#

look for servers who are willing to disboard list and stuff

#

servers who have tags for your target audience

heavy shard
#

@flint isle do you host your bot somewhere?

shrewd apex
#

code?

#

remove the await and try

sick birch
#

If you want to, go ahead

shrewd apex
#

that means i is not an iterable here

#

print i

#

there are changes in 2.0

#

other wise it wouldn't be called 2.0

#

from what i saw yesterday most iterator or functions returning list before have become async generators

#

so u have to iterate using

async for i in list:
      print(i)
vital glacier
#

Does anyone know how to create embed with this:

{content: This is the content part}{embed}{title: This is the embed title}$v{description: This is an embed description}$v{url: https://discord.gg}$v{author: Author Name && https://cdn.discordapp.com/icons/980316232341389413/205c8c67f07e1bd41c186533e9de4f01.png?size=1024 && https://discord.gg}$v{field: This is the field title && This is the field description && true}$v{thumbnail: https://cdn.discordapp.com/icons/980316232341389413/205c8c67f07e1bd41c186533e9de4f01.png?size=1024}$v{image: https://cdn.discordapp.com/icons/980316232341389413/205c8c67f07e1bd41c186533e9de4f01.png?size=1024}$v{footer: This is the footer && https://cdn.discordapp.com/icons/980316232341389413/205c8c67f07e1bd41c186533e9de4f01.png?size=1024}$v{color: #0062ff}$v{button: This is a button && https://discord.gg}

The output is this:
https://tokyotokyotokyotokyo.tokyo/​‌​​‌​‌‌​‌‌​​‌‌​​​‌‌​​​​​‌​​​‌‌‌​‌‌‌​‌​‌​​‌‌​‌‌​​‌‌‌​​‌‌​‌‌​‌‌‌​
(it's basically an embed builder so people can do custom embeds for certain things)

shrewd apex
#

u have to parse this and add the data to your embed field?

vital glacier
shrewd apex
#

so how do people add this data for their embed

slate swan
#

the way you are trying to do it requires good knowledge of regex and logics

paper sluice
#

need command ideas...

shrewd apex
slate swan
#

😂

slate swan
#

🥱 mee6 does that + who tf uses that

shrewd apex
#

u people read manga?pithink

slate swan
#

only when i want to spoil their anime~

shrewd apex
#

lmao

slate swan
shrewd apex
#

lmao all bad people giving spoilers

slate swan
slate swan
#

gets banned , im petty

#

fine

shrewd apex
keen talon
lyric apex
#

How to get this time?

#

Ending time?

slate swan
unkempt canyonBOT
#

discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.10)") for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
lyric apex
#

Not the <t:7373836:R>

slate swan
#

how does that relate?

lyric apex
lyric apex
#

There are integers in it like <t:738272:R>

slate swan
lyric apex
#

Ok

robust fulcrum
#

Guys do owners of python discord change avater of server daily or they have a system in their bot?

#

If there is system in @unkempt canyon can anyone tell me I would i like to make it in my bot

stone beacon
#

It's only changed for events

#

Or for specific months or days

#

The bot repo is public but I have a feel you'd get lost there easily

robust fulcrum
#

Can we change it using bot?

stone beacon
#

No idea

#

You can always Google it real quick

robust fulcrum
#

But they sometimes give deprecated code

#

Or something wrong

stone beacon
#

Check Google to see if it's possible not to copy code

robust fulcrum
#

But me will search GitHub

slate swan
#

!src

unkempt canyonBOT
robust fulcrum
#

I will lost in bot

#

I searched many times

stone beacon
#

Yes you will

robust fulcrum
#

I searched for eval command but very confused

robust fulcrum
stone beacon
#

!d discord.Guild.edit

unkempt canyonBOT
#
await edit(*, reason=..., name=..., description=..., icon=..., banner=..., splash=..., discovery_splash=..., community=..., afk_channel=..., owner=..., afk_timeout=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the guild.

You must have the [`manage_guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_guild "discord.Permissions.manage_guild") permission to edit the guild.

Changed in version 1.4: The rules\_channel and public\_updates\_channel keyword-only parameters were added.

Changed in version 2.0: The discovery\_splash and community keyword-only parameters were added.

Changed in version 2.0: The newly updated guild is returned...
stone beacon
#

Docs have it all my friend

shrewd apex
#

how did ur chem go?

shrewd apex
#

nice

stone beacon
#

Math was horrible

#

First time in my life

#

Broke my heart

shrewd apex
#

OoO happens first times for everything

stone beacon
#

Thankfully I don't need the subject since I've been teaching myself all this time

stone beacon
#

!d bytes

unkempt canyonBOT
#

class bytes([source[, encoding[, errors]]])```
Firstly, the syntax for bytes literals is largely the same as that for string literals, except that a `b` prefix is added:

• Single quotes: `b'still allows embedded "double" quotes'`

• Double quotes: `b"still allows embedded 'single' quotes"`

• Triple quoted: `b'''3 single quotes'''`, `b"""3 double quotes"""`

Only ASCII characters are permitted in bytes literals (regardless of the declared source code encoding). Any binary values over 127 must be entered into bytes literals using the appropriate escape sequence...
robust fulcrum
slate swan
#

try calculus

robust fulcrum
slate swan
#

no, i mean the calculus branch of mathematics

robust fulcrum
#

Oh

shrewd apex
slate swan
#

well i find it tougher than others..

shrewd apex
#

hmm true

slate swan
#

!src

unkempt canyonBOT
robust fulcrum
#

Guys how can we make that if we react to message with bin emoji like @unkempt canyon then it deleates message
Can anyone help me?

robust fulcrum
#

Hmm?

silk fulcrum
#

!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.10)"). 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.10)") 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.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
robust fulcrum
#

It can await bot.wait_for

#

That's for message

silk fulcrum
#

Event will be 'reaction_add'

#

Or something like that

robust fulcrum
#

Check also?

silk fulcrum
#

Check is functiin

robust fulcrum
#

Ik

silk fulcrum
robust fulcrum
slate swan
#

!src d

unkempt canyonBOT
#
Command: docs

Look up documentation for Python symbols.

Source Code
vital glacier
robust fulcrum
jovial plover
#

Can 1 bot have multiple Names, Avatars?

robust fulcrum
#
import discord
from discord.ext import commands
from discord.ext.commands import cooldown, BucketType

def check(msg):
		return msg.author.id == ctx.author.id and msg.channel.id == ctx.channel.id


class suggest(commands.Cog):
	def __init__(self, bot):
		self.bot = bot

	class Select(discord.ui.Select):
		def __init__(self):
			options=[
				discord.SelectOption(label="Option 1",emoji="👌",description="This is option 1!"),
				discord.SelectOption(label="Option 2",emoji="✨",description="This is option 2!"),
				discord.SelectOption(label="Option 3",emoji="🎭",description="This is option 3!")
			]
			super().__init__(placeholder="Select an option",max_values=1,min_values=1,options=options)
				
	class SelectView(discord.ui.View):
		def __init__(self, *, timeout = 180):
			super().__init__(timeout=timeout)
			self.add_item(Select())

	
	@commands.command()
	@commands.cooldown(1, 43200, commands.BucketType.user)
	async def suggest(self, ctx):
		await ctx.send("**Type the suggestion you want to submit**")
		suggestion =  await self.bot.wait_for('message', check=check,timeout=20)
		suggestion = str(suggestion)
		await ctx.send(suggestion,view=Select())



async def setup(bot):
	await bot.add_cog(suggest(bot))

How to fix this error

maiden fable
robust fulcrum
heavy folio
robust fulcrum
#

What

robust fulcrum
heavy folio
#
class A:
  class B:
    ...
  class C:
    ...
robust fulcrum
#

Ok

slate swan
#

nested classes lol

slate swan
# robust fulcrum Ok

better make another file for views and import the view objects from that file (recommended) or just create them outside the cog

shrewd apex
#

thx for the example yesterday helped a lot

robust fulcrum
#

Such errors this ****************** replit gives without any reason

shrewd apex
#

why are u coding on phone?

robust fulcrum
#

My laptop with my dad ;-;

shrewd apex
#

why what were u doing on it🧐

robust fulcrum
robust fulcrum
shrewd apex
robust fulcrum
#

Do you have any solution for it?

shrewd apex
#

for?

robust fulcrum
#

That **** replit

shrewd apex
#

idk try and add import discord on top

slate swan
robust fulcrum
#

Ok

slate swan
#
if message.guild.id == 123. . .:

Says ‘nonetype’ has to attribute ‘id’

robust fulcrum
#

Btw if there is comamnd called >test
And i type >tyst
So i want that my bot send no command called tyst found
How can I do it

slate swan
robust fulcrum
slate swan
#

nice

robust fulcrum
robust fulcrum
#

Me want that if there is comamnd called >test
And i type >teyt (wrong spelling)
So my bot should send no command teyt found
How to do that?

robust fulcrum
#

Means what type

slate swan
#

!d discord.ext.commands.Bot.on_command_error

unkempt canyonBOT
#

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

The default command error handler provided by the bot.

By default this prints to [`sys.stderr`](https://docs.python.org/3/library/sys.html#sys.stderr "(in Python v3.10)") however it could be overridden to have a different implementation.

This only fires if you do not specify any listeners for command error.

Changed in version 2.0: `context` and `exception` parameters are now positional-only.
worn folio
#

Hey everyone, trying to fetch daily no. of users who message/voice in the server. can you please help how can i do it?

worn folio
lyric apex
slate swan
lyric apex
#

?

worn folio
slate swan
lyric apex
#

Ash could you see aboveQtpie

slate swan
#

Hi, I had a problem with replit.com, everything I do says Packag Operation Failed

worn folio
slate swan
lyric apex
worn folio
#

the numbers

lyric apex
#

time.time() should return the unix timestamp

slate swan
#

time is already something else

lyric apex
slate swan
robust fulcrum
#

@slate swan how to fix this error?

slate swan
#

or is it fixed?

slate swan
lyric apex
#

Yep Fixed!py_guido

slate swan
#

wonderful

shrewd apex
# worn folio the numbers

u can just create a log channel in your main server and send the data when commands are being used there

maiden fable
#

And get yr bot ratelimited when multiple commands are invoked at the same time!

slate swan
shrewd apex
slate swan
# shrewd apex do they get ratelimited then how do big bots operate?

logging data in channels instead of a database is just unnecessary requests, and most probably large bots don't do that, so there's no point, also, they are verified and have larger number of requests per second compared to unverified bots. Sorting of data in a discord channel can also be much harder as compared to a database that provides enough flexibility for you to organize your data and you could use other stuff to display your data with a more organized layout

shrewd apex
slate swan
shrewd apex
#

so some bots use pil

slate swan
#

wha-

shrewd apex
#

and u can only send pil images as attachment

shrewd apex
slate swan
#

sure

shrewd apex
#

and file attachments cannot be edited

#

so currently i have a paginated pil images menu

#

which i send the image on a channel and get url from that image

#

and use that url in set image before paginating

slate swan
#

extra work

#

why not use just one url

shrewd apex
#

so i was concerned abt the rate limit part for sending messages in a channel

shrewd apex
#

how do i get that in one url

robust fulcrum
#
class Select(discord.ui.Select):
    def __init__(self):
        options=[
            discord.SelectOption(label="Send!",emoji="✅",description="Send the suggestion!"),
            discord.SelectOption(label="Cancel!",emoji="❌",description="Cancel the suggestion!")
            ]
        super().__init__(placeholder="Select an option",max_values=1,min_values=1,options=options)
    async def callback(self, interaction: discord.Interaction):
        await interaction.response.send_message(content=f"Your choice is {self.values[0]}!",ephemeral=True)

Guys i want that if someone click on then it sends message and if ❌ then not
How to?✅

slate swan
# shrewd apex wdym? like i have 3 pil images

still dont understand, how does it look?
like you got 3 pages with each page containing one image
and that image is set from a url of an image you send in another channel of yours, right?

shrewd apex
#

i can invite u...

slate swan
#

sure

slate swan
shrewd apex
slate swan
#

it does, smh

shrewd apex
#

i tried ysterday

slate swan
#

lemme try

shrewd apex
#

its interaction.data['values']

robust fulcrum
#

Anyway I'll remove it

#

And how can I do that if someone click on green tick the it send something

shrewd apex
#

u have to add a check like if u click this value something will happen

#

also for this use buttons

#

not selection drop

robust fulcrum
#

I want for selection drop

shrewd apex
#

ok..

robust fulcrum
#

How to then?

#

If select.option?

shrewd apex
#

if interaction.data['values'][0] == '✅ '

robust fulcrum
#

Oh k

shrewd apex
#

something along those lines

robust fulcrum
#

@shrewd apex will id of emoji work?

shrewd apex
#

it should

#

depending on what u are getting in interaction.data

#

but pretty sure there is a way to make it work

slate swan
#

it does

shrewd apex
#

linter dosent give error run and see

slate swan
#

have the values

shrewd apex
#

i got error select has not attribute values

#

select here is a class so it will naturally show no error

shrewd apex
#

did u get values when u ran the code coz i didnt get

#

i raised this query yesterday

slate swan
shrewd apex
#

on this channel

#

i can just do it and show

dusky pine
#

uwuView

robust fulcrum
#

@shrewd apex

class Select(discord.ui.Select):
    def __init__(self):
        options=[
            discord.SelectOption(label="Send!",emoji="✅",description="Send the suggestion!"),
            discord.SelectOption(label="Cancel!",emoji="❌",description="Cancel the suggestion!")
            ]
        super().__init__(placeholder="Select an option",max_values=1,min_values=1,options=options)
    async def callback(self, interaction: discord.Interaction):
        if interaction.data['values'][0] == '✅':
            await interaction.response.send_message(content="successfully sent!",ephemeral=True)

It's not working ;-!

shrewd apex
#

print interaction.data

fast musk
#

You need a value kwarg in SelectOption

#

also you don't need interaction.data

#

if you think about it, you are subclassing Select

#

so self is Select... do self.values

young pike
#

Hello, devs!
I want to know the best way to localize text in bot's output. At the moment I store all data at .json file

robust fulcrum
#

Guys how can we do that if someone select a option from drop down bot sends a dm to a particular user
How to?

paper sluice
feral jacinth
robust fulcrum
slate swan
#

even though nobody will use it

feral jacinth
paper sluice
feral jacinth
#

commands.Bot.get_user(id)

slate swan
#

!d discord.ext.commands.Bot.get_user

unkempt canyonBOT
shrewd apex
lyric apex
#

Using tasks loop slow down the bot's speed?Qtpie

slate swan
#

lmao

shrewd apex
lyric apex
jovial plover
#
@client.slash_command(
    base_desc='Shows your Wallet Balance',
    name="wallet",
    options=[
        CommandOption(
            option_type=discord.Member,
            name='member',
            description='Mention the user to check their Wallet Balance.',
            )],
    
    guild_ids=[])

async def test(interaction: discord.ApplicationCommandInteraction, user: discord.Member=None):
        """Shows your wallet balance."""
        if user is not None:
            embed = discord.Embed(title="Wallet",description=f"{user.id}")       
            await interaction.respond(embed=embed)

What is wrong?

maiden fable
#

Something

slate swan
#

that isnt how you create slash commands....

#

or is that disnake as discord

jovial plover
#

Where can i read

#
import discord
from discord import SlashCommandOption as CommandOption, Permissions
import datetime
slate swan
#

what the-

jovial plover
#

Never installed disnake

jovial plover
#
import discord
from discord import SlashCommandOption as CommandOption, Permissions
import datetime

client = discord.Client(sync_commands=True)

@client.slash_command(
    base_desc='Shows your Wallet Balance',
    name="wallet",
    options=[
        CommandOption(
            option_type=discord.Member,
            name='member',
            description='Mention the user to check their Wallet Balance.',
            )],
    
    guild_ids=[])

async def test(interaction: discord.ApplicationCommandInteraction, user: discord.member=None):
        """Shows your wallet balance."""
        if user is not None:
            embed = discord.Embed(title="Wallet",description=f"{user.id}")       
            await interaction.respond(embed=embed)

slate swan
loud junco
#

Impressive imports 💀

slate swan
#

!d discord.app_commands.CommandTree

unkempt canyonBOT
#

class discord.app_commands.CommandTree(client, *, fallback_to_global=True)```
Represents a container that holds application command information.
jovial plover
#

is this not official 😮

slate swan
loud junco
#

But he dont even know indent

paper sluice
#

sad

loud junco
#

And calling me a noob

#

And tells me to leave

#

😂😂😂

jovial plover
#

Hydro seems like a troll tbh.
They send a message, and if nobody replies, they delete their message. 😏

loud junco
#

👀

#

Im a troll whats ur problem

#

But at least i help people out there struggling

#

(if ik how)

#

Better than those that act like pro but knows nothing

paper sluice
#

:hides swiftly:

loud junco
#

Lol

slender flame
#

plz help me on_command_error doesnt work

heavy folio
#

!d discord.ext.commands.Context.send

unkempt canyonBOT
#
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=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.

This works similarly to [`send()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for non-interaction contexts.

For interaction based contexts this does one of the following...
heavy folio
#

use this instead

slender flame
#

ctx.send()?

visual island
slender flame
#

wdym

slate swan
#

whilst currently, ctx works as the exception raised and error works as the context

loud junco
slender flame
#

still not working

loud junco
#

With await in front

#

await ctx.send

slender flame
slate swan
# slender flame

the first argument should be the content of the message, ctx.send will automatically send it to the channel

loud junco
#

I wish im on my pc rn

#

Then i can send u sample

slender flame
#

Lol i forgot i had on command error already

#

so there were 2 and it wasnt workin

#

smh

hidden moss
loud junco
left bolt
#

Hello I have a quesiton, how to do you chance colors of block quotes for bots?

#

hi

#

like that's grey but how do i make it blue for my bot? ^

maiden fable
#

U can't @left bolt

left bolt
#

red, yellow?

maiden fable
left bolt
maiden fable
#

Rip no embed

#

@left bolt I got it

#

!d discord.Embed

unkempt canyonBOT
#

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

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

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

New in version 2.0.

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

Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
maiden fable
#

!d discord.Embed.colour

unkempt canyonBOT
#

The colour code of the embed. Aliased to color as well. This can be set during initialisation.

loud junco
#

U click on it

#

It will redirect u to a website

exotic maple
#

How would i make an interactive setup command?

For example,

It will send a message and the user then sends what its asking for such as a role etc.

And it stores that role and moves onto the next message?

robust fulcrum
slate swan
#

its an even like on_message is

loud junco
#

im making a new repl

#

with 20+ file

#

copy pasta manually

lyric apex
#

I am using sqlite3 and i made new db and disk is having enough space still this error

slate swan
#

is it hosted on a VPS? seems like they are not allowing to perform write Operation

slate swan
#

restarting your project may fix it

lyric apex
lyric apex
loud junco
#

how to update discord to latest version again

#

the github thing

#

but i only have 1.7.3

#
async def main():
  async with bot:
    (await bot.load_extension(f"commando.{file[:-3]}") for file in os.listdir("commando/") if file.endswith(".py"))
    await bot.start(os.getenv('TOKEN'))

asyncio.run(main())
shrewd apex
loud junco
#

but she say i need 1.8

shrewd apex
#

what 1.8? bot.start is there only in 2.0

loud junco
#

ei

#

python 3.8

shrewd apex
#

python 3.8+

loud junco
#

alright

shrewd apex
#

for dpy 2.0

loud junco
shrewd apex
#

pip uninstall discord.py==1.7.3

loud junco
#

ok

shrewd apex
#

u can unistall calling strong equality

loud junco
#

ok

#

this is normal right?

shrewd apex
#

just telling to uninstall since the code may take 1.7.3 as default it's better to work with a cleaner venv

#

yeah

#

all good

loud junco
#

ok

shrewd apex
#

u on 2.0

#

now

loud junco
#

?

#

it deleted for me automatically?

shrewd apex
#

yeah

#

it unistall old builds

#

i thought u hadn't installed it yet so...

loud junco
#

oo

tacit token
#

hi guys, how can i import the created_at to 6days ago or
6 months ago

#

if the member acc 356days older the bot write 1 year ago..

shrewd apex
#

make a function to do that

loud junco
#

my bot is back to gg

#

but its not doing anything

tacit token
loud junco
shrewd apex
#

hmm

slate swan
#
@commands.Cog.listener(name="on_member_remove")
        @commands.guild_only()
        async def fm(member):
            await member.ban(reason="User left while freeloader mode was on.")

user isnt banned on leave

shrewd apex
#

not even the help command?

loud junco
#

but its printing the we have logged in as blahblah thing

slate swan
#

why at on_ready

loud junco
#

look at the indent

#

its not inside

#

and it works also XD

visual island
# loud junco

You need to enable message_content intents, it's required for seeing message contents in v2.0

shrewd apex
#

do Intents.all()

loud junco
#

ok

paper sluice
# loud junco

commands.Bot(..., case_insensitive=True,) instead of having a list of all prefix names

loud junco
#

ok

paper sluice
#

waiyt

#

does that work in prefixes

#

hold

loud junco
#

no

paper sluice
#

sad

loud junco
#

lol

paper sluice
#

it works on commands

loud junco
#

its replying

#

but its not loading the thing it should have load

paper sluice
#

what import?

loud junco
#

@paper sluice

shrewd apex
#

cogs are not loaded?

loud junco
#

ya

paper sluice
#

any errors?

loud junco
#

no

#

and 1111111111111111 is printed as well

shrewd apex
#

try once again but this time with the for loop properly and print statement in the midlle

loud junco
#

?

shrewd apex
#

like print(f"loaded {cog}")

loud junco
#

okok

#
(await bot.load_extension(f"commando.{file[:-3]}") for file in os.listdir("commando/") if file.endswith(".py"))
```how tho
paper sluice
#
(print(f"commando.{file[:-3]}") for file in os.listdir("commando/") if file.endswith(".py"))
#

wait, i got it

#

change it to a list comp, its a generator right noew

shrewd apex
#

() this gives an async generator object here

loud junco
#

?

paper sluice
#

[...]

shrewd apex
#

thats why i said to take it out and try

shrewd apex
paper sluice
# loud junco ?

basically anything inside a generator doesn't get executed unless u iterate over it

shrewd apex
#

we can compress/one liner it later

loud junco
#

so...

#

what do i do

paper sluice
#
for file in ...:
    if file ...:
        await load...('commando....')
shrewd apex
#
for file in os.listdir("commando/"):
   if file.endswith(".py"): 
       await bot.load_extension(f"commando.{file[:-3]}")
       print(f"loaded {file}")
loud junco
#

its working

#

i mean the whole bot is working

#

loaded everything

#

@shrewd apex @paper sluice

paper sluice
#

nice

shrewd apex
#

yeah the generator object was the problem

#

now try with list as ryuga said

loud junco
#

how

shrewd apex
#

cause as far as i remember generator yields the first object and stops

#

and waits for the call on the next object

shrewd apex
# loud junco how

its not exactly necessary here tho but u can try by just replacing () with []

shrewd apex
#
[await bot.load_extension(f"commando.{file[:-3]}") for file in os.listdir("commando/") if file.endswith(".py")]
shrewd apex
#

yeah

loud junco
loud junco
shrewd apex
shrewd apex
loud junco
#

ok

loud junco
#

yes

shrewd apex
#

nice

loud junco
#

nc

#

everything is working as intended

slate swan
shrewd apex
#

good afternoon

#

he is using start now

slate swan
#

afternoon Lord

loud junco
#

🤣

loud junco
shrewd apex
#

1pm arnd

#

for ash

#

6:22pm for me

loud junco
#

1am

#

💀

slate swan
slate swan
shrewd apex
#

hmm

#

welp back to pil i guess for me i hate finding co ordinates on image to paste such a chore

slate swan
#

Possible to do like
If the user uses a?truth (mentions a user) and the bot returns {ctx.author.mention} asked (the user mentioned after a?truth)

shrewd apex
visual island
#

No, cause async function doesn't handle blocking code

#

It just allows you to run that function as a task and asynchronously

paper sluice
shrewd apex
#

so how to run them in executorpithink

slate swan
visual island
unkempt canyonBOT
#

awaitable loop.run_in_executor(executor, func, *args)```
Arrange for *func* to be called in the specified executor.

The *executor* argument should be an [`concurrent.futures.Executor`](https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.Executor "concurrent.futures.Executor") instance. The default executor is used if *executor* is `None`.

Example:
paper sluice
#

spawn a thread and run the blocking code there

visual island
#

pass None to the executor

robust fulcrum
#
import discord
from discord.ext import commands
from replit import db
import asyncio

db["likes"] = "test"

if db["likes"] == "test":
    db["likes"] = 0
    

class vote(commands.Cog):
    def __init__(self, bot):
	    self.bot = bot

    @commands.command()
    async def vote(self, ctx):
	    await ctx.send("voting..... ")
	    await asyncio.sleep(2)
	    like = int(db["likes"]+1)
	    db["likes"] = like
	    await ctx.send(f"successfully vpted! we have {like} votes now")
	    
    
    
async def setup(bot):
	await bot.add_cog(vote(bot))

Guys my command is not working and even it's not showing any error
Can anyone help me?

visual island
shrewd apex
visual island
slate swan
shrewd apex
#

ok

slate swan
robust fulcrum
#

See all are enabled

shrewd apex
visual island
# robust fulcrum

Don't show screenshot, paste the code here, we can't see if you passed the intents correctly to your bot instance

shrewd apex
#

ok cool lemme do that

slate swan
#
asyncio.get_event_loop().run_until_complete(func())```
is another alternative but wont recommend it
robust fulcrum
#
intents = discord.Intents.all()
bot = commands.Bot(command_prefix=">", intents=intents)
visual island
#

Commands not triggering as usual

slate swan
#

all commands?

visual island
#

@robust fulcrum do you have on_message event?

visual island
robust fulcrum
#

It's command ;-;

slate swan
slate swan
slate swan
visual island
slate swan
torn sail
#

Oh ok

#

Didn’t see

slate swan
shrewd apex
torn sail
#

You would need to use run_in_executor (or asyncio.to_thread) on the pil functions within the async function

slate swan
#

^

shrewd apex
#
async def image(parameters):
     #pil stuff
     # return image
#in bot 
foo = ___
slate swan
#
async def open_image():
  im = await bot.loop.run_in_executor(None, Image.open("_.png"))  
  return im

#command
await open_image()
shrewd apex
#

foo is where i call the function

slate swan
slate swan
shrewd apex
#

ok so i need to only make the image open part run in executor or every single pil line

robust fulcrum
robust fulcrum
slate swan
# slate swan wait what?
@commands.command()
    async def truth(self, ctx, member: discord.Member):
       tEmbed = discord.Embed(titlle=f"{ctx.author.name} asked  {member.name}", description=random.choice(truth), color = discord.Colour.dark_theme())
       tEmbed.set_footer("More truths will be added in future.")
``` code ^
slate swan
slate swan
slate swan
visual island
slate swan
robust fulcrum
slate swan
#

The member is underlined in the code

#

ide issue

#

restart the IDE

shrewd apex
robust fulcrum
shrewd apex
#

so it's tough to make the function sync

paper sluice
slate swan
slate swan
visual island
slate swan
robust fulcrum
shrewd apex
#

sad me

shrewd apex
torn sail
robust fulcrum
slate swan
robust fulcrum
#

No

torn sail
slate swan
#

@robust fulcrum can you send your main bot file

robust fulcrum
#

Ok

slate swan
visual island
flint isle
#

which version is reccomended to be a database for a discord bot?

shrewd apex
slate swan
robust fulcrum
#

@slate swan do you have replit I'll send multiplayer link?

slate swan
flint isle
#

ok

shrewd apex
slate swan
loud junco
#

can someone get me the embed link?

visual island
shrewd apex
#

unless i call that function before and send data as parameters

slate swan
unkempt canyonBOT
#

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

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

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

New in version 2.0.

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

Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
loud junco
#

thankss

torn sail
flint isle
sweet chasm
#

if u want

shrewd apex
robust fulcrum
#

!paste

slate swan
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
#

is there sample code for embed?

#

like general layout

slate swan
slate swan
#

ohk

paper sluice
loud junco
#

ye

#

i use colour and always get error

robust fulcrum
slate swan
loud junco
#

because its color 🤣

loud junco
paper sluice
loud junco
#

americaners

jade tartan
#
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\Main.py", line 2, in <module>
    from   discord.ext import commands
ImportError: cannot import name 'commands' from 'discord.ext' (unknown location)```
torn sail
slate swan
loud junco
jade tartan
#

Someone

slate swan
slate swan
sweet chasm
visual island
sweet chasm
#

lol

visual island
torn sail
west wigeon
slate swan
sweet chasm
#

amercan?

loud junco
#

alright imma stop

#

going to get oted

sweet chasm
#

lol

loud junco
#

🤣

jade tartan
loud junco
#

btw this is correct right?

west wigeon
#

yes, but maybe not where you thought it was installed

paper sluice
slate swan
visual island
loud junco
#

ctx.author.display_name or ctx.author.display.name

jade tartan
#

I have this installed discord.py==1.7.3

loud junco
slate swan
loud junco
#

so i just copy paste this and started modifying it

west wigeon
jade tartan
west wigeon
slate swan
#

maybe you have multiple versions of python installed?

west wigeon
#

yeah, that's what i'm thinking

slate swan
#

wait wth is discord-ext-bot, these packages mess with the library iternals

#

!pip discord-ext-bot

unkempt canyonBOT
jade tartan
#

Would you like me to show the extentions that i have installed?

slate swan
#

yeah thats the issue

west wigeon
#

oof

slate swan
#

this library if forcing you to use ```py
from discord.ext import bot

bot = bot.Bot()

jade tartan
#

vsc

#

?

slate swan
#

start with deleting the useless 3rd party libraries.

west wigeon
west wigeon
# jade tartan Meaning?

meaning sloppy grammar and "no longer maintained" doesn't exactly recommend these packages to you

#

if you're following someone's outdated tutorial to make a bot with these, just don't.

paper sluice
#

ya, but i dont think there is anything that lib offers which 1.7.3 doesn't have

shrewd apex
#
place = await bot.loop.run_in_executor(None, image(kwargs))
def image(kwargs):
   #pil stuff
   #returns a tuple 

Error

TypeError: 'tuple' object is not callable
paper sluice
#

no i mean discord-ext-bot doesn't offer anything which 1.7.3 doesn't have

shrewd apex
paper sluice
unkempt canyonBOT
#

functools.partial(func, /, *args, **keywords)```
Return a new [partial object](https://docs.python.org/3/library/functools.html#partial-objects) which when called will behave like *func* called with the positional arguments *args* and keyword arguments *keywords*. If more arguments are supplied to the call, they are appended to *args*. If additional keyword arguments are supplied, they extend and override *keywords*. Roughly equivalent to:

```py
def partial(func, /, *args, **keywords):
    def newfunc(*fargs, **fkeywords):
        newkeywords = {**keywords, **fkeywords}
        return func(*args, *fargs, **newkeywords)
    newfunc.func = func
    newfunc.args = args
    newfunc.keywords = keywords
    return newfunc
shrewd apex
paper sluice
#

it means discord-ext-bot requires discord

#

Required-by: discord, discord-ext-bot, discord-ext-ipc

paper sluice
# shrewd apex could u elaborate?

!e

from functools import partial

def call(func):
    return func()

def foo(a, b, c):
    print(a, b, c)
    return 1

print(call(partial(foo, 1, 2, 3)))
unkempt canyonBOT
#

@paper sluice :white_check_mark: Your eval job has completed with return code 0.

001 | 1 2 3
002 | 1
slate swan
visual island
slate swan
slate swan
#

oh i didn't read that messagepWut

paper sluice
# shrewd apex could u elaborate?

partial takes the function and the args, then call calls partial which returns the function with filling the arguments then call can do foo() without having to fill the args

slate swan
unkempt canyonBOT
#

extensions/Admin.py lines 4 to 7

class Admin(lightbulb.Plugin):
    def __init__(self):
        self.bot: lightbulb.BotApp
        super().__init__(name="Admin Commands", description="Bot Admin Commands")```
robust fulcrum
west wigeon
#

probably good to confirm what @jade tartan is trying to accomplish, anyway. the discord-ext-ipc extension looks like something to communicate between a client (e.g. webapp) and the bot via RPC. so if the problem is the extensions are interfering (which we haven't confirmed yet), then simply dropping the extensions is not a whole solution. edit: oh, except others have suggested only to drop discord-ext-bot, which i agree with. maybe you can keep the ipc one, though my concern is that it's discontinued so might also give you trouble

slate swan
robust fulcrum
#

Idk how

slate swan
shrewd apex
#

now i made image an async function it gave me a coro back and i awaited that coro and i got the result i wanted

#

so is it possible that this work even if the function is not sync?

slate swan
#

and I just find it better, I know you can just plugin = lightbulb.Plugin(...)

shrewd apex
#
place = await bot.loop.run_in_executor(None, parital(image, x, y, z))# gave back a coro
place = await place # i got the desired result
async def image(kwargs):
   #pil stuff
   #returns a tuple 
slate swan
shrewd apex
paper sluice
#

when its sync

loud junco
#

i wrote rpm load farm

#

no output

shrewd apex
slate swan
#

pQuack bot.loop is an asyncio.loop itself

visual island
slate swan
shrewd apex
#

when i awaited it again i got what i wanted

slate swan
slate swan
loud junco
slate swan
visual island
slate swan
loud junco
shrewd apex
slate swan
loud junco
#

but every single community server out there: NO ADVERTISING

slate swan
slate swan
loud junco
slate swan
#

even tho people won't use it, but the server count will keep increasing

loud junco
#

im december boi

#

;-;

shrewd apex
fallow mauve
#

someone asked me to make an 8ball command for my bot, so i started making it today. however, apparently the question arg cannot be used alongside .endswith, how would i fix this?

  @commands.command(name="eightballball", aliases=["8ball"])
  async def eightball(self, ctx: commands.Context, *, question=None):
    if question.endswith("?"):
      await ctx.send("Question mark detected.")
    elif question == None:
      await ctx.send("Please include a question in your command.")
    else:
      await ctx.reply("No question detected. Make sure to add a question mark to the end of your command.")
loud junco
slate swan
loud junco
paper sluice
loud junco
#

no

shrewd apex
#

any way to do this in one line?

place = await bot.loop.run_in_executor(None, partial(posi, x, y, 'pad'))
place = await place
loud junco
paper sluice
slate swan
loud junco
#

uwu

loud junco
#

🤣

paper sluice
shrewd apex
slate swan
paper sluice
fallow mauve
shrewd apex
shrewd apex
paper sluice
shrewd apex
#

it creates a thread...

paper sluice
slate swan
#

why run a function in a thread tho?

paper sluice
#

blockin

shrewd apex
#

yeah so exeuctor here apparently runs async too and gives back a coro which i awaited and got the result

slate swan
#

just use a Task?

visual island
fallow mauve
# slate swan uh?

questions.endswith will only give me an extra error. i cant use .endswith with an arg bcs it gives me an error, how do i work around this

loud junco
#
from discord.ext import commands
import discord

class Trade(commands.Cog):
  def __init__(self, bot):
    self.bot = bot

  @commands.command()
  @commands.cooldown(1, 1, commands.BucketType.user)
  async def farm(self, ctx):
    embed = discord.Embed(
        description = f'''
.........
    ''', 
        color = discord.Color.blue())
    embed.set_thumbnail(url = ctx.author.avatar.url)
    embed.set_author(name= f"{ctx.author.display_name}'s trade", 
    icon_url = ctx.author.avatar.url)
    await ctx.send(embed=embed)
  
def setup(bot):
    bot.add_cog(Trade(bot))
#

is this correct?

shrewd apex
shrewd apex
robust fulcrum
#

Guys is there any image recognisation library in python?

slate swan
#

tensorflow

#

!pip tensorflow

unkempt canyonBOT
shrewd apex
paper sluice
fallow mauve
maiden fable
slate swan
visual island
fallow mauve
#

still doesnt work

paper sluice
slate swan
loud junco
visual island
#

and this is with a sync func

paper sluice
fallow mauve
slate swan
fallow mauve
# slate swan show traceback
Traceback (most recent call last):
  File "/home/runner/Yggdrasil-Bot/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/runner/Yggdrasil-Bot/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/runner/Yggdrasil-Bot/venv/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: AttributeError: 'NoneType' object has no attribute 'endswith'
paper sluice
#

question is None...

fallow mauve
slate swan
paper sluice
paper sluice
#

like?

slate swan
#

you have to keep the conditional that checks question is None at the top, iirc it was the 2nd conditional instead, and you were checking it after checking if the question endswith a question mark

fallow mauve
slate swan
#

that's the issue

loud junco
paper sluice
# fallow mauve yes

do this

async def ...(..., question: str | None = None):
    if question is None:
        ...
        return
    rest of the code
paper sluice
#

💀

visual island
slate swan
hearty shore
slate swan
fallow mauve
#

@slate swan @paper sluice got it to work thx for the help

slate swan
#

thank Ryuga

visual island
slate swan
#

!pep 484

unkempt canyonBOT
#
**PEP 484 - Type Hints**
Status

Final

Python-Version

3.5

Created

29-Sep-2014

Type

Standards Track

slate swan
#

then dont be confusinggrump

#

ash being confused is persistent

#

Most of the time, I don't even know what I write

#

🛌

#

wish

loud junco
#

sry accidentally pinged

slate swan
#

its okay

slate swan
slate swan
loud junco
#

but where =.=

slate swan
#
async def setup(bot: commands.Bot) -> None:
  await bot.add_cog(...(bot))
loud junco
#

oo

slate swan
#

yeah it needs to be a coroutine object so you can await it because since it was a function it just returned None which you then awaitedpWut

visual island
slate swan
loud junco
#

ok

slate swan
# loud junco

why do I always get ignored even after giving a full-fleshed example which are wrong 75% of the times

devout iris
#

Hia, i'm trynna set a variable bot's latency, but i'm getting NaN type....

slate swan
loud junco
devout iris
loud junco
#

didnt see the async up there

slate swan
#

websocket

loud junco
#

.<

devout iris
#

Ah

slate swan
loud junco
#

arg is string by default right?

devout iris
#

Well, how can i make a command like ping command but without gettin' NaN type?

visual island
#

It shouldn't return NaN

devout iris
#

Yes

visual island
#

oh yeah it can

slate swan
#
self.latency = float(self.hb or "Nan")
``` dpy does something like this
loud junco
#
@bot.command()
@commands.cooldown(1, 1, commands.BucketType.user)
async def ping(self, ctx):
  await ctx.send(f"Pong! {round(bot.latency * 1000)}ms")
visual island
slate swan
#

its returning None because it hasnt connected to the ws yet😅

devout iris
#

I've already a ping command. I'm just trynna make a command that command makes set ping variable and uses it.

light violet
#

@scarlet sorrel send text as file

visual island
#

yeah, you can't access it if the bot isn't connected yet

slate swan
#

the value of ping is never constant + why would you want it to be

#

yeah the latency is always dynamic

loud junco
devout iris
#

Just like that:

ping = bot.latency*1000

if ping > 100:
    .....("good")
.....

#

Should i add

@bot.command() decorator
???

slate swan
#

you cant do it outside a function invoked before the bot is running

devout iris
slate swan
slate swan
devout iris
#

It is so complex

#

Let me send it

slate swan
#

if statements? complex?

#

ill show you ```py
bot = commands.Bot()

ping = bot.latency*1000

if ping > 100:
.....("good")
.....

bot.run()

devout iris
slate swan
#

why would you paste all of your code

devout iris
#

(I said, that code so complex and you can't read it probably

slate swan
#

just paste the part

devout iris
#

Then you should wait a bit, cus so complex

slate swan
#

... that part is not in the file...

slate swan
#
from discord.ext import commands
import discord

intents = discord.Intents.default()
intents.message_content = True

bot = commands.Bot(command_prefix="uwu", intents=intents)

@bot.command()
async def ping(ctx: commands.Context) -> None:
  await ctx.send(f"{bot.latency*1000}")

bot.run("TOKEN")
devout iris
slate swan
slate swan
slate swan
#

😔 makes sense

#

yeah give her a break shes using return annotations pWut

paper sluice
#

👀

slate swan
maiden fable
slate swan
#

pBear i don't see why return annotations matter for a bot command... its not like it will speed up the code or you'll be calling that function elsewhere

slate swan
paper sluice
#

just good practice

slate swan
#

but yeah, typing is cool

#

habbit

slate swan
slate swan
loud junco
#
@commands.command()
@commands.cooldown(1, 1, commands.BucketType.user)
async def trade(self, ctx, arg):
```arg is string by default right?
loud junco
#

ok

slate swan
#

pithink me wondering how ppl even do that

loud junco
#

i need one more name

#

hmmm who should i put

slate swan
#

both 50 commands & texting thing

loud junco
#

ryuga 👍

slate swan
heady sluice
#

sad woman noises

slate swan
#

or maybe i should just stop being a lazy typer.

#

I feel you

loud junco
slate swan
#

i just check my insta for cat memespWut

loud junco
#

🤣

maiden fable
#

Might as well take this to OT

loud junco
slate swan
heady sluice
maiden fable
#

You're welcome

heady sluice
#

thank you

slate swan
#

polite

robust fulcrum
#
    @vote.error
    async def vote_error(ctx, error):
        if isinstance(error, commands.CommandOnCooldown):
            em = discord.Embed(title=f"Cooldown you cant vote yet!",description=f"Try again in {error.retry_after:.2f}s.", color=discord.Color.red())
            await ctx.send(embed=em)

Guys is this error handler correct?

robust fulcrum
heady sluice
#

you didn't put
else: raise error

robust fulcrum
#

Where I have ti put else?

heady sluice
#

after the if

robust fulcrum
#

Oh k

heady sluice
#

what kinda question was that

robust fulcrum
#

And do i need to put ()?

heady sluice
#

no

robust fulcrum
#

@heady sluice is there any library to covert seconds into minutes?

unkempt canyonBOT
#

class datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)```
All arguments are optional and default to `0`. Arguments may be integers or floats, and may be positive or negative.

Only *days*, *seconds* and *microseconds* are stored internally. Arguments are converted to those units...
paper sluice
#

its just seconds // 60

slate swan
#

or that

robust fulcrum
#

Understood!

slate swan
#

just divide it by 60

robust fulcrum
#

That's easy but just asking for my knowledge

#

Is there any library btw?

slate swan
#

am broken

robust fulcrum
#

Divide

paper sluice
robust fulcrum
#

Multiply will do into milliseconds

heady sluice
#

you would multiply by 1000

robust fulcrum
#

Anyways just i would go for simple

heady sluice
#

mille means 1000

slate swan
heady sluice
#

megaew

slate swan
#

!e

import datetime

print(str(datetime.timedelta(seconds=70-1)))
unkempt canyonBOT
#

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

0:01:09
heady sluice
#

I mean it looks cool

#

I take it back

slate swan
heady sluice
#

no

robust fulcrum
#

@slate swan i have a variable {error.retry_after:.2f} how can I put it into formated_time varibable?

slate swan
#

ask meh, he's better

robust fulcrum
#

@heady sluice can you tell me?

robust fulcrum
paper sluice
#

meh decorator lemon_hyperpleased

heady sluice
#

also print type

robust fulcrum
heady sluice
slate swan
robust fulcrum
#

Why print i want to just put in variable

heady sluice
#

oh my nickname

heady sluice
slate swan
#

what

heady sluice
#

where to put it

slate swan
#

well, help him then

robust fulcrum
# heady sluice print it and show results
    @vote.error
    async def vote_error(ctx, error):
        if isinstance(error, commands.CommandOnCooldown):
            em = discord.Embed(title=f"Cooldown you cant vote yet!",description=f"Try again in {error.retry_after:.2f}s.", color=discord.Color.red())
            await ctx.send(embed=em)
        else:
            raise error

I just want to replace {error.retry_after:.2f} into a variable

dull stirrup
#

I'm trying to send multiple images from a sqlite database using a simple plugin, problem is it always sends the links then the images afterward, anyone know how to simply hide the urls so only the images are visible?

heady sluice
#

import datetime

hello = str(datetime.timedelta(seconds=error.retry_after:.2f))