#discord-bots

1 messages Β· Page 830 of 1

slate swan
#

Is the owner_id a string there?

scarlet rune
sick birch
#

Right, on_ready() doesn't provide you with context, and unban() takes a snowflake

hazy oxide
#

Anyway

sick birch
#

!d discord.Guild.unban

unkempt canyonBOT
#

await unban(user, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Unbans a user from the guild.

The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to do this.
sick birch
#

refer to that for more information

final iron
#

You shouldn't be doing anything in on_ready. Discord has a tendency to disconnect you if you make requests in that event

slate swan
#

@sick birch i have my member id and role id

hazy oxide
#

Is there a code that will make the command works for bot owner only?

scarlet rune
slate swan
#

whats the command to unban the member id when bot starts?

final iron
slate swan
hazy oxide
#

Okay thank you

final iron
oblique laurel
#

This just seems wrong lol. If he was banned, it was prob for a reason

scarlet rune
slate swan
sick birch
# slate swan exactly

None of us are going to give you the code to copy paste, so either find a different community that will, or read up on the docs and learn from what we're telling you

oblique laurel
#

We dont spoonfeed here

keen sage
slate swan
#

i never used python my life and its a one time things why u sendimg me docs xd

scarlet rune
#

also i noticed that get_user ends just there...

lapis lintel
oblique laurel
slate swan
hazy oxide
#

So you code discord bot python just to unban yourself, and it's your first experience on python?

sick birch
slate swan
#

u dont wanna help me bascially

#

i came here to get the docs

keen sage
final iron
slate swan
#

discord team are evven slower

lapis lintel
oblique laurel
slate swan
#

it was ironic

#

i came here to just get the docs like wtf xd

keen sage
# final iron It is?

I guess yes, because if bot does not exist in that server then how he could unban himself?

sick birch
lapis lintel
slate swan
#

it takes 2 mins ill leave u

sick birch
#

Like I mentioned before I don't do dm help

slate swan
#

damn

#
  • Full stack Javascript developer
  • Arch Linux user
  • Helper at https://www.discord.gg/python
  • Ping friendly, always available to help πŸ™‚
  • DMs & friend requests closed, ping me to talk
sick birch
#

I also don't want to be held liable for helping people potentially break TOS

slate swan
#

and the max he can do is sending docs

#

fr

sick birch
#

Yes, what else do you want me to do? Spoonfeed you?

slate swan
#

we would already finish 30 mins ago

scarlet rune
#

@slate swanbro if you don't want to learn, just use the money you got from selling acc to get a custom bot on fiver or something

hazy oxide
#

True

sick birch
slate swan
#

????

grim oar
#

Probably too dumb to read the docs lol

sick birch
#

Those 2 are events

slate swan
sick birch
#

You're not looking for that, you're looking for the coroutine that actually unbans the user

#

Do keep in mind the bot needs to have the sufficient permissions to do so

oblique laurel
#

Thats an event, not a utility func

slate swan
grim oar
sick birch
slate swan
oblique laurel
# slate swan

Var names cannot be separated by a space. You rlly should look into some tutorials

slate swan
#

this i what i want to do XD

sick birch
#

Oh my yeah this is really not going to work

hazy oxide
#

If you want to copas only

slate swan
#

see ??

hazy oxide
#

Search on google

final iron
#

What is going on

hazy oxide
#

Unless you wanna learn

slate swan
#

i never opened python bro just lemme copy paste

final iron
#

πŸ—Ώ

grim oar
#

No lol

sick birch
oblique laurel
#

I cant πŸ˜‚

slate swan
#

ok well then advice me xd

final iron
slate swan
#

I DONT WANAN LEARNNN

grim oar
slate swan
#

ITS A ONE TIME THING x3 time

#

i say it

oblique laurel
slate swan
hazy oxide
#

Totally wrong

slate swan
#

whats correct command ?

keen sage
# slate swan ????

buddy, everyone here is trying to help you... But, you must understand that people here can provide the context and references to solve the problem they can't write the whole script. And, also you mentioned that you never did programming right? Then it's impossible to read doc and create bots so, it would be ideal for you to wait for your friend. I can understand what you are going because the same incident did happen with me when one of my friends banned me...

grim oar
#

!resources

unkempt canyonBOT
#
Resources

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

final iron
# slate swan I DONT WANAN LEARNNN

Then I'm afraid you've come to the wrong server. This server is meant to help for people who are interested in programming, not people who just want to be spoonfed code

slate swan
slate swan
sick birch
slate swan
#

send me that community then

#

cuz im fckkin losing my time

sick birch
#

I'm not aware of any

hazy oxide
#

Discord

final iron
oblique laurel
#

Theres a reason we dont do that. You can pay people to do that, that’s about it

slate swan
#

Utilise bot.http if you are too rookie for doing objects

#

await bot.http.unban(your_id, server_id) inside an async function πŸ‘

final iron
#

wat

keen sage
scarlet rune
#

@slate swanayo it's working now, thanks... my ide was being slow lol

slate swan
sick birch
slate swan
#

like this i try?

keen sage
oblique laurel
final iron
#

Guys can we calm down with the threats? I understand that some of you don't like this person but keep in mind, we should still be respectful

slate swan
oblique laurel
hazy oxide
sick birch
hazy oxide
#

On @bot.event

final iron
final iron
keen sage
slate swan
sick birch
#

Your bot is not in that guild then

slate swan
#

which guild?

final iron
hazy oxide
#

The guild you got banned

final iron
#

Can I have the documentation?

sick birch
oblique laurel
slate swan
final iron
slate swan
#

it works without that

slate swan
slim ibex
#

ah yes, VALORANT

final iron
sick birch
# slate swan

Yes, but your bot is not the guild so there's nothing you can do

final iron
#

Is it an internal method only?

sick birch
slate swan
#

guild is the server?

sick birch
#

Yes, guild = server

slate swan
#

it is in the server bro

slate swan
oblique laurel
#

How do u know if you were banned

oblique laurel
sick birch
oblique laurel
#

Either its the wrong id or ur bot isnt there

keen sage
# final iron Is your bot in the server you're banned in?

This is exact question it was asked... I was also wondering if bot already exist in the sever that mean he knows python and if he never used both that means both does not exist which means no matter what he do bot will not work

oblique laurel
#

Bots arent magic lol

slate swan
#

Who knows if the bot was removed too

#

cause they claim the bot was in the servr

#

will recommend printing bot.guilds

keen sage
slate swan
#

ITS On SERVER @calm sonnet

#

@sick birch

#

i see with alt acc

sick birch
#

Well the API doesn't lie, you probably put in the wrong ID or are looking at something else

oblique laurel
#

Why does that look so sketch lol

grim oar
#

Bot for trading accounts?!?

#

πŸ¦…

oblique laurel
#

Not trading, selling

slate swan
sick birch
#

In which case we should stop helping them

grim oar
#

Idk whatever

slate swan
#

πŸƒvalorant accounts market?

sick birch
#

Since we would be violating rule 5

oblique laurel
slate swan
#

cause the bot name suggests that.

#

dont do that never will be my intention

oblique laurel
#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

oblique laurel
#

Ima just back out of this

hazy oxide
#

Oof

slate swan
#

i asked a unban command

#

not a fortnite cheat

final iron
slate swan
#

lmfao u fr

final iron
#

@slate swan

slate swan
#

@slate swan give this

final iron
#

Never your intention huh

slate swan
#

dont lookk my bio

#

you know what it means.

grim oar
#

Bot doesn't have permission to unban members!

oblique laurel
#

Bot doesnt have perms looks like

slate swan
hazy oxide
#

Wha

slate swan
#

Roles don't matter, permissions do

supple thorn
#

dude is the most sus person ive seen in awhile

oblique laurel
#

Bro how is this guy not banned yet lol, he was banned from a server where u sell skins/accs it looks like

slate swan
#

Seems like that

final iron
#

Would this break rule 5?

oblique laurel
sick birch
slate swan
final iron
#

<@&831776746206265384> Not sure if whats going on breaks rule 5 but I would rather be safe than sorry

slate swan
#

by the way he is illicitly cracking/stealing valorant accounts and essentially selling them

hazy oxide
#

Well

slate swan
#

im asking how to add a role with python

#

No need to ping all mods, just mention a single person xd

oblique laurel
daring olive
#

who?

slate swan
#

u can get banned it break rules

final iron
oblique laurel
daring olive
#

yeah that i noted

slate swan
#

!rule 6

unkempt canyonBOT
#

6. Do not post unapproved advertising.

daring olive
#

would you mind DMing @novel apex please with whatever relevant information you have? i'm not finding anything obviously actionable here

final iron
#

Will do

scarlet rune
#

i wanted to catch an error when the bot doesn't get a permission to certain channel, this is the error:
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
which except should i make? is it except discord.errors.Forbidden:?

final iron
#

He dm advertised to me

slate swan
#

some"one" do it

#

you cant say yeah look at my bio and your bio is full of links of servers thats just like saying yeah open this door and the door is full of a room with advertisements

slate swan
pliant gulch
#

Ok that was pretty easy

slate swan
#

Damnn

slate swan
sick birch
pliant gulch
#

I guess I should support all 256 colors

slate swan
#

very nice

pliant gulch
#

8-16 was too quick

#

πŸ˜”

slate swan
#

andy complete Rewrite when

pliant gulch
pliant gulch
keen sage
#

Could we not just let user specify RGBA? πŸ€” Just wondering

slate swan
#

@slate swan

#

does it work?

pliant gulch
final iron
#

Aight I reported him

oblique laurel
#

πŸ‘

slate swan
# slate swan

what does the http attr do and id is a built in an not an attr to the Member class

slate swan
final iron
#

It's not documented

pliant gulch
#

I have no ETA on when that will be finished πŸ˜”

slate swan
final iron
#

Β―_(ツ)_/Β―

#

Ask Sarthak_

slate swan
#

ill dm him😏

#

😳

oblique laurel
#

Uses a bit of science and some black magic

slate swan
#

loll

#

I can clearly see y'all never check the internals.

final iron
#

Seems nice you can unban someone with just their id and server id

slate swan
final iron
#

I don't know why thats not a public method

oblique laurel
slate swan
#

And they don't care to document it either

oblique laurel
#

Ive never seen it in action, so i question if ur just pulling our legs lol

final iron
#

Nah

slate swan
#

what if you dont have legs

#

😳

#

@slate swan

#

hey man do i need server id here?

#

id is a built in still

sick birch
slate swan
#

vars should be in snake_casing

oblique laurel
#

Not english casing lel

slate swan
#

lmaoooo

unkempt canyonBOT
#

discord/client.py line 220

self.http: HTTPClient = HTTPClient(connector, proxy=proxy, proxy_auth=proxy_auth, unsync_clock=unsync_clock, loop=self.loop)```
slate swan
#

that looks clean

slate swan
#

but who would read internals

#

πŸƒ

slate swan
#

😳

tender estuary
#

I read that.

slate swan
#

read what

tender estuary
#

What what

oblique laurel
#

Lol

slate swan
#

πŸ‘οΈπŸ‘οΈ

slate swan
oblique laurel
#

Didnt read the second one sadly

slate swan
slate swan
tender estuary
#

...

slate swan
slate swan
#

cause my code is never worth pushing

#

Basically I just shorten things

slate swan
#

Into the wrapper itself

#

same

#

i read rin tho

#

not dpy

oblique laurel
tender estuary
slate swan
#

I was reading rin's src , totally understandable

unkempt canyonBOT
slate swan
#

a discord api wrapper

static lintel
#

So is chip gone?

slate swan
#

Made by andy

slate swan
tender estuary
static lintel
slate swan
sick birch
slate swan
#

we all love andy

oblique laurel
#

Hopefully

final iron
slate swan
#

Andy should have helpers role whos with me? πŸ˜„

static lintel
#

Rip I was gonna try to send them a video from the guy who taught me how to make a discord bot. Not sure if you guys watched Lucas but he got me started on discord bots

tender estuary
oblique laurel
#

Probll be back asking how to grab ips w python

tender estuary
slate swan
#

lucasπŸƒ

#

fccπŸƒ

tender estuary
slate swan
tender estuary
#

He just got into the idea you can't actually make a bot by only watching his videos

slate swan
#

yeah

static lintel
slate swan
#

vco has the best tutorial imo and disnakes guide is great as well

tender estuary
oblique laurel
slate swan
static lintel
#

the chip guy seemed a little confused so I figured I’d send the video and he’d be on his way. That way we could avoid any interaction with him promoting sus activity

sick birch
slate swan
#
@bot.command()
async def ban(ctx): await ctx.guild.get_member(637458038915203127).ban()```
tender estuary
slate swan
#

I'd love to see this being added to all bots!

oblique laurel
#

10/10 feature

slate swan
slate swan
opaque galleon
#

can anyone

oblique laurel
#

Insta ban the dude np matter what server hes in lol

opaque galleon
#

teach meeeeeeeee

slate swan
opaque galleon
#

discord.pyyyyyyyyyyyy

slate swan
#

Vco can

pliant gulch
#

😳

slate swan
opaque galleon
#

ty

slate swan
pliant gulch
#

The context manager is actually useful for once

tender estuary
pliant gulch
#

Clears the past lines in the builder

slate swan
#

yeah i saw the context manager

#

Oki pls explain me what it does 😌

pliant gulch
#

    def __enter__(self) -> ANSIBuilder:
        return self

    def __exit__(self, *_: Any) -> None:
        self.clear()
tender estuary
pliant gulch
#

self.clear calls self.lines.clear()

slate swan
#

thanku for losing 4hrs of my time btw

slate swan
tender estuary
sick birch
#

Let's keep it civil

slate swan
#

only hikari tried to help for real

#

no bro i legit list 4hrs im sick and worried

#

lost

sick birch
#

Β―_(ツ)_/Β―

slate swan
#

hikari should be moderator here

pliant gulch
#

probably idk

slate swan
#

pog right

sick birch
#

Context managers are pretty cool, I was looking at RoboDanny's source code and it used one for database connection, making and closing cursors I thought that was pretty ingenious

pliant gulch
#

It's a no brainer to do context managers for database cursors

#

Same with file pointers

#

You wouldn't want to go into C and malloc 10000 bytes without freeing it later

sick birch
#

Yah honestly after I saw that I got mine working and never went back to the old way whatever it was

slate swan
timid wagon
#

I've seen user and member objects being resolved through a context manager, to add attributes from the database

#

It's very useful lol

sick birch
#

agreed, easily one of my favourite features

slate swan
#

you probably dont know who i am but i know victorpithink

timid wagon
#

Not really something I'd discuss here, but yeah

slate swan
timid wagon
#

thonk I think yes

slate swan
#

he discussed it with you guys i suppose?

timid wagon
#

Yep, we had a talk before he left

slate swan
#

thats greatyert

tender estuary
#

Sounds like someone got laid

slate swan
#

!ot

unkempt canyonBOT
tender estuary
slate swan
#

🀫

timid wagon
#

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

#

Have y'all come up with ideas to utilize modals?

slate swan
#

no

#

havent even learned them

timid wagon
#

Text inputs limit where I can implement them, but there's still potential

hoary cargo
timid wagon
#

Yeah, eh

tender estuary
#

Imagine if van rossum was here

slate swan
timid wagon
#

The limit of?

slate swan
#

text

timid wagon
#

Well, a paragraph text input has a limit of 4000 characters

maiden fable
#

πŸ‘€

slate swan
pliant gulch
#

Great, discord seems to not support 255 colours

tender estuary
pliant gulch
#

I can't make the rainbow method of ANSIBuilder truly colorful

timid wagon
#

No but like, having dropdowns and file attachments, and so on

maiden fable
sick birch
slate swan
#

default is 2k for nitro users its 4k how is that not enough what are you writting 5 pages?

maiden fable
#

Lmao

slate swan
#

hey hunterpithink

sick birch
#

They didn't have official support for it so I had to implement it myself, but regardless was pretty easy

timid wagon
#

Ah yes

sick birch
maiden fable
#

Seems like some highly technical talks are going on here, I'mma just go

sick birch
#

It's just a POST request

timid wagon
#

Yep yep

slate swan
#

seems easy

sick birch
#

but their on_interaction is much less sophisticated than ours, it doesn't pick up interactions it doesn't recognize, i.e MODAL_SUBMIT

pliant gulch
sick birch
#

discord.py does actually pick it up if only to give you the raw data

pliant gulch
#

lmao πŸ˜”

sick birch
#

so unfortunately i was not able to listen to modal submits using d.js but i believe if you're implementing it using d.py you should be able to

sick birch
slate swan
sick birch
#

smh i had context managers on my mind

slate swan
timid wagon
#

For a sec I thought you were hacked dead

sick birch
#

nah it has a big yellow box saying to not enter sensitive info

slate swan
#

doesnt seem fake

slate swan
timid wagon
slate swan
#

LOL

sick birch
#

for reference

final iron
#

Have those been added?

slate swan
timid wagon
#

Indeed

slate swan
sick birch
slate swan
#

modals

sick birch
#

but it's an official thing yes

timid wagon
#

think they've all added them already

#

they're either on master or in release - disnake has them in 2.4

slate swan
sick birch
#

Don't do discord bots much anymore so yall can be the judge of that

slate swan
#

No idea about others

timid wagon
#

I remember the docs saying that required for a text input was false by default, and it was incorrect

#

devsnek got to it later

pliant gulch
#

bro, what. Discord doesn't even support bright fore & background colours of the 8-16 colour codes

slate swan
#

they dont? what

pliant gulch
#

yea they only support the regular 8-16 colour codes

slate swan
#

damn thats bad

final iron
pliant gulch
#

So that rainbow method from earlier is basically the best it gets colour wise

pliant gulch
#

πŸ˜”

#

Italic escape code doesn't even work either

timid wagon
lofty pebble
#
def run_id(id = ""):

    Client = commands.Bot(command_prefix=".", help_command= None )
    token = " "
    @Client.event
    async def on_ready():
        #while not Client.is_closed():


        command = Client.get_command("test")
        await command()
    
        #command = Client.get_command("bruh")
        #await command()
    
        #command = Client.get_command("wow")
        #await command()        
    print("online")
    @Client.command()
    async def test(ctx):
        await ctx.send("hello")
    Client.run(token, bot = True)

run_id(id = "x")
run_id(id = "y")

The second function never runs cause the first one never closes. How do I fix this ? Any ideas ?

slate swan
slate swan
unkempt canyonBOT
#

class disnake.ui.Modal(*, title, components, custom_id=..., timeout=600)```
Represents a UI Modal.

New in version 2.4.
final iron
final iron
timid wagon
#

Ah oka :P

final iron
#

Okay thats interesting

slim ibex
#

lowercase client pls

final iron
#

That's really cool

slim ibex
slate swan
slate swan
final iron
#

Okimii want to make a discord bot project

final iron
#

I want to create one but if I do it myself its boring

slim ibex
#

im making a bot for a server if yall wanna help lol

slate swan
final iron
#

All these new interactions are cool as hell

slim ibex
#

its disnake

lofty pebble
final iron
final iron
slim ibex
#

but i don't rlly plan on it being open source.. if i have collaborators though i must make it open source though

slate swan
slate swan
final iron
#

Can you make a private github repo and sort of add people to it?

timid wagon
slim ibex
#

oh ye im stupid

slim ibex
#

so yall interested? i barely started it today

final iron
slate swan
final iron
#

I'm getting a bit bored of Akeno

slim ibex
#

its going to be a general purpose bot that covers shit like moderation, automod, reaction roles, verification, config, etc

slate swan
slim ibex
#

but only for one server πŸ’€

slate swan
final iron
#

πŸ—Ώ

slate swan
final iron
pliant gulch
#

Looks good enuff to push

final iron
slate swan
pliant gulch
#

what

slate swan
pliant gulch
#

Yea you could steal it, you don't need to use rin specifically to use it

slate swan
#

😳imma copy it.

pliant gulch
final iron
#

@slim ibex Send me a msg so I don't forget

slate swan
slate swan
final iron
slate swan
slate swan
final iron
slate swan
slate swan
pliant gulch
#

glad but also sad that it's only the 8-16 colors

#

Glad I don't need to add shit ass many colours

#

Sad I don't get cool colours

keen talon
#

Sup awesome people

timid wagon
#

Yo

final iron
#

Can someone explain to me the advantages of subclassing the bot constructor than doing it the conventional way?

slate swan
pliant gulch
#

You can add extra things to the bot in an easier manner

#

Otherwise you'd be shadowing the objects attributes/methods

slim ibex
#

define your own methods in the class and customize stuff

slate swan
#

yup

final iron
#

Still don't understand but I guess I should do it

slate swan
slim ibex
#
class Bot(InteractionBot):
    def __init__(self, **options) -> None:
        intents = Intents.all()

        super().__init__(**options, intents=intents)

    # noinspection SpellCheckingInspection
    @staticmethod
    async def _connect_to_db() -> None:
        async with connect(r"...") as db:
            BUILD_PATH = r"..."

            if os.path.exists(BUILD_PATH):
                with open(BUILD_PATH, "r") as f:
                    await db.executescript(f.read())

            await db.commit()

    async def on_ready(self) -> None:
        await self._connect_to_db()
        log.info("Successfully established database connection.")

        log.info(f"Ready: {self.user} (ID: {self.user.id})")

    def load_cogs(self) -> None:
        for filename in os.listdir("./src/cogs"):
            if filename.endswith(".py"):
                self.load_extension(f"cogs.{filename[:-3]}")
                log.info(f"Loaded cog: {filename[:-3]}")

this is why subclassing good. i wouldn't be able to establish database connections or load cogs without having to do it in a procedural way with tons of lines of unorganized code

pliant gulch
maiden fable
#

Lol

pliant gulch
#
class Foo(commands.Bot):
    async def connect(self) -> None:
        ... # db stuff here
slim ibex
#

ooo forgot about that

pliant gulch
#

And this makes it so it only connects once a life-time

#

Rather than doing it on_ready

slim ibex
#

oh shjit thanks

slate swan
maiden fable
slim ibex
#

should i specify the specific intents?

pliant gulch
slate swan
maiden fable
#

Haha okay

#

Just kidding

slim ibex
#

true

slate swan
#

just add the class directly

slim ibex
#
def __init__(self, **options) -> None:
  super().__init__(**options, intents=Intents.all())
slate swan
#

yes

pliant gulch
slim ibex
#
async def connect(self) -> None:
  async with connect(r"...") as db:
    BUILD_PATH = r"..."

    if os.path.exists(BUILD_PATH):
      with open(BUILD_PATH, "r") as f:
        await db.executescript(f.read())

    await db.commit()
            
  await super().connect()

@pliant gulch ?

lofty pebble
#

Are questions related to self_bot are forbidden ?

maiden fable
#

Yes

slate swan
#

yes

pliant gulch
#

Is the file you're reading your schema.sql?

slim ibex
#

ye the build_path points to the sql file

#

i just didn't wanna put my path there lmao

maiden fable
#

Lmao

slim ibex
#

it reads the sql file and executes it, then commits it to the db

pliant gulch
# pliant gulch LGTM

Something to note though, connect takes 1 arg reconnect but technically you don't need to change anything as by default it's set to true

slim ibex
#

ye ik that

pliant gulch
#

Ok I did atleast one commit for the week

#

Time to procrastinate the rest

slim ibex
#

i cna also load cogs in the connect method right?

#

instead of making a separate method and calling it in on_ready

pliant gulch
#

There isn't a point to do it in connect I don't think you're not running any coroutines so

#

You can just add it to bot.run()

slim ibex
#

oh ok

pliant gulch
#

Same way with how you overwritten connect

slim ibex
#

ye ive done that before

slate swan
maiden fable
pliant gulch
#

If you don't add a reset code your colours will mishmosh

slate swan
slate swan
pliant gulch
slate swan
pliant gulch
#

I guess I randomly wrote it like that for some reason

#

I cba to commit again tonight πŸ˜”

slate swan
#

esoteric

pliant gulch
#

I could've made the builder esoteric

unkempt canyonBOT
#

rin/models/builders/ansi.py line 48

the forground color code, and the second being the background color code.```
pliant gulch
#

Probably could've used @type.__call__

pliant gulch
slate swan
#

😳 sure

frank tartan
#

how can i require either a specified role or a permission for a cmd?

slate swan
slate swan
frank tartan
pliant gulch
#

is roleID a variable?

frank tartan
pliant gulch
#

It won't work like that, decorators run at runtime

#

Unless you set roleID right away it won't work

slate swan
#

and it will first check if the user has admin perms

pliant gulch
#

You should show your roleID definition

frank tartan
final iron
#

What is with you and camelCase

#

camelCase should never be used in python

frank tartan
#

ok goodbye

final iron
#

snake_case should be used for variable and function names

pliant gulch
frank tartan
#

litterly there

#

also, when i run it requires the role, it doesnt work if you have admin perms

pliant gulch
#

At that point you'd just pass the int itself right?

#

If the variable is literally right above it

slim ibex
#
TypeError: Bot.connect() got an unexpected keyword argument 'reconnect'
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000002CD6BAEE830>
Traceback (most recent call last):
  File "C:\Users\binds\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\binds\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Users\binds\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 745, in call_soon
    self._check_closed()
  File "C:\Users\binds\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

πŸ—Ώ

async def connect(self) -> None:
  async with connect(r"...") as db:
    BUILD_PATH = r"..."

    if os.path.exists(BUILD_PATH):
      with open(BUILD_PATH, "r") as f:
        await db.executescript(f.read())

    await db.commit()
            
  await super().connect()

same function

slate swan
frank tartan
pliant gulch
frank tartan
#

can you guys just tell me how i can get the user's permissions? or check if a user has a sertain permission?

slate swan
slate swan
#

!d discord.Member.guild_permissions

unkempt canyonBOT
#

property guild_permissions: discord.permissions.Permissions```
Returns the member’s guild permissions.

This only takes into consideration the guild permissions and not most of the implied permissions or any of the channel permission overwrites. For 100% accurate permission calculation, please use [`abc.GuildChannel.permissions_for()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.GuildChannel.permissions_for "discord.abc.GuildChannel.permissions_for").

