#discord-bots

1 messages Β· Page 1081 of 1

robust fulcrum
#

Ok

paper sluice
#

u forgot fstring

slate swan
heady sluice
#

why you need f-string

paper sluice
#

then what is :.2f

heady sluice
#

2 decimals

slate swan
paper sluice
#

ya but that only works in fstrings πŸ˜”

slate swan
#

!e

num = 90.0088757774884

print(f"{num:.2f}")
#

yes it does work with strings only

heady sluice
#

does it actually

#

tf

#

python pythoningn't

unkempt canyonBOT
#

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

90.01
slate swan
#

Ryuga's really smort ngl

paper sluice
#

syntax for fstrings are {object_with_ __format__:<formatter>}

heady sluice
#
import datetime

hello = str(datetime.timedelta(seconds=float(f"{error.retry_after:.2f}")))
#

nah not int

#

float

robust fulcrum
#

@heady sluice

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

It says invalid syntax

heady sluice
#

GRRRR

robust fulcrum
heady sluice
#

read conversation

paper sluice
#

!e

class Foo:
    def __format__(self, formatter):
          if formatter == '#':
                return 'u said #'
print(f'{Foo():#}')
unkempt canyonBOT
#

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

u said #
heady sluice
#

ryuga smart

heady sluice
robust fulcrum
#

Ok

robust fulcrum
paper sluice
#

its supposed to return str

#

always

robust fulcrum
heady sluice
#

cog command without self

robust fulcrum
#

Errors everywhere!

robust fulcrum
#

Everywhere self!

heady sluice
#

bro I'm calling it

#

I speak computer

robust fulcrum
#

Why replit always say poetry add aiohttp everytime even i have downloaded it

heady sluice
#

you're using replit

#

you kind of deserve the suffer it offers

robust fulcrum
#

Why my bot sending a weird thing

#

Why .76000 at back?

#

Is there anything to remove that?

paper sluice
robust fulcrum
paper sluice
dull stirrup
#

essentially only sending the preview of the image and hiding the link

robust fulcrum
#

Guys is there any event that if anyone use any command it gets triggered
Cause i don't want to add print in all commands
Is there any way if there pls tell!

hushed galleon
#

there's the on_command event

analog snow
#

Can anyone give me guidance on how to create discord bots using python?

west wigeon
#

get it installed and follow the Quickstart

analog snow
#

Ok tysm

fallow mauve
#
class SayCommand(commands.Cog):

  def __init__(self, bot: commands.Bot):
      self.bot = bot
      self.last_msg = None



  @commands.listener()
  async def on_message_delete(message):
    self.last_msg = message
```snipe command is being stupid and not working for me, what is wrong with this on message delete event?
maiden fable
fallow mauve
slate swan
#

the message isnt in the cache of the bot then

fallow mauve
#

huh?

slate swan
#

and make sure the cog is loaded

fallow mauve
#

it is loaded

slate swan
#

idk how you even got it to work without errors

fallow mauve
#

i misss self?

#

huh?

slate swan
#

oh wait nvm

slate swan
#

!self

unkempt canyonBOT
#

Class instance

When calling a method from a class instance (ie. instance.method()), the instance itself will automatically be passed as the first argument implicitly. By convention, we call this self, but it could technically be called any valid variable name.

class Foo:
    def bar(self):
        print('bar')

    def spam(self, eggs):
        print(eggs)

foo = Foo()

If we call foo.bar(), it is equivalent to doing Foo.bar(foo). Our instance foo is passed for us to the bar function, so while we initially gave zero arguments, it is actually called with one.

Similarly if we call foo.spam('ham'), it is equivalent to
doing Foo.spam(foo, 'ham').

Why is this useful?

Methods do not inherently have access to attributes defined in the class. In order for any one method to be able to access other methods or variables defined in the class, it must have access to the instance.

Consider if outside the class, we tried to do this: spam(foo, 'ham'). This would give an error, because we don't have access to the spam method directly, we have to call it by doing foo.spam('ham'). This is also the case inside of the class. If we wanted to call the bar method inside the spam method, we'd have to do self.bar(), just doing bar() would give an error.

slate swan
#

learn python classes πŸšΆβ€β™‚οΈ

fallow mauve
#

oh im so stupid...

#

i knew that

#

how did i not see that xD

slate swan
fallow mauve
slate swan
#

thank sarthak

#

ash sleeping for 19hrs straight

slate swan
#

πŸ˜” thats a wamen of culture

west wigeon
slate swan
#

the python extension already has tools for that included

#

^

west wigeon
slate swan
#

what the hell

#

sorry

#

πŸ˜‚

fallow mauve
#

im honestly confused now

gaunt mortar
#

Good afternoon, is it possible to know the locale (the language used by someone on discord) when someone uses a command ?

fallow mauve
#

wait nvm

slate swan
fallow mauve
unkempt canyonBOT
gaunt mortar
#

Shall I get it from the message that triggered the command ? (Message got an interaction attribute I swear)

sick birch
#

Regular commands and messages don't have interactions, if that's what you mean

slate swan
#

How to do it? Correctly

lyric apex
#

Can we get the permission which the ctx command uses?

gaunt mortar
slate swan
#

Help

sick birch
paper sluice
sick birch
#

Regular, text-based command with a traditional prefix like !, or the newish slash commands, for which you type /?

slate swan
gaunt mortar
sick birch
#

In that case getting the locale from the interaction object is not possible, due to the fact that there is no interaction object

gaunt mortar
sick birch
#

Unless you migrate to slash commands

#

Or you have a database of users and their preferred languages

gaunt mortar
#

I have not checked what are these slash commands so far, I guess I should xD

sick birch
#

You should, as discord recommends (read: forces) you to migrate to them

maiden fable
#

These are the commands that popup when u type /

gaunt mortar
slate swan
dull stirrup
#

any way I can hide an image's url?

maiden fable
#

hide an image url? @dull stirrup

scarlet aurora
#

copy and paste the image, not the link

#

or download the image and send it

dull stirrup
#

I'm taking the urls from a database, then sending them seperated by a space

scarlet aurora
#

put the web address in

scarlet aurora
slate swan
scarlet aurora
dull stirrup
#

It's currently not sending them in an embed

slate swan
dull stirrup
#

sec

slate swan
#

can you tell me how can i get arguments that user passed

dull stirrup
#
@client.command()
@is_registered
async def collection(ctx: commands.Context):
    await economy.is_registered(ctx.message.author.id)
    user_account = await economy.get_user(ctx.message.author.id)
    await ctx.send(f"{ctx.message.author.name}'s Collection:\n{' '.join(user_account.items)}")
slate swan
#

where embed at with image

dull stirrup
#

It's sending multiple links, embeds can only use 1 image

slate swan
#

$setactivity <argument> <argument2>

dull stirrup
#

if I embed it, it will break

scarlet aurora
#

async def command_name(ctx, argument1, argument2)

slate swan
#

Help me with This thing

slate swan
scarlet aurora
dull stirrup
#

I can't put 3 images in the same embed

slate swan
#

It means not working

#

try to pass it as a string

slate swan
#

Can you type it hete

slate swan
scarlet aurora
#

yes

scarlet aurora
slate swan
scarlet aurora
#

what he put was correct for integers

slate swan
scarlet aurora
dull stirrup
#

is there someway I could make my webhook send as many embeds as I have image urls (changes often)

scarlet aurora
#

send 1 image per embed?

#

then send however many embeds u need

#

for urls in wherever:
(send embed)

slate swan
scarlet aurora
#

auschwitz

slate swan
#

shh

sick birch
#

I don't believe discord.type is a thing

dull stirrup
slate swan
dull stirrup
#

so ye

slate swan
scarlet aurora
slate swan
scarlet aurora
#

yeah i don't see why not

slate swan
#

@slate swan

scarlet aurora
#

what are the arguments that are being passed through?

slate swan
#

idk anymore

scarlet aurora
#

you can set them to what oyu want

livid hinge
#

guys would this work

@bot.event
async def on_member_update(ctx, before, after):
    if after.username == "SomeUser":
        await after.ban()```
slate swan
vale wing
slate swan
#

Yea

vale wing
#

Oh mo

slate swan
#

Poor :(

slate swan
vale wing
#

Is it 429 exception

sick birch
slate swan
livid hinge
#

its actually not terrible if you pay

slate swan
#

Then why should I use

vale wing
slate swan
#

I need pc

vale wing
#

Or anything else you know

slate swan
#

I don't have

vale wing
slate swan
#

Just tell me how to do it their

slate swan
vale wing
#

Oh god

slate swan
#

😫

vale wing
#

I remember coding on mobile

#

It was aids

#

Why office tho

slate swan
#

Ok ok

#

Ik what is it

vale wing
#

For projects or smth

slate swan
#

then deploy to a shitty vps from like linode or sum

#

Tell me how to fix it

slate swan
vale wing
#

I am a musician so I only use musescore

slate swan
vale wing
#

Full traceback please

#

And the code

slate swan
#

What

slate swan
#

Nah i can't

#

Huh

vale wing
#

Then we can't help

slate swan
#

Why full code

vale wing
#

The code that is malfunctioning

slate swan
#

It's privacy

vale wing
#

Not the full code

#

Bro

slate swan
#

Privacy πŸ˜‚

#

Easy words

vale wing
#

Good idea

#

Why'd I even make my AI antispam bot open-source 😩

slate swan
#

Lol

#

Help..

vale wing
#

Recently one guy tried to steal its source and was like "how to run it plz tell me"

slate swan
#

I am done that's just last thing

#

I can't fix it

vale wing
slate swan
#

How should I put it like? The channel one

vale wing
#

I don't even see send function anywhere

slate swan
#

get the channel

vale wing
#

Just declaring 2 variables isn't informative

slate swan
#

If it's worng it doens't response if i just put 1 channel it works

west wigeon
#

those are two assignments of values to variables. afterwards, message_1 and channel_1 contain values.

vale wing
#

And why are you storing ids as strings

west wigeon
#

so far, that's all we can tell.

slate swan
#

That's it

west wigeon
#

the rest is just guessing without the code. and our guesses will be wrong.

vale wing
#

Well you just declared them and assigned values to them

exotic granite
#

Hey all, anyone have some documentation on running discord bots at a higher scale? Finding that my bot is lagging on responses recently due to traffic. There are definitely areas I can optimize in the code, but I'm curious about scaling too.
How might i load balance across multiple instances of the bot? Is it just a matter of scaling vertically?

slate swan
#

listen nobody will copy ur code here don't worry

vale wing
slate swan
#

Out of 10

vale wing
vale wing
#

Did you make your bot with raw requests

slate swan
#

What?

livid hinge
slate swan
#

What's that

vale wing
#

Ok well you are a regular code copypaster

slate swan
#

:)

vale wing
#

Sorry I don't help to such people

exotic granite
slate swan
west wigeon
#

this is a nightmare.

#

use a library.

slate swan
#

I just bought the code

#

Rly

#

Ye

vale wing
#

Might sound discouraging but please learn some stuff of python

paper sluice
slate swan
#