This does take into consideration guild ownership and the administrator implication.
slim ibex
frank tartan
slim ibex
#

quite a coincidence that the method is named connect when i also use another method inside that connect method named connect to connect to my db

#

anyways thanks for help @pliant gulch ily. gonna head to bed

#

tell me when i can make the first big Rin bot

pliant gulch
#

😳

maiden fable
#

Andy got fans πŸ‘€

slate swan
#

!d discord.on_member_ban

unkempt canyonBOT
#

discord.on_member_ban(guild, user)```
Called when user gets banned from a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

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

Hmm

slate swan
#

hm

#

guys I'm working on my first bot

#

going nicely so far if I do say so myself imstuff

maiden fable
#

Cool!

final iron
slate swan
#

I just learned how to use cogs today

final iron
#

Nice

sick birch
#

Ah cogs, remember when I learned about them I thought they were insanely cool

slate swan
#

indeed

hoary cargo
#

Progress is real pepeOK

maiden fable
#

I started with cogs when I didn't know what are classes

slate swan
#

haha real

sick birch
final iron
#

I still don't know what a class is

pliant gulch
#

I remember being ecstatic with discord.py now looking back I'm kind of just dissapointed

final iron
#

I got burnt out when I created my first discord bot

#

πŸ˜”

sick birch
pliant gulch
#

Idk, overall mostly everything

maiden fable
pliant gulch
#

Just not the wrapper for me

sick birch
#

I assume that's why you're working on your own?

pliant gulch
#

Yea

slate swan
final iron
#

I think I've found my true interest with python. Working with APIs and analyzing data

maiden fable
#

The only reason Andy works alone is so that no one can tell him to push stuff today or smth. He likes procrastinating, yk

pliant gulch
#

also cause I got like real bad coding OCD

maiden fable
pliant gulch
#

if someone does something not how I usually style my code

#

I will go insane

maiden fable
#

Ouch

pliant gulch
#

Black mostly solves it though

final iron
#

Just follow pep8 and y'all will have the same style

pliant gulch
#

πŸ˜” but then the semantics

maiden fable
#

Hahahaha

maiden fable
pliant gulch
maiden fable
#

BTW

final iron
#

I think okimii doesn't like my obsession with pep8. I made a commit just to fix the import order of a file

maiden fable
#

U say u r making breaking changes

#

does anyone even use yr wrapper

pliant gulch
#

Probably 1 or 2

#

But I'll make sure to make those two hate me, for the amount of rewrites I will be doing

#

Only slightly joking

echo wasp
#

Ok i have 2 different bots in the same folder how do i make one reference a .env file in another folder in the folder that the starting file is in.
I use this py load_dotenv() TOKEN = os.getenv('DISCORD_TOKEN') GUILD = os.getenv('DISCORD_GUILD') intents = discord.Intents.default() intents.members = True

maiden fable
slate swan
#

😳 i use rin to find mistakes/bugs innit

echo wasp
#

can someone help with my question? or no clue

slate swan
#

from what i know

sick birch
#

Writing your own wrapper is acutally really cool, though I don't like to do it in Python, really good learning experience regardless

slate swan
#

or use a system variable which works globally on your system

dapper epoch
#

@sick birch any good resources on that

echo wasp
#

well how about absolute path?

pliant gulch
#

Rin will probably never see v1.0.0, we gonna be perpetually stuck at v0.1.12394 or something

sick birch
dapper epoch
#

I’d love to right a wrapper to some c++ functionality for image processing

maiden fable
sick birch
pliant gulch
#

😼

dapper epoch
#

I actually mean in general i’ve never written my own python wrappers

maiden fable
sick birch
#

I'll warn you I'm only good with the connecting and API part, not with the classes and objects and whatnot πŸ‘€

sick birch
maiden fable
#

🀣

dapper epoch
#

Ah nevermind

pliant gulch
#

Oh yea connecting to the API is easiest part

maiden fable
#

Facts

pliant gulch
#

Models and whatnot are so tedious to add

sick birch
#

though anyone who writes a discord library in binary would acquire godlike powers

sick birch
pliant gulch
#

You'd spend 5 years a lone writing the websockets in binary

#

Then you'd spend another 10 years making it work

dapper epoch
#

I wrote a pyscript for a motion system and camera for work and rewrote it in c++ for performance boost on the image processing

maiden fable
#

Lmaooo

pliant gulch
#

Python also integrates nicely with c++ c, rust etc since they have a C api

dapper epoch
#

One of the optimizations i had looked into before just calling the rehaul bad been writing a wrapper for the c++ code to do the processing

pliant gulch
#

You could've written bindings for it in c++ code keeping some parts python, good learning expirence

#

Makes sense that the processor would be c++ code though

dapper epoch
#

Yeah what i’m looking for im young not a year out of college

#

I learned on the job how slow python can be comparitively

#

But god is it a beautiful language to use

pliant gulch
#

Sounds like the python curse

smoky cedar
#

Does anyone have a good example to follow of a python discord bot on github for project / file structure?

sick birch
#

Created by the same person who made discord.py, so i trust it

pliant gulch
sick birch
#

I don't know about the syntax, personally I prefer typescript in terms of syntax

pliant gulch
#

If python is your first lang and you get really used to it, I'd def say it impacts your learning

dapper epoch
#

I looked into cython as an optimization and trying to implement it just seemed to be a pain

pliant gulch
smoky cedar
pliant gulch
#

Javascript syntax is ok, but the conventions are weird

dapper epoch
#

I still need to actually try numba that didnt seem too bad to implement

pliant gulch
#

2 space indentation isn't very good

sick birch
dapper epoch
#

My first language was java in hs

sick birch
#

apparently they're making operating systems with it

pliant gulch
#

For speed sure, for the syntax even more

#

Also because rust is memory safe

dapper epoch
#

Then c -> c++ -> python in college

pliant gulch
#
int main() {
    void *foo = malloc(9000000000000);
    return 0;
}
``` 😳
dapper epoch
#