14 lines 60$

#

For How much?

#

60$

#

U got scammed

#

Huh

paper sluice
slate swan
#

Bruh

exotic granite
#

@slate swan are you trolling? There is a lot of free code available.

slate swan
#

RIP

west wigeon
#

i'm curious if you lost more than just money on this ... like if you don't know what the code is even doing, do you trust what it's doing?

vale wing
slate swan
#

I bought it

slate swan
#

Idk

#

I won't show the chat

#

Ask the guy u bought from

slate swan
exotic granite
slate swan
#

...

#

Ig i didn't watsed my bitcoin

polar scroll
#

Is it a good idea to use replit to make Discord bots? Since all the hostings are paid

exotic granite
paper sluice
vale wing
slate swan
#

Anyone please help

paper sluice
slate swan
paper sluice
slate swan
exotic granite
slate swan
paper sluice
slate swan
#

Idk

#

How to use

paper sluice
#

check the docs

vale wing
slate swan
#

I am 1/10 in coding

exotic granite
polar scroll
#

Is it a good idea to use replit to make Discord bots? Since all the hostings are paid

vale wing
#

@slate swan I can make you a bot for free I am bored lol

slate swan
#

I can just think what is it doing by seeing 3 to 5 words

paper sluice
polar scroll
vale wing
exotic granite
vale wing
# polar scroll What should I do?

Well I can't really recommend anything. Personally I have a bare metal server that I built from old computer parts and it works perfectly besides sometimes we get electricity cut off πŸ˜„

slate swan
#

Dms @vale wing

slate swan
#

$ + $ = €

vale wing
#

Anything free

slate swan
#

Dm @vale wing

#

Fast.. i have to study for tomorrow exam

#

Pls move to dms

vale wing
#

Running the server isn't free as well but compared to the prices of servers with 4 gb ram it is miserably small price I pay for electricity it consumes

slate swan
#

Omg @vale wing

vale wing
slate swan
#

Dms pls

polar scroll
#

That's big brain

slate swan
#

I good at maths

#

πŸ€“

#

Ok

#

!ot

unkempt canyonBOT
polar scroll
#

Well anyways, since I'm starting my career as a bot developer, i would like to know how do I make a simple mute command

gaunt mortar
#

Hi guys, I started to use slash commands instead of regular commands.. My / command isn't showing up while typed in my discord server (I'm admin, I checked applications.command in OAuth2) but I can't find two examples doing the same and most of them are using external librairies :

@app_commands.command(name="bet", description="Ajoute, crΓ©e ou valide un pari")
    async def bet(self, interaction):
    #doing things
        await interaction.response.send_message(embed=embed, view=view)

It's inside a cog tho but as I said earlier I had no issue with it when using regular commands so..

slate swan
#

I good at maths

#

πŸ€“

mossy jacinth
#

How can i make it so it sends the image inside the embed?

slate swan
#

What peal can make

#

!d discord.Embed.thumbnail

echo wasp
#

'NoneType' object has no attribute 'send'

unkempt canyonBOT
#

property thumbnail```
Returns an `EmbedProxy` denoting the thumbnail contents.

Possible attributes you can access are...
echo wasp
# echo wasp 'NoneType' object has no attribute 'send'
 @commands.command()
    async def permissions(self, ctx, channel):
        em = discord.Embed(title=f'Testing', description=f"I am testing if i have permissions in this channel!")
        channel = await fetch_channel(channel)
        try:
            await channel.send(embed=em)

        except Exception as e:
            await ctx.channel.send(f"{e}")```
slate swan
slate swan
#

use await self.bot.fetch_channel()

echo wasp
slate swan
#

its a string, which must be integer

#

um ye

#

or typehinted it to discord.TextChannel would be even better, then you can directly channel.send

livid hinge
#

is there some Messageable interface thing as well

vale wing
#

!d discord.abc.Messageable you mean this?

unkempt canyonBOT
#

class discord.abc.Messageable```
An ABC that details the common operations on a model that can send messages.

The following classes implement this ABC...
vale wing
#

Abc is an abstract class or smth

livid hinge
#

yes thats the one

paper sluice
#

abstract base class

livid hinge
#

!d discord.abc.Messageable.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.

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

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

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

its got send too ig

vale wing
#

Yeah

livid hinge
#

but I always have done textchannel

#

i just recall seeing that someplace

vale wing
#

Well it implements the Messageable

livid hinge
#

theres like 6 classes that have Channel in the name

vale wing
#

For different types of channels

echo wasp
# slate swan use await self.bot.fetch_channel()

Ignoring exception in command permissions:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/vscode/Everything bot's/cogs/commands.py", line 87, in permissions
channel = channel = await fetch_channel(channel)
NameError: name 'fetch_channel' is not defined

vale wing
#

You need to call it on something

#

Bot or guild

echo wasp
#

oh got it

slate swan
#

I really can't type on mobile so...

vale wing
#

Understandable

slate swan
keen talon
#

Sup everyone πŸ‘‹πŸ˜‰

slate swan
#

heyyyypWut

slate swan
fallow mauve
#
class SnipeCommand(commands.Cog):

  def __init__(self, bot: commands.Bot):
      self.bot = bot
      self.last_msg = None
      self.last_msg_author = None
      self.last_emsg = None
      self.last_emsg_author = None



  @commands.Cog.listener()
  async def on_message_delete(self, message):
    if message.author.id != 981585342626955364:
      self.last_msg = message.content
      self.last_msg_author = message.author



  @commands.Cog.listener()
  async def on_message_edit(self, message):
    if message.author.id != 981585342626955364:
      self.last_emsg = message.content
      self.last_emsg_author = message.author

im trying to make a snipe command for edited messages too, but the on_message_edit event isnt working, it says there are 3 args but it only takes 2, when there arent

slate swan
#

hello who give me help please

#

Commande ban (Pour ban un membre ou quelqu'un)

@bot.command()
@commands.has_permissions(ban_members = True)
async def ban(ctx, user : discord.User, *, reason):
reason = " ".join(reason)
await ctx.guild.ban(user, reason = reason)
embed = discord.Embed(title = "Banissement", description = "Un modΓ©rateur a frappΓ© !", url = "https://discord.com/terms", color=0xFF0000)
embed.set_thumbnail(url = "https://th.bing.com/th/id/R.6295f456c34c3e88f7541cc8c1318be6?rik=1m1HBBcuephTtg&pid=ImgRaw&r=0")
embed.add_field(name="Membre banni", value = user.name, inline = True)
embed.add_field(name=f"Raison", value = reason, inline = True)
embed.add_field(name="ModΓ©rateur", value = ctx.author.name)

await ctx.send(embed = embed)
sick birch
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

sick birch
#

Also describe the issue and any tracebacks you may be getting

slate swan
#

sorry To ou bad english

fallow mauve
slate swan
#

Iirc I takes 1 before and 2 after

#

yes one second

gaunt mortar
#

I started to use slash commands instead of regular commands.. My / command isn't showing up while typed in my discord server (I'm admin, I checked applications.command in OAuth2) but I can't find two examples doing the same and most of them are using external librairies :

@app_commands.command(name="bet", description="Ajoute, crΓ©e ou valide un pari")
    async def bet(self, interaction):
    #doing things
        await interaction.response.send_message(embed=embed, view=view)

It's inside a cog tho but as I said earlier I had no issue with it when using regular commands so..
Any clue of what am I doing wrong ?

sick birch
slate swan
#

Ye

west wigeon
#

yeah, that

slate swan
#
# Commande ban (Pour ban un membre ou quelqu'un)
@bot.command()
@commands.has_permissions(ban_members = True)
async def ban(ctx, user : discord.User, *, reason):
    reason = " ".join(reason)
    await ctx.guild.ban(user, reason = reason)
    embed = discord.Embed(title = "**Banissement**", description = "Un modΓ©rateur a frappΓ© !", url = "https://discord.com/terms", color=0xFF0000)
    embed.set_thumbnail(url = "https://th.bing.com/th/id/R.6295f456c34c3e88f7541cc8c1318be6?rik=1m1HBBcuephTtg&pid=ImgRaw&r=0")
    embed.add_field(name="Membre banni", value = user.name, inline = True)
    embed.add_field(name=f"Raison", value = reason, inline = True)
    embed.add_field(name="ModΓ©rateur", value = ctx.author.name)

    await ctx.send(embed = embed)β€Š
#

sorry

sick birch
#

Also if I'm not mistake, you do need a CommandTree instance:

tree = discord.app_commands.CommandTree()
@tree.command(...)
...
sick birch
gaunt mortar
sick birch
#

Well, there you have it

slate swan
#

one second please

gaunt mortar
slate swan
livid hinge
#

but no message ?

fallow mauve
# sick birch ```py async def on_message_edit(self, before: discord.Message, after: discord.Me...
  @commands.command(name="esnipe")
  async def esnipe(self, ctx: commands.Context):
    embed=discord.Embed(description="** **", color=0x48c039)
    if self.last_msg == None:
      content = "No messages to snipe."
      author = "N/A"
    else:
      content = self.last_emsg
      content2 = self.last_emsg2
      author = self.last_emsg_author
    embed.add_field(name=f"Before: {content}", value="** **")
    embed.add_field(name=f"After: {content2}", value=f"- by {author}")
    await ctx.send(embed=embed)

content2 referenced before assignment?

sick birch
#

Yeah content2 only exists if self.last_msg is NOT None

#

I would just do something like this:

if self.last_msg is None:
  await ctx.send("No message to snipe") # embed also works too
else:
  ...
slate swan
#

2 helpers in one channelpWut

livid hinge
#

πŸ‘€

echo wasp
#

wow

slate swan
#

lots of hewlp

livid hinge
#

is it unusual

slate swan
#

yup

#

yup very

#

I need help To get the font to be Perfect but I dont know cos to fix it

sick birch
#

Well, maybe we need more helpers then

slate swan
slate swan
#

well Robin grew up in this channel

slate swan
sick birch
#

Yeah we don't get many staff around these parts

livid hinge
#

could use moar helpers

sick birch
#

Probably

slate swan
#

grump πŸ‘‹

livid hinge
#

*more discord helpers

slate swan
#

πŸ‘‹

#

im still here

#

but sarthak is smarterpWut

#

@slate swan send me inv to that cat emoji server πŸ‘€

livid hinge
#

oh another server with nice cat emojis

sick birch
#

At least in the way that you get to pick which font your embeds are

slate swan
livid hinge
#

the c# cats are awesome imo

slate swan
#

its global emojis lol so im limited

sick birch
#

I wouldn't consider italics to be a seperate font

slate swan
#

you sure?

sick birch
#

But I'm guessing alpr is asking why the bold markdown in the embed title isn't bold

livid hinge
#

like thiz ?

sick birch
#

The reason is because it's already bold

slate swan
#

πŸ›Œ

#

hey guys

#

you just killed the chat

#

shhh

livid hinge
#

oh just saw the huge bubble

slate swan
#

what do you guys think about this feature dont ask about the src😳 grump

#

you can play gifs in your rich presence

livid hinge
#

is that a custom activity you wrote

slate swan
#

idk how its done hunter never told me but he said something about setting a url maybe in his presence idkgrump

#

@sick beacon

#

hunter

slate swan
#

appears as invalid user for me

#

desktop client?

#

cuz im on mobile client so i wasnt sure if hunter was in my clients cache

#

im on mobile phone

maiden fable
#

Didn't get a ping

maiden fable
livid hinge
#

oh the Test / Test made me think it was some work in progress

maiden fable
#

Nah, just a random app id

livid hinge
#

weird..

maiden fable
#

Never got the ping

slate swan
#

@maiden fable

#

Uh

livid hinge
#

@maiden fable

#

ok wrong #

slate swan
#

Ye right I'd

paper sluice
#

@maiden fable

#

:)