Rust i can believe is getting os applications

#

I mean theres gotta be a good reason all of solana is either in rust or c

pliant gulch
#

I'd much rather see new kernels being built in Rust than C

#

Preference mostly

dapper epoch
#

I have only worked minimally with rust so far

#

And a lot of it was being abstracted away by anchor

pliant gulch
#

Once you get used to it, it's pretty nice

#

A very robust langauge

dapper epoch
#

I will have to take your word for it at the moment

#

But thats good to hear my interests in writing solana contracts wont be leading me down the dark path

lapis meadow
#

@client.event()
async def on_message_delete(message):
embed=discord.Embed(title="{} deleted a message".format(message.member.name),
description="", color="Blue")
embed.add_field(name= message.content ,value="This is the message that he has deleted", inline=True)
channel=client.get_channel(937566314522902538)
await channel.send(channel, embed=embed)

#

Trying to make my bot be able to log events

#

I started with this but I'm getting this error and I'm not sure what to do.

maiden fable
#

Remove the ()

#

From client.event

lapis meadow
#

I'm stupid... Thanks

#

Still a problem. I deleted a message and it didn't put the deleted message in my logs channel

quick gust
#

await channel.send(channel, embed=embed)

#

send just the embed

lapis meadow
#

Okay

#

await channel.send(embed=embed)
I made it this and now I'm getting this error