maiden fable
#

Thanks for the 3 pings guys

livid hinge
#

now they're getting the pings lol

#

anytime man .

maiden fable
#

Thanks for the 3 reactions guys

slate swan
#

thanks to greyblue for flexing his reaction perms 😳

shrewd apex
#

do u know how to access variables from variable names in string?

slate swan
shrewd apex
#
xyz = {}#some dict
a = input()#'xyz'
print()# trying to print xyz from input
maiden fable
slate swan
maiden fable
#

Had to use an eval since there was no other way

slate swan
#

!e ```py
var1 = 1

string = "var1 is cool"
variables = (var for var in string.split() if var in dir())
print(variables)

paper sluice
#

!e

from fishhook import hook, orig

@hook(str)
def __repr__(self, *args, **kwargs):
    string = orig(self)
    for word in string.strip("'").split():
        if word in globals():
            string = string.replace(word, globals()[word])
    return string


var1 = "hello World!"
foo = 'var1 :)'
print(repr(foo))
unkempt canyonBOT
#

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

'hello World! :)'
#

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

<generator object <genexpr> at 0x7f1e5b73fca0>
slate swan
slate swan
slate swan
#

yup you can use dir(), globals() and locals() depending on the situation which dir() returns a list and the others return a dict

#

dir returns a list

slate swan
#

guess i got confusedπŸ˜”

slate swan
unkempt canyonBOT
#

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

<class 'list'>
slate swan
#

mhmm thanks qt

paper sluice
maiden fable
paper sluice
#

nop wait im tripping

slate swan
#

wanna see something funny?

slate swan
slate swan
shrewd apex
#

hmm what do u think would be better i keep a json loaded in gloabals and then use dir() or globals() for command or open when its input in the command

slate swan
#

!e

a = "hi"
inp = "a"
print(f"{inp}")
#

why the f string anyway?

unkempt canyonBOT
#

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

a
slate swan
#

and you cant assign anything to keywords

#

Wait no

maiden fable
slate swan
#

I was testing something

unkempt canyonBOT
#

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

hi
slate swan
maiden fable
# shrewd apex πŸ‘†

U cannot do that, globals() returns a dict which would have a structure smth like: {"ctx": Context_object} and those objects ain't json parsable

slate swan
#

i would use globals imo

shrewd apex
slate swan
#
print(globals()[input("What var value should i show?\n"])
#

is a good examplepWut

#

how do i get command name

unkempt canyonBOT
slate swan
#

thats the functions name which is probably the same

slate swan
#

nope

slate swan
#

bame😭

paper sluice
#

this chat keeps dying

slate swan
#

ryuga revive itgrump

slate swan
#

he has spokenπŸ™

#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'stname'
paper sluice
#

now ask bot questions πŸ”« 🐱

slate swan
#
    async def streaming(self, ctx, *, stname):
            await ctx.message.delete()
            stream = discord.Streaming(
                name=stname,
                url="https://twitch.tv/elraenn"
                )
            await self.bot.change_presence(activity=stream)
            await ctx.send(f"```toml\n[Activity Changed]: Type: {ctx.command.name} Status: {ctx.stname}```", delete_after = 5)
paper sluice
#

yes it worked lemon_hyperpleased

slate swan
#

help

shrewd apex
#

It's Alive

slate swan
#

what

shrewd apex
#

the chat -_-

slate swan
paper sluice
slate swan
#

i should be more specific

paper sluice
# slate swan i should be more specific

!e

import io
from contextlib import redirect_stdout

with io.StringIO() as buf, redirect_stdout(buf):
    import this
    output = buf.getvalue().splitlines()[3]

print(output)
unkempt canyonBOT
#

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

Explicit is better than implicit.
unkempt canyonBOT
#

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

001 | The Zen of Python, by Tim Peters
002 | 
003 | Beautiful is better than ugly.
004 | Explicit is better than implicit.
005 | Simple is better than complex.
006 | Complex is better than complicated.
007 | Flat is better than nested.
008 | Sparse is better than dense.
009 | Readability counts.
010 | Special cases aren't special enough to break the rules.
011 | Although practicality beats purity.
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/sarujekoha.txt?noredirect

paper sluice
slate swan
#

is theres any way i can get loaded commands

#

like in every cog

#

all the commands registered?

#

yea

#

i guess

#

!d discord.ext.commands.Bot.commands

unkempt canyonBOT
slate swan
#

Cogs probably have it too

#

don't put me on

#

the docs please

#

{len(ctx.commands)}

#

!d discord.ext.commands.Cog.get_commands / walk_commands

unkempt canyonBOT
#

get_commands()```
Returns the commands that are defined inside this cog.

This does *not* include [`discord.app_commands.Command`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Command "discord.app_commands.Command") or [`discord.app_commands.Group`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.app_commands.Group "discord.app_commands.Group") instances.
slate swan
#

im med

paper sluice
slate swan
shrewd apex
#

what was the doc link for subclassing help command?

maiden fable
#

!custom-help

unkempt canyonBOT
#

Custom help commands in discord.py

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

slate swan
paper sluice
#

πŸ‘€ there is teg for it

slate swan
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.
shrewd apex
#

thx

slate swan
paper sluice
#

sem, when was this added?

maiden fable
#

been there since at least more than half a year iirc

paper sluice
#

how do u look at all past commits on github?

slate swan
#

was sent for the first time on 26/3/21

shrewd apex
#

it's pretty detailed

slate swan
paper sluice
#

ya i can do that, but i want to know about that

slate swan
#

anyways you can just click on the "last commit" on the code page it will list all the commits

paper sluice
#

ah got it, thanks

slate swan
#

can I not hyperlink text in discord titles on embeds?

slate swan
#

Embed(title="hyperlink", url="https://uwu.you")

#

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

me who was using embed.title.url for 2 hrs unable to figure out how to get an embed's title url

maiden fable
#

Its fine sarth, I know the feeling

slate swan
#

😭

placid skiff
slate swan
#
            int(
                event_2.message.embeds[0]
                .description.split("#:")[1]
                .replace(".", "")
                .replace("`", "")
            ),``` and then i did this, too proud.
slate swan
slate swan
slate swan
#

dw, i understand ash, you dont need to edit it million times

slate swan
slate swan
slate swan
#

but i wont until its a commit thats worthy

slate swan
slate swan
slate swan
maiden fable
slate swan
slate swan
slate swan
slate swan
slate swan
maiden fable
slate swan
slate swan
#

nooo😭

maiden fable
#

!d object.setattr exists...

unkempt canyonBOT
#

object.__setattr__(self, name, value)```
Called when an attribute assignment is attempted. This is called instead of the normal mechanism (i.e. store the value in the instance dictionary). *name* is the attribute name, *value* is the value to be assigned to it.