File "c:\Users\13129\Desktop\Python Bot\Sloth.py", line 57, in on_message_delete
embed=discord.Embed(title="{} deleted a message".format(message.member.name),
AttributeError: 'Message' object has no attribute 'member'

quick gust
#

message.author

slate swan
#

keep getting this when trying to use cogs with pycord

lapis meadow
#

this? format(message.member.name) to this? format(message.author)

quick gust
#

since message.author returns a Member object

slate swan
lapis meadow
#

now this is the error @quick gust

quick gust
#

why dont u use f-strings instead of .format

#

!f-strings

unkempt canyonBOT
#

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

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

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

lapis meadow
#

oh

quick gust
#

also remove description="" since its empty anyways

fervent shard
#

how can i make a discord.py code doing β€œif messages are in this channel, react with β€œπŸŽ‰β€β€

quick gust
#

on_message
if message.channel = channel
message.add_reaction(emoji)

lapis meadow
#

used like that correct?

fervent shard
quick gust
#

channel object

quick gust
fervent shard
quick gust
#

no

#

!d discord.TextChannel

unkempt canyonBOT
#

class discord.TextChannel```
Represents a Discord guild text channel.

x == y Checks if two channels are equal.

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

hash(x) Returns the channel’s hash.

str(x) Returns the channel’s name.
torn sail
quick gust
#

an instance of this

lapis meadow
#

it keeps telling me this

quick gust
#

ah i see

#

the color isnt a string

#

color should be without the ""

lapis meadow
#

k lemme checkk

fervent shard
#

can u give me an example

lapis meadow
#

@quick gust

#

I can kiss you CatKisso

#

Now I’m going to do the same things for all the other eventa

maiden fable
lapis meadow
#

Mine compared to Carl. How do I get it to tell me what channel it was deleted in?

maiden fable
#

message.channel

lapis meadow
maiden fable
#

u can also do {message.channel} only

lapis meadow
#

one more question

#

How do I get it to show the user ID and the time

quick gust
quick gust
lapis meadow
#

@quick gust PES_Think

maiden fable
#

For the time, u gotta use the datetime module

lapis meadow
#

eh

#

okeee

quick gust
slate swan
#
        if image is None:
            image = discord.File(f"data/images/{species.id}.png", filename="pokemon.png")
            embed.set_image(url="attachment://pokemon.png")
``` wdym by this
maiden fable
#

Delete time

quick gust
#

Oh it's the delete time

slate swan
lapis meadow
#

@maiden fable Do you know how to actually do that in code format? Also do I have to import anything?

fervent shard
#

how can i make a discord.py code doing β€œif messages are in this channel, react with β€œπŸŽ‰β€β€

lapis meadow
#

or @quick gust lol

slate swan
#

what have what have i done wrong here?

#

heyyyyyyy

slate swan
#

and its in a cog there isnt events

#

its

@commands.Cog.listener()
quick gust
#

and u need to import datetime

slate swan
#

timestamps?

quick gust
#

yeh

slate swan
#

ye

#

if you do

from datetime import datetime

then you just need

datetime.utcnow()
quick gust
slate swan
#

since its a method from that

fervent shard
#

code:py @bot.listen() async def on_message(msg): if 'wfl' in msg.content: await msg.add_reaction('\U0001f1fc') await msg.add_reaction('\U0001f1eb') await msg.add_reaction('\U0001f1f1') for word in filtered_words: if word in msg.content: await msg.delete() if message.channel = 943049242174427206 message.add_reaction(πŸŽ‰)error:

    if message.channel = 943049242174427206
                       ^
SyntaxError: invalid syntax```
slate swan
#

and wut comparing a channel obj to an int?

maiden fable
#

And what if I do

from datetime import datetime
datetime = None
fervent shard
quick gust
unkempt canyonBOT
#
Resources

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

slate swan
maiden fable
#

From when u know this much about the API πŸ‘€

slate swan
fervent shard
#

what do i put in the line instead?

#

id or channel name?

slate swan
#

you can compare the name or the id it doesnt matter

lapis meadow
#

This is what I have and this is what it shows

fervent shard
# slate swan well channel has an id attr no?
@bot.listen()
async def on_message(msg):
    if 'wfl' in msg.content:
      await msg.add_reaction('\U0001f1fc')
      await msg.add_reaction('\U0001f1eb')
      await msg.add_reaction('\U0001f1f1')
    for word in filtered_words:
        if word in msg.content:
            await msg.delete()
    if message.channel == 943049242174427206
       message.add_reaction(πŸŽ‰)``` this instead?
quick gust
lapis meadow
#

o

slate swan
#

bot.latency lol

lapis meadow
#

wdym? @slate swan

slate swan
fervent shard
slate swan
#
  1. forgot a colon
  2. use regex
  3. where are you pulling channel from if message is not defined
  4. add reaction is a coro
  5. param naming
lapis meadow
#

So, if you're talking about the time var what should I do instead?

scarlet rune
#

you sure it's in ms? or in seconds? you might want to multiply it by 1000 for ms?

quick gust
#

nope

slate swan
#

nano?

quick gust
#

probably not lmao

slate swan
#

bro

quick gust
#

!d discord.ext.commands.Bot.latency

unkempt canyonBOT
#

property latency: float```
Measures latency between a HEARTBEAT and a HEARTBEAT\_ACK in seconds.

This could be referred to as the Discord WebSocket protocol latency.
quick gust
#

no idea lol

scarlet rune
#

tbh no idea

slate swan
#

just says a float prob ms

#

if not nano

#

nvm

maiden fable
slate swan
zenith basin
#

?

maiden fable
#

Idk what's a snowflake no cap

zenith basin
slate swan
zenith basin
#

!ad eval

#

!d eval

unkempt canyonBOT
#

eval(expression[, globals[, locals]])```
The arguments are a string and optional globals and locals. If provided, *globals* must be a dictionary. If provided, *locals* can be any mapping object.
slate swan
#

like a snowflake which is always unique

maiden fable
slate swan
zenith basin
maiden fable
slate swan
#

in binary jeez

maiden fable
#

Yes

#

That's how stuff work

lapis meadow
#

So its showing this when a message is deleted:

#

HOw do I get it to display like carl bot lol

maiden fable
#

Use the timestamp kwarg

slate swan
# slate swan

ah so its a femtosecond just multiply it for a second

maiden fable
#

!d discord.Embed.timestamp

unkempt canyonBOT
#

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

slate swan
#

maths hard

maiden fable
slate swan
#

its not a millisecond

maiden fable
#

Your wish

lapis meadow
#

So how do I do that?

maiden fable
#

Multiplying by 1000 returns the ms

slate swan
maiden fable
lapis meadow
#

UTCnow()

maiden fable
slate swan
lapis meadow
#

I have that?

#

It shows this

#

I want it to show something like this

#

But I have no clue where to change t

#

Would I put it in the footer where {timestamp} is?

slate swan
#

no

#

timestamp returns a footer yes but its used for timestamps

lapis meadow
#

So what do I do to get it to display the local time

slate swan
lapis meadow
#

of when it happened

brazen raft
slate swan
slate swan
brazen raft
#

A millisecond multiplied by a thousand converts it to microseconds

maiden fable
#

oki, why u ain't listening to anyone rn

slate swan
#

ugh i hate math

maiden fable
#

Then just ignore that thing

slate swan
#

wut

brazen raft
# slate swan

Yes, a second multiplied by a thousand is a thousand milliseconds

#

Milli is a thousandth, micro is a millionth

slate swan
#

my brain is having a stroke lets change topic please😭

lapis meadow
#

okay but where do I actually get it to display?

slate swan
brazen raft
#

There is set_timestamp

slate swan
#
timestamp=datetime.utcnow()
brazen raft
#

Or do that

slate swan
#

but the timestamp kwarg takes all the footer

lapis meadow
#

the kwarg makes it so that it shows it like this 12:13 AM

#

instead of including everything else

slate swan
#

yeah

lapis meadow
#

okay

slate swan
#

if you want text then use footer

lapis meadow
#

I'm so confused on what I'm putting in the footer to make it look like 12:15 AM

#

like where do I look?

slate swan
#

you mean a timestamps format

lapis meadow
#

yes

#

I just want it to look like this