If [`__setattr__()`](https://docs.python.org/3/reference/datamodel.html#object.__setattr__ "object.__setattr__") wants to assign to an instance attribute, it should call the base class method with the same name, for example, `object.__setattr__(self, name, value)`.

For certain sensitive attribute assignments, raises an [auditing event](https://docs.python.org/3/library/sys.html#auditing) `object.__setattr__` with arguments `obj`, `name`, `value`.
slate swan
#

!e

class A:
    def __init__(self, **botvars) -> None:
        pass

ok = A().botvar = 1
print(ok)
unkempt canyonBOT
#

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

1
slate swan
#

its really that easy

#

uh you dont even need to do that...

maiden fable
#

Yea

slate swan
#

its better thogrump

#

i mean that **botvars

#

the name?

maiden fable
#

U don't need to accept the kwargs

slate swan
#

!e ```py
class A:
def init(self) -> None:
pass

ok = A().botvar = 1
print(ok)```

unkempt canyonBOT
#

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

1
slate swan
#

juss like this

#

what the hell

shrewd apex
#

just init(self)

slate swan
#

guess i dont need to make a commit😌

#

actually you dont need the init too kek

#

yeah lmao

#

its an examplepWut

shrewd apex
#

πŸ”¦

light violet
#

how do i make a command like that if the command user deletes his command message then the bot too delets it's response on that command huh?

slate swan
#

use bot.wait_for('message_delete') with proper checks to check if the user deletes his message

light violet
#

ok ok thanks

#

hehe

#

lemme test

shrewd apex
#

u can add a reaction to the bot response

#

like how python does

#

like that

slate swan
shrewd apex
#

looks like someone dropped ink on em

slate swan
#

how you guys even using those emojis

#

😳 global emojis...

light violet
#
client.wait_for('message_delete',check = lambda message: message.author == ctx.author)
  await gg.delete()```
it is deleting message on its own help pls 

i didnt even dellete my msg
shrewd apex
#

how many global emojis were there?

slate swan
slate swan
slate swan
shrewd apex
#

so if u join those servers you get access to global emojis

slate swan
#

i can send you the links of the servers if you guys want? just ping me in and ot channel and ill send the links

slate swan
#

ohh

#

12 am, cope

light violet
#

this?

slate swan
#

yes that would work

light violet
#

not working it is deleting the msg soon it responds

slate swan
light violet
#

yes

shrewd apex
#

yeah

slate swan
#

you got the answer.. πŸ˜‚

fallow mauve
#

how would i make my bot wait a few seconds between doing things in an event

slate swan
light violet
shrewd apex
#

❀️

slate swan
#

sarthak

#

yo

shrewd apex
#

welp i gtg cya gn have a nice day ahead

slate swan
#

gn asher

slate swan
slate swan
slate swan
slate swan
#

no im not indianπŸ˜”

#

pithink how does that matter

#

cause yall smart grump

#

hunter is indian and look at himgrump

#

Indians are comparatively smarter

#

yes

slate swan
#

maybe im indianpWut

#

sarthak adopt me

#

me too

#

i'll prefer being hunter for a while

#

!ot

unkempt canyonBOT
paper sluice
#

πŸ‘€

slate swan
#

no your leaving like my dad damnπŸ˜”

#

I was gonna say that l, nooooiiii

#

the embed on phone....it just effing floats upwards

#

on reacting continuously

#

yeah

#

it buggs out

paper sluice
slate swan
#

lmao

#

bradpWut

velvet compass
#

Can I just take a moment and say thank you to the regulars here? Haven't had any issues coming from pride month

#

So ya, y'all rock

slate swan
#

make us helpersgrump

#

lol

#

πŸ˜‚

velvet compass
#

Helpers get nominated, and then voted on

slate swan
#

πŸ˜” or atleast allow reaction perms here

#

^

slate swan
velvet compass
#

Might be worth asking for a reaction role permission instead?

maiden fable
#

Mods have told numerous times before, the reason why there are no reaction perms tbh

slate swan
#

no

#

mina is stubborn shes gonna say nogrump

slate swan
#

ash shhhh

#
    if embed.color == 16777215:
        return 1
    elif embed.color == 8060813:
        return 2
    elif embed.color == 5808355:
        return 3
    elif embed.color == 11360483:
        return 4
    elif embed.color == 16314629:
        return 5
    elif embed.color == 15344162:
        return 6```

this function took me 2 hrs to make
velvet compass
unkempt canyonBOT
slate swan
#

we can edit messages instead

#

ty ash :painful_smile:

waits for 10 more secs

velvet compass
#

lol

paper sluice
#

yey lemon_happy

velvet compass
#

I changed it back

paper sluice
#

no lemon_angrysad

velvet compass
#

But back to the helper thing, it really is through nominations and voting, as far as I know no one has made it through with a shortcut, even if they are nominated by an owner

paper sluice
#

democracy, you love to see it

slate swan
#

at least brad's humourous

slate swan
#

we cool rightgrump

#

no

velvet compass
#

Yeah we are all cool

slate swan
#

ash😭

heavy shard
#

brad: your pfp is creepy adorable πŸ™‚

slate swan
#

atleast oki is

#

no sarthak you coolergrump

slate swan
velvet compass
slate swan
#

brad

#

I had a stroke reading that

#

have you ever gone to Uranus pWut

paper sluice
#

πŸ‘€

slate swan
#

its pronounced Ura nus btwgrump

#

dadjoke incoming

velvet compass
#

I've been to the Mun, Minmus, Eve, Duna and Laythe (I guess orbiting Jul counts?)

sick birch
#

hello and what is going on here πŸ‘€

maiden fable
#

I think ot channels exist, brad

slate swan
#

i'm sorry but, isn't the convo way off topic now?

#

shhh

#

hunter with ot

paper sluice
velvet compass
#

F

#

!warn 698273827448291379 stay on topic

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied warning to @velvet compass.

slate swan
#

πŸ’€

#

...

#

brad dont make me moderate you againlurks

velvet compass
slate swan
#

he was saying how cool we arepWut

slate swan
slate swan
slate swan
#

would be fun

#

wow its like thatπŸ˜”

paper sluice
maiden fable
#

I still remember Eivee (don't mind the spellings) invoking the ot commands cz lemon was taking about ot stuff

sick birch
#

So... discord bots?

slate swan
#

pithink we are off-topic-ing the chat to stop making it off-topic, isnt it

#

no

maiden fable
slate swan
#

no comments

paper sluice
#

chat ded agen

#

πŸ˜” ducky_vader

velvet compass
maiden fable
#

Better not go there unless u wanna see some..... nvm

slate swan
paper sluice
maiden fable
#

what u doing

paper sluice
#

idk, i figured i could use asynccontextmanagers to handle exceptions instead of two try-excpts

mossy jacinth
#

How can i make so the error message also deletes the embed of another command?

paper sluice
#

!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...
paper sluice
#

^ it has a delete_after keyword arg

slate swan
#
  File "C:\Users\sethh\Desktop\Projects\self\main.py", line 1, in <module>
    import discord, rich, colorama, os, colored, requests, json, asyncio, urwid
ModuleNotFoundError: No module named 'discord'
#

why not work the module is installed

vale wing
#

What code editor do you use

slate swan
#

vsc

vale wing
#

Do you use venv

rocky trench
#

long time ago

slate swan
rocky trench
slate swan
#

yepgrump

vale wing
rocky trench
vale wing
#

Missing closing bracket nothing really weird

rocky trench
vale wing
#

Thought it was kind of joke

rocky trench
#

I was 'chatting' with okimii while staying on topic

slate swan
vale wing
#

Compare their top_role

slate swan
#

and im good

vale wing
#

!d discord.Member.top_role

unkempt canyonBOT
#

property top_role```
Returns the member’s highest role.

This is useful for figuring where a member stands in the role hierarchy chain.
rocky trench
slate swan
#

πŸ˜”

heady sluice
#

yes because Role > Role checks for hierarchy

#

I study docs

vale wing
#

Docs are cool

heady sluice
#

yes

vale wing
#

But not docs for java libs

slate swan
#

src pWut

heady sluice
#

I didn't read any java docs

vale wing
#

Hope you never will

#

I got my brain destroyed after trying to figure out what method should I even use

heady sluice
#

but learning java (oop language) before dpy was like skyrocketing difficulties downwards

#

java can be cool af

#

but c# still is a betterjava

vale wing
#

Well in what context are you trying to implement that stuff? Like mute command? Then like this

@bot.command()
async def mute(ctx, target: discord.Member):
    if ctx.author.top_role <= target.top_role:
        await ctx.send("Too low role")```
vale wing
#

It's hard to do anything with java especially with gradle dependencies without IDE

heady sluice
#

god I make so many grammar mistakes now

#

btw we won't go to ot

vale wing
#

How do you even get who deleted the channel?

slate swan
#

should i delete that package

heady sluice
vale wing
slate swan
vale wing
#

How is json related to venv dude

slate swan
heady sluice
#

kind of ew but I appreciate the effort

vale wing
slate swan
unkempt canyonBOT
#

Virtual Environments

Virtual environments are isolated Python environments, which make it easier to keep your system clean and manage dependencies. By default, when activated, only libraries and scripts installed in the virtual environment are accessible, preventing cross-project dependency conflicts, and allowing easy isolation of requirements.

To create a new virtual environment, you can use the standard library venv module: python3 -m venv .venv (replace python3 with python or py on Windows)

Then, to activate the new virtual environment:

Windows (PowerShell): .venv\Scripts\Activate.ps1
or (Command Prompt): .venv\Scripts\activate.bat
MacOS / Linux (Bash): source .venv/bin/activate

Packages can then be installed to the virtual environment using pip, as normal.

For more information, take a read of the documentation. If you run code through your editor, check its documentation on how to make it use your virtual environment. For example, see the VSCode or PyCharm docs.

Tools such as poetry and pipenv can manage the creation of virtual environments as well as project dependencies, making packaging and installing your project easier.

Note: When using Windows PowerShell, you may need to change the execution policy first. This is only required once:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

sick birch
heady sluice
#

there's None

slate swan
#

i think they confused it with a .env file for saving configs..

vale wing
heady sluice
#

the code could be better of course but there's no other way to check who deleted a channel other than audit logs

vale wing
#

Hello there

heady sluice
#

by not using useless variables for example

vale wing
#

Well that's on channel create, not delete lol

paper sluice
slate swan
heady sluice
slate swan
heady sluice
#

wtf is that

vale wing
heady sluice
#

auschwitz.run

#

you good mate? 😭

vale wing
#

And yeah seems like you already do have a venv

#

And it is not configured as project interpreter

#

Anyway let's create a new one

paper sluice
heady sluice
#

there's a permission to view audit logs

#

you don't need admin for it

#

and good point

#

but can't discord check for the perms to see the things it should pass to you? would that make things much slower?

paper sluice
paper sluice
heady sluice
#

also you're making a lot of API calls by checkin audit logs

#

so how is that any better

vale wing
#

Perms check is something about byte shifting or smth

paper sluice
#

huh?

vale wing
#

Sorry man

heady sluice
#

I forgot the problem

vale wing
#

So basically you must have Member object (I dunno how'd you get it) and a Role object which you may get with Guild.get_role then just compare your role with member's top_role @pulsar bay

vale wing
#

Somehow they done perms calculation in just several math operations but although I know about bytes shifting and bitwise operators I dunno how they are typically used

slate swan
vale wing
#

Ok

heady sluice
#
if not member.top_role >= guild.me.top_role:
    #don't ignore, you're better
paper sluice
heady sluice
#

like checking perms

sick birch
vale wing
heady sluice
#

you don't need to get a role

#

you get member well... your way

heady sluice
#

studied Exenifix

#

if i is a member object, yes

#

it doesn't look like it

#

seems like an AuditLogEntry to me

#

put the user

mossy jacinth
#

how can my bot check if the user provided a real-/full- website link? Because it still wants to check if https:// is a real website same with anything else...

mossy jacinth
slate swan
slate swan
slate swan
slate swan
slate swan
#

or cpp if you may

#

or go

heady sluice
#

bro's tryna make us migrate

#

probably will succeed

slate swan
#

am I seeing things or were there messages that were deleted...

maiden fable
#

Same, I think the person who asked either deleted the message or I am hallucinating questions now from randoms

slate swan
#

I think I saw it by mistake

#

or we both are insane pWut

rare saddle
#

How to add multiple languages to a bot?

#

I just haven't tried anything, it doesn't work for me and nothing works

fading marlin
#

how can you not try anything and have it not work?

slate swan
#

multiple languages?

rare saddle
rare saddle
slate swan
maiden fable
odd mango
#

is there any git repo which has a nice embedded dpy help command?

unkempt canyonBOT
#

Custom help commands in discord.py

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

maiden fable
#

!d discord.Interaction.locale might help you with this

unkempt canyonBOT
maiden fable
#

@rare saddle ^^^

rare saddle
#

And if it already works, then how to translate the description of the slash command and its parameters?

odd mango
#

or one which i can import directly from pypi

slate swan
#

it has no embeds

#

!d discord.Message.embeds

unkempt canyonBOT
slate swan
#

it returns a list which would be empty if it has no embeds

crisp drift
#

cuz u need message intent

slate swan
#

!d discord.Intents.message_content

unkempt canyonBOT
#

Whether message content, attachments, embeds and components will be available in messages which do not meet the following criteria:

β€’ The message was sent by the client

β€’ The message was sent in direct messages

β€’ The message mentions the client

This applies to the following events...

flint isle
#

@sick birch I have my database created on google cloud and I need help configuring the connectivity. since im getting this error

disnake.ext.commands.errors.ExtensionFailed: Extension 'cogs.events' raised an error: OperationalError: connection to server at "34.68.242.84", port 5432 failed: Connection timed out (0x0000274C/10060)
    Is the server running on that host and accepting TCP/IP connections?
sick birch
scarlet sorrel
#

im sure someone has already made this so ill just ask here, how do you get the exact time of something happening from its discord id?

sick birch
scarlet sorrel
unkempt canyonBOT
sick birch
#

It does

#

You can also do something like discord.Object(...).created_at

scarlet sorrel
#

makes sense since this id system has been around for a while

#

it was originally used by twitter

sick birch
#

If you're going the manual route, you can do a little bit-shifting and get it to work

scarlet sorrel
#

ik

#

i could easy do it myself but if people had already done it asking is even easier

scarlet sorrel
sick birch
#

Good point, no need to re-invent the wheel here

scarlet sorrel
#

yea

sick birch
#

datetime.datetime