#dev-contrib

1 messages ยท Page 37 of 1

clever wraith
#

47 dependencies

#

damnn

#

DONE
also done
pipenv run precommit

hardy gorge
#

That's mainly because some of the packages we use have dependencies of their own.

green oriole
#

I thought they were way more tbh

clever wraith
#

Now we talking

green oriole
#

Oh wait you were working on the seasonalbot?

#

Okay okay

clever wraith
#

Oh lol

#

Now i have a piece of code

#

that i want to add as a command

#

now how to do that ?

crude gyro
#

guess you should take a look at how the other commands work and model that approach

clever wraith
#

bangs head on the table

#

my god this code is so complexxxxxx

green oriole
#

Not too complicated, just try to understand what piece of code do what

clever wraith
#

just give me one hint where is the code of .uwu .random , i will find my way from there

#

roll not random

brazen charm
#

pycharm has a project search feature when you do ctrl shift f

green oriole
#

Go inside the cogs/ folder and work your way in it

clever wraith
#

where is cogs

#

let me try it with pycharm wait

#

so evergreen season stays online forever with other season ?

#

?

#

what class does it belongs to ? !bookmark thing

green oriole
#

Evergreen

clever wraith
#

how to stop the bot if i closed the CMD ?

green oriole
#

If you closed it, it is down

#

Or CRTL + BREAK

clever wraith
#

will continue tomorrow , done adding the command need it to include in

#

Nice

whole ruin
#

I couldn't complete it cuz its already 12 here and school tomorrow

tawdry vapor
#

How do I access the staff logs?

#

is it just staff.pythondiscord.local?

#

cause I get a 404 for it

#

figured it out

#

have to add bot/logs/ with the deletion context id at the end

glass pecan
#

ye

tawdry vapor
#

Was it just not meant to be used there?

#

Yeah, it's meant to be used with format() when making an API call

tawdry vapor
green oriole
tawdry vapor
#

No, they were my improvements to the PR

#

I was testing it and figured I'd just make the changes myself while I have the code checked out

#

Instead of like, writing paragraphs about it and going back and forth

clever wraith
#

@green oriole there ?

#

.uptime

dusky shoreBOT
clever wraith
#

remove that #deleted-channel BTW

green oriole
#

Gonna go to eat, I'll be there in 1h or 2

clever wraith
#

ok will wait

#

Stupid as F question still
So i added a bookmark.py with similar syntax of uptime.py , but its not loading , how to make it to load
seasonalbot BTW

green oriole
#

@clever wraith have you pushed your changes to your fork yet?

#

So I can check it out

clever wraith
#

one second

#

how to push the changes ?

#

this doesn't worked

gusty sonnet
#

After you commit you will have to push

#

Do you have any GUI like github desktop?

#

Otherwise CLI is fine, you will need to set branch then do a push

clever wraith
#

why github so confusing

gusty sonnet
#

Git can be quite confusing at first, but once you know it it is considered essential when developing

#

source control is very veyr important

#

Github has an app - Github desktop, that you can download

#

It eases the commit push branch switching thingy

clever wraith
#

OMG GOT IT WORKING WITH THE BOT

#

@green oriole

#

I will add it a PR soon

gusty sonnet
#

It is a better practice to do smaller single-responsibility, well documented commits instead of a big one, so if you need to you can revert to any one of them

#

Commit more frequently!

clever wraith
#

If i get a way to submit it ,
its a very small commit
just a bookmark.py file and done

green oriole
#

If you want to learn more about git, I can't recommend you enough the pro git book, I read it to learn more about it, and it was crazy simple!

molten bough
#

I also find commit etiquette way more complex than actually using git most of the time

#

heh, commit etiquette

#

committiquette

green oriole
#

Commit etiquette?

molten bough
#

Learning when and why to commit, when to bunch commits or push them, how to write commit messages

#

learning to never force push (to master)

green oriole
#

Oh yeah that kind of etiquette

#

Force pushing can be useful

#

But yeah, not to master

#

Just. please no

gusty sonnet
#

stash
stash pop
omg where's my precious commits pls giv back

molten bough
#

haha

#

I use the thing that jetbrains recommends

#

shelve?

green oriole
#

Arg you use jetbrains features?

molten bough
#

oh god yes

#

why waste time with the command line

#

I already know how to use it

green oriole
#

Command line is great!

clever wraith
#

can you give me that guide @green oriole

green oriole
#

(except for stashing diiferent parts of a file)

molten bough
#

also I find that PyCharm is way better at automatically resolving merge conflicts than git itself is

clever wraith
#

right here is where i want the bookmark to be used

green oriole
#

I hate pycharm's way to handle merge conficts: do nothing

clever wraith
#

LOL

molten bough
#

there's nothing better than a nice 3-way mergetool

#

that at least is something the community can agree on

#

haha

green oriole
#

Yes I agree

#

But if I start resolving a merge conflit from the command line, PyCharm just don't care and doesn't open a solver or something

molten bough
#

also by the time pycharm has prompted you to handle a merge conflict, it's already tried to merge automatically

#

well yeah, you need to use the git tools built in for those git tools to work

#

it's not going to try to interfere with your manual workflow if you use it

green oriole
#

But I don't want to use them! ducky

molten bough
#

well then you clearly don't need the mergetool either

clever wraith
#

The commands can only be used in #seasonalbot-commands and #bot-commands channels

#

as said in issue comment

green oriole
#

It is a decorator

#

I think

#

But I prefer using a mergetool than just manually resolving the conflicts

molten bough
#

Why do you prefer the commandline to clicking a button and having PyCharm fetch, stash any changes as needed, pull, unstash, and try to merge conflicts?

green oriole
#

I find it easier

#

Everything in one place

molten bough
#

you find what easier?

green oriole
#

no need to go in a submenu of a submenu of a submenu of a submenu

molten bough
#

git pll no wait gt pull argh

#

there is no submenu?

#

it's right there in the toolbar

clever wraith
#

hey hey @green oriole listen
the code for 8bitify is

@commands.command(name="8bitify")
    async def eightbit_command(self, ctx: commands.Context) -> None:
        """Pixelates your avatar and changes the palette to an 8bit one."""
        async with ctx.typing():
            image_bytes = await ctx.author.avatar_url.read()
            avatar = Image.open(BytesIO(image_bytes))
            avatar = avatar.convert("RGBA").resize((1024, 1024))

            eightbit = self.pixelate(avatar)
            eightbit = self.quantize(eightbit)

            bufferedio = BytesIO()
            eightbit.save(bufferedio, format="PNG")
            bufferedio.seek(0)

            file = discord.File(bufferedio, filename="8bitavatar.png")

            embed = discord.Embed(
                title="Your 8-bit avatar",
                description='Here is your avatar. I think it looks all cool and "retro"'
            )

            embed.set_image(url="attachment://8bitavatar.png")
            embed.set_footer(text=f"Made by {ctx.author.display_name}", icon_url=ctx.author.avatar_url)

        await ctx.send(file=file, embed=embed)

where is the line which triggers that it is wrong channel ?

green oriole
#

It do it by default I think

#

Try it

molten bough
#

seasonalbot does it by default, yeah, afaik

#

I dunno what submenu you're talking about akarys

#

I only ever go into the VCS menu if I need to manually push a commit or I need to edit the remotes or something

green oriole
#

Like, if I want to amend the last commit, use all unstashed files and do not change the commit message commit -a --amend --no-edit I don't need to search for the option

clever wraith
#

here it is

molten bough
#

yeah, you don't need to search for the option in pycharm

#

hit version control at the bottom, find the commit in the log, right-click, rewrite

green oriole
#

Please, give it a better commit message AG

#

find the commit in the log
I can just do --amend instead

clever wraith
#

i will post the one i am sending here before sending it

molten bough
#

well if it's the latest commit then it's the top commit in the list, isn't it

#

toolbar buttons

#

pull, commit, compare, history, rollback

clever wraith
#

wrong emoji

green oriole
#

I learned git with the command line anyway, I don't see the point of re-learning everything

molten bough
#

the point is that it's faster

clever wraith
#

โœ…

molten bough
#

you remind me of those 60 year old linux kernel developers

#

I WILL USE SVN UNTIL I DIE

green oriole
#

I don't think it is faster

#

at least for me

clever wraith
#

it is

molten bough
#

clicking a single button is definitely faster than opening a terminal, fetching, stashing, pulling, unstashing, and resolving conflicts

#

even if your fingers are robotic

green oriole
#

I always have a terminal open ๐Ÿ™‚

molten bough
#

your point? haha

#

I mean hey, it's up to you to use the tools the way you prefer, but they are more efficient when used this way

#

until you actually start trying to use them, you'll never know.

green oriole
#

I tried them tbh, and I didn't liked

molten bough
#

I mean, if you think you need to go through submenus to pull, I'm not sure you tried it for long

#

haha

#

but you know, I agree with you

#

it's much more efficient to have all of the tools in one place

#

that place for me happens to be pycharm

green oriole
#

Okay, it wasn't in a submenu, but I'm sure some options of git are hidden

molten bough
#

Nothing you'll be using on a regular basis

green oriole
#

Yeah, you're right, like I run all my code from command line not from pycharm

molten bough
#

yeah, I have run configs

#

although you can't use pycharm's debugger without run configs either

#

so do you never use the debugger?

green oriole
#

Does print() count as a debugger?

molten bough
#

no

#

haha

green oriole
#

No I'm kidding

#

Actually.. I rarely debug

molten bough
#

womp womp

clever wraith
#

I202 Additional newline in a group of imports. 'from discord.ext import commands' is identified as Third Party and 'import discord' is identified as Third Party
while i lint it

green oriole
#

I use logs and stuff, but never actual debuggers

molten bough
#

AG, well, what do you think the problem is?

green oriole
#

You need to add a line break between them

molten bough
#

no, wrong

green oriole
#

*a blank line

molten bough
#

Neither of you read the error haha

clever wraith
#

it says third party

green oriole
#

You put too much blank lines ๐Ÿ™‚

molten bough
#

there we go

green oriole
#

haha

molten bough
#

you have a blank line where there shouldn't be one

clever wraith
#

I201 Missing newline between import groups. 'import discord' is identified as Third Party and 'import logging' is identified as Stdlib.

green oriole
#

I mean, I don't have the code in front of me soo..

molten bough
#

yep, now you need to add one

#

read the error

#

it's quite self-explanitory

green oriole
#

Missing

clever wraith
#

why its so tricky

molten bough
#

it's not tricky

green oriole
#

linters..

#

No okay linters are fine

#

Rules are sometimes weird

#

just need to get used to them

molten bough
#

there are three separate groups of imports and they should be separated by a blank line

clever wraith
#

D415 First line should end with a period, question mark, or exclamation point
"""A cog for Bookmark command"""
Really

molten bough
#

standard library, first party (as in, from the current project), and third party

#

yes, really

green oriole
#

Oh yeah, add a dot at the end

hardy gorge
#

Yes

molten bough
#

docstring linting, I must say, I fully support

green oriole
#

This one is pretty.. special?

#

but I can understand the point

clever wraith
#

TYP001 Missing type annotation for function argument 'ctx'
now what does that mean ,

#

:int

#

got it

molten bough
#

It means you're missing a type annotation for argument "ctx"

#

and it's not int

hardy gorge
#

The first line of a docstring should be a summary line summing up the class/method/function. As it needs to be a single, contained sentence, requiring a ., ! or ? at the end more or less guarantees people actually do that.

molten bough
#

that's for sure

green oriole
#

You know what typehints are?

clever wraith
#

i know just a type

molten bough
#

ctx is a Context object

#

look at the other command in the bot

clever wraith
#

commands.Context

molten bough
#

well, just Context, and import it from discord.commands

green oriole
#

I don't really see a case where you would put ? at the end of your docstring, like This function might do something?

molten bough
#

long type hints are not friendly

#
def freeze():
    """"
    Do you want to build a snowman?

    This function freezes ...
    """
clever wraith
#

D102 Missing docstring in public method
i really don't understand this one

molten bough
#

me_irl

#

Well that means you're missing a docstring

green oriole
#

Oh yeah!!

clever wraith
#

what is a docstring

molten bough
#

I'm sorry, what

#

oh right

molten bough
#

the error didn't say docstring

#

yeah, that's a docstring

#

you should document every public method or function with a docstring.

clever wraith
#

AHHH
a """ whatever i want is here """ thing

#

so that is called a docstring

molten bough
#

yes, that's a docstring. Triple-quoted string.

clever wraith
#

bot\seasons\evergreen\bookmark.py:16:28: TYP201 Missing return type annotation for public function

#

why so strict

molten bough
#

Yep, you haven't type hinted a return type

#

Because consistency is important and type hints are useful

green oriole
#

Because typehints are great!

molten bough
#

You'll get used to it.

clever wraith
#
    async def bm(self, ctx: commands.Context, hypelink: str =None, *args):
#

now what is wrong i don't get what you mean by typehints

molten bough
#

hypelink?

#

you mean hyperlink? or maybe just link?

green oriole
#

also call it bookmark instead

clever wraith
#

yeah hyperlink ;-; it uses that

molten bough
#

your default type has incorrect syntax also

#

anyway, return types are ```py
def function() -> Type:

green oriole
#

But the lint should tell it

gusty sonnet
#

Try to name it meaningful, you can add command name / alias in later

molten bough
#

yeah

clever wraith
#

Done

molten bough
#

bookmark instead of bm, add bm alias later

clever wraith
#
    async def bookmark(self, ctx: commands.Context, hypelink: str =None, *args)-> None:

molten bough
#

that link argument should have spaces around the = as well

clever wraith
#

now its that

molten bough
#

and don't call it hypelink, pls

#

I like that screenshot

#

haha

gusty sonnet
#

Me too

#

Quick, we help with the PR so we can bookmark it

green oriole
#

Well, you'll get a review for sure if you call it hypelink

clever wraith
#

its catchy so i am using hypelink

molten bough
#

don't use that

#

it's a useless name

green oriole
molten bough
#

it needs to be descriptive

gusty sonnet
#

It should be named jump_url or message_jump_url or message_link

#

a hyperlink is too generic

molten bough
#

or just link maybe

#

hmm, well, I guess, yeah

clever wraith
#

async def bookmark(self, ctx: commands.Context, hyperlink: str =None, *args)-> None:

#

ok now ?

green oriole
#

jump_url is used in the reminder cog, so you maybe should use it

clever wraith
#

happy now

gusty sonnet
#

Also hyperlink is used to refer to clickable text that has url

molten bough
#

yeah jump_url is probably better for consistency then

clever wraith
#

BC

molten bough
#

also that = needs a space on the right side of it

green oriole
#

hyperlink: str =None seems wrong too

#

Well

molten bough
#

jump_url: str = None

gusty sonnet
#

PyCharm should have an extension for auto formatting code, right?

molten bough
#

I mean that type hint is technically incorrect

gusty sonnet
#

for VSCode I have one that auto format accordingly to PEP8

molten bough
#

but I'm not sure discord.py will put up with Optional[str]

gusty sonnet
#

It does

molten bough
#

aha, then yeah

gusty sonnet
#

But it should be required anyway

clever wraith
#
    async def bookmark(self, ctx: commands.Context, jump_url: str = None, *args) -> None:
#

fine ?

molten bough
#

What does the command do if no jump URL is given?

gusty sonnet
#

Hmm, the jump url will never be None in that case

clever wraith
#

it checks for the message above the .bm

gusty sonnet
#

Like if you do !bm hello no link provided

green oriole
#

It does correct it

molten bough
#

Ah right

clever wraith
#

I planeed that

gusty sonnet
#

hello will be the jump_url

molten bough
#

Then it should be type hinted Optional[str]

gusty sonnet
#

So it will never be None

clever wraith
#
        if jump_url is None or jump_url == "*":
            channel = ctx.channel
            async for x in channel.history(limit=2):
                message_id = x.id
            try:
                message = await channel.fetch_message(message_id)
            except discord.NotFound:
                await ctx.send(">>> Message not in this"
                               " channel\nOr\nYou are trying to Pin"
                               " your own message,\nPlease use the channel"
                               " where message is.")
                return
            hyperlink = f"https://discordapp.com/channels/" \
                       f"{ctx.guild.id}/{channel.id}/{message.id}"

molten bough
#

I'm not sure it needs to take * as an argument in that case

gusty sonnet
#

What if you do !bm bookmark this message, this is a command with no link

molten bough
#

It just takes a url right now

gusty sonnet
#

What will your bot do

#

jump_url should take in bookmark

clever wraith
#
            if "discordapp.com/channels" not in jump_url:
                await ctx.send("INVALID URL")
                await ctx.send("An example of the command can be \n"
                               "!bm https://discordapp.com/channels"
                               "/267624335836053506/267631170882240512/"
                               "554639398130548746"
                               " Some of the hints here")
                return

green oriole
#

The jump_url is generated by d.py

molten bough
#

It's not

gusty sonnet
#

In that case yeah it should be just py jump_url: str

green oriole
#

Well, it can be

gusty sonnet
#

Adding = None to it is redundant

green oriole
#

I mean for the hyperlink

molten bough
#

It's not redundant

gusty sonnet
#

You mean for !bmbare?

#

That's the only case when it'll be None

molten bough
#

Yeah, which is a supported operation

clever wraith
gusty sonnet
#

In that case I'd say do a py @bookmark_error async def bookmark_error_handler(self, ctx, error): await ctx.send('You have to give me a link!')

molten bough
#

that's not

green oriole
#
hyperlink = f"https://discordapp.com/channels/" \
                       f"{ctx.guild.id}/{channel.id}/{message.id}"```-->
```py
hyperlink = message.jump_url```too
molten bough
#

no

#

If it's bare you just bookmark the previous message

gusty sonnet
#

Oooooooooh

#

I see, I see why you need the = None now

#

Carry on!

molten bough
#

however

#

kind of makes that feature useless

clever wraith
#

yeah i also said that

green oriole
#

It was discussed by the staff apparently

molten bough
#

"apparently" isn't really enough info

#

haha

green oriole
#

Well, it has been

gusty sonnet
#

It was discussed internally, the main concern is that it can be spammy in regular help channels interrupting conversations

#

In general it should be avoided

molten bough
#

Couldn't it just immediately remove the command message?

green oriole
#

^

clever wraith
#

yeah

molten bough
#

And then only reply in DM

clever wraith
#

thats what i said

molten bough
#

I mean, they may have discussed that, but that's what I'd do, haha

clever wraith
#

I don't think they discussed about that cuz the handler of that issue scragly went offline as soon as i commented that , and never came back , i don't think someone actually opened the issue and proceed to read even though they can see scragly reported it

woeful thorn
#

Yes, we did

green oriole
clever wraith
#

oh then NICE

#

last lint then i am pulling a PR

green oriole
#

ELA is sneaky, he set his status to idle so he can burst in the conversation at any moment haha

clever wraith
#

second last

#

LETS GOOO

molten bough
#

just remember that passed linting doesn't mean there won't be more reviewing :>

clever wraith
#

first ever PR

crude gyro
#

..Add files via upload?

green oriole
#

Your commit messages aren't really great

crude gyro
#

what kind of commit message is that

clever wraith
#

that one is from my fork

#

forgot to expand it

crude gyro
#

frankly, those commit messages aren't good enough.

green oriole
#

So just use them as the main message, not the descriptions

clever wraith
#

โœ“

green oriole
#

Did you deleted the old commits?

clever wraith
#

there are only 3 commits total ;-; it don't need anything else

green oriole
#

I mean, how does your commit history looks like right now?

clever wraith
green oriole
#

Aaaand you are on master

clever wraith
green oriole
#

Why you didn't commited from the command line or pycharm?

clever wraith
#

i am not confident with that yet

green oriole
#

You know what? Delete your repo, re-fork it, and then switch to a new branch, and upload your files with a nice commit message

#

We can help you if you want

clever wraith
#

i alredy created a PR

#

;-;

#

too late

green oriole
#

I think using the web interface is okay, as long as you write nice commit messages and you don't delete a file just to edit it

#

I'm sorry, but you need to reset the history of your branch

#

We can't merge that

clever wraith
#

I promise i will do it next time.

#

Please I have a ton of homework to do ;-; TBH

green oriole
#

No, we can't leave that in the history

#

I can do it for you if you want

#

But the commit author will be me then, if you really really can't do it @clever wraith

clever wraith
#

I can

#

ok lets do it

#

delete the PR ?

green oriole
#

No no if you have checked the allow edits from maintainers box, it is good

clever wraith
#

yeah i did

green oriole
#

Okay

clever wraith
#

Now what ?

green oriole
#

I'm squashing them

clever wraith
#

RIP

green oriole
#

Okay it is done

#

Time for reviewing

clever wraith
#

It will pass for sure

#

passed

green oriole
#

I mean, time for humans to review it

clever wraith
#

Oh so i now need 2 people

#

ofc not you cuz you are not human ofc

#

you can't approve it right

green oriole
#

Tbh, you can expect some changes

clever wraith
#

ik

#

sneaky @gusty sonnet

gusty sonnet
#

In order for a PR to be merged, you need 2 approves and at least one of them has to be from a core dev

clever wraith
#

lets see

green oriole
#

I can't start the bot

discord.ext.commands.errors.ExtensionFailed: Extension 'bot.seasons.evergreen.bookmark' raised an error: ClientException: The alias bookmark is already an existing command or alias.```
clever wraith
#

wtf

#

i can

#

should i try to git my fork and opening it

green oriole
#

I did it

clever wraith
#

I really have no idea

#

you see whats the issue

green oriole
#

You called the command bookmark and you want to add an alias bookmark

#

So d.py doesn't like it

clever wraith
#

ahhh

#

u guys made me do it

green oriole
#

Can you correct that quickly from the web edit please

clever wraith
#

doing

green oriole
#

Well, you were supposed to test it again

clever wraith
#

what should i do it

#

def book_mark ?

green oriole
#

Just delete the alias bookmark

clever wraith
green oriole
#

THE COMMIT MESSAGE!!

clever wraith
#

its good enough

green oriole
#

Not update bookmark.py

#

And fixed a bug isn't enough

#

Have you read the links lemon sent you?

#

You could do something like

Delete alias bookmark

Caused an error because the same alias was used twice```
clever wraith
#

i don't have time , i have ton of homework to do

molten bough
#

Fix error caused by command alias conflict or something

green oriole
#

Then do it later

clever wraith
#

ITS OK now

#

let it do it work

#

you want a demo ? i can invite u to my test server

green oriole
#

I prefer to test it in my own environment so we can be sure it can work outside of the machine on which the code was written ๐Ÿ™‚

clever wraith
#

Ok

green oriole
#

So, the commit message?

clever wraith
#

ahhhhhhhh

green oriole
#

I can rollback for you, and you re-commit it with a meaningful message, is it good for you?

clever wraith
#

Fine

#

why so peaky

#

picky* whatever is right

green oriole
#

Because when you browse though more than a thousand commits, the commit message is important

clever wraith
#

wait

#

have you done it ?

#

@green oriole

green oriole
#

not yet

#

Okay it is done

#

Please do not make me do that again

clever wraith
#

I think i found another bug lol

green oriole
#

Write good messages!

#

Do one commit per bug please

clever wraith
#

Am deleting the repo

#

will do it all over again

#

new PR and all

#

Ok ?

green oriole
#

I guess that's too late

tardy marsh
#

...

clever wraith
#

i did it alredy

#

the pr is closed alredy

green oriole
#

Yeah because I pushed just after you deleted it

#

Watever

clever wraith
#

LOL

green oriole
#

Please this time make a new branch too

#

Do not work on master

#

Bad things could happen

clever wraith
green oriole
molten bough
#

It's probably worth pointing out that development is a team effort, here

#

It's not about being picky, or having a linter that's too strict

#

We have a set of standards, and everyone has to follow them - it keeps the code readable, and it makes sure everyone knows exactly what's going on and why changes were made

#

A PR is often presented in isolation, but it's going to be a smaller piece of a larger project, and it's important that it also meets the standards everyone else adheres to

#

that said, we're not making updates for pacemaker software here, if you don't have time to read the literature that people are giving you, then your PR can wait

#

I get that this is your first PR, AG, but I know you're capable of this :>

clever wraith
#

;-;

#

working on it

molten bough
#

Also, don't stress out about rushing

#

If you need to do homework, do homework

#

Real life takes priority, yeah?

clever wraith
#

na

#

;-;

molten bough
#

you don't wanna know how much time I lost when I was staff over burning myself out :>

clever wraith
#

yeah i don't wanna

#

;-;

green oriole
#

You should ^^

molten bough
#

haha, I just mean, don't overdo it

#

it'll be fine if you need to something else

#

if you just keep beating your head off a wall, eventually you'll get a headache

clever wraith
#

what was the command to lint

#

nvm got it

#

no linting issue

#

working fine

#

looks like

#

@green oriole

green oriole
#

And you write a meaningful commit message, not Added file via upload (delete it)

clever wraith
#

it is the default line

gusty sonnet
#

It can be as short as Introduced `!bm` command for personal bookmarking message via message jump url

clever wraith
mellow hare
#

It just needs to be descriptive, that's all

clever wraith
gusty sonnet
#

You also want to create a branch first

#

Then commit to that branch instead of master

clever wraith
#

ok

gusty sonnet
#

In case things go wrong / when the master repo on the main repo updates

clever wraith
#

lets do that first

gusty sonnet
#

Otherwise it'll be a nightmare

#

You can open a PR from any branch

green oriole
#

Yep, it is a nightmare <_< (I did that for my first contrib)

clever wraith
#

how to push a branch ?

gusty sonnet
#

Afterward, you can change the branch to push for in the CLI

clever wraith
#

new branch โ˜‘๏ธ

#

now fine ? @green oriole

green oriole
#

Actually I don't think you need the extended description, but you written it, and there is never too much!

clever wraith
green oriole
#

You could have kept it..

#

Yes yes it is fine

clever wraith
#

hahahah

green oriole
#

just a bit of pickiness: can you delete the space before the comma ๐Ÿ™‚

clever wraith
green oriole
#

Saw it ^^

#

Perfect

clever wraith
#

next step add a pr ?

green oriole
#

Yep!

clever wraith
green oriole
#

The message body is weird, but it is fine

#

It can still be edited later and doesn't go in the history

clever wraith
#

---
name: .bookmarks
about: helps to bookmark something useful along hint(s) to find in future.
issue: Issue #323 



---

Provide a simple description of what the PR achieves. 

## Pull Request Details

Please ensure your PR fulfills the following criteria:

[ โœ“] Have you joined the PythonDiscord Community?
[ โœ“] Were your changes made in a Pipenv environment?
[โœ“ ] Does flake8 pass (pipenv run lint)


## Additional information

There is no check whether if the call is  in the right channel or not , because seasonalbot do it itself.
green oriole
#

๐Ÿ‘Œ

clever wraith
#

DONE

gusty sonnet
#

Hmm, I'm writing unit tests for bot.utils.time but somehow it is not being discovered, anyone knows why might be the case?

#

I created a tests.bot.utils.test_time.py

#
from unittest import TestCase

class TimeTests(TestCase):
    """Test helper functions in bot.utils.time."""

    def test_humanize_delta(self):
        ...```
#

It is not being discovered at all

green oriole
#

@clever wraith reviewed!

clever wraith
#

OMG

crude gyro
#

@green oriole putting an entire pull request in a single commit isn't really that much better, but at least the commit message is marginally better.

#

I kinda feel like you should read those links I posted earlier, too.

green oriole
#

I mean, he don't know how to use the command line, at least it is a meaningful commit message

#

I know, split commits in case you need to revert them

hardy gorge
#

@gusty sonnet Interesting and odd. I'll check it out later. Did you push that branch to the remote?

molten bough
#

I thought that was because he deleted his old PR and branch

gusty sonnet
#

I created the branch, didnt push my commits yet since I cant even discover all the tests on my vscode

#

This is everything it managed to find

hardy gorge
#

Does VSCode use a different test runner?

gusty sonnet
#

I'm discovering via unittest in it, not sure if it's different

#

I guess I can try via CLI

crude gyro
#

@green oriole so you're not gonna read those articles? they really might be helpful. you've made several cardinal sins here in this commit message:

hardy gorge
#

I mean, the current tests we have a definitely discovered by unittest when we run them, so if it's not recognizing other tests as well, it may be something local

green oriole
#

I mean, I didn't wrote the message

hardy gorge
#

can you try to run them from the command line?

#

pipenv run test?

green oriole
#

and I thing i might have already read them

clever wraith
#

@green oriole now how to edit the .py file that i submitted ?

crude gyro
#

I thought you were helping @clever wraith solve the problem, my mistake.

gusty sonnet
#

Interesting, I see the new stuff in settings.json now, I will fiddle with it

clever wraith
green oriole
#

some silly things

#

Can it be with it doesn't detect it?

#

@clever wraith you should better do it from command line now, since all changes need to be tested

hardy gorge
#

from which directory did you run the command, Akarys?

#

you should do it from the main directory of the repository

green oriole
#

Oh my bad, I though it doesn't matter

#

Seems logic

clever wraith
#

Done fixed all the grammatical issues . also simplified the code a bit .

gusty sonnet
#

Okay, so VSCode cannot discover the tests, the unittest command can

#

Guess I have to rely on it then

hardy gorge
#

Is there something we can change to make it work?

clever wraith
#

I hope now it passes @green oriole take a look

green oriole
#

Not at my computer right now, I will check it later ^^

gusty sonnet
#

I will have to look deeper into vscode, since unittest in cmd works just fine

#
self.assertIsInstance(error, ValueError)
self.assertEqual(str(error), 'max_units must be positive')
```is there a nicer way to do this lol
gusty sonnet
#

Thank you

#
with self.assertRaises(ValueError) as error:
    time.humanize_delta(relativedelta(days=2, hours=2), 'hours', max_units)
    self.assertEqual(str(error), 'max_units must be positive')
```like this, yes?
#

Should I include tests for the new functions in bot.utils.time? I should wait for the PR to be approved right?

#

Or should I just open a PR for the current functions, and open another later?

crude gyro
#

the current util functions have tests?

#

in that case, yes.

#

otherwise, well, it's your call.

#

ideally tests should be part of the same PR as the features.

gusty sonnet
#

Hmm, that's actually a better idea

#

I'll open a PR for the current functions then

#

Thanks lemon

crude gyro
#

np

gusty sonnet
#

Now someone tells me how to round relativedelta lol

tawdry vapor
#

with a lot of if statements

green oriole
#

Add a delta of one second ๐Ÿ˜

#

From my testing for the reminder cog, it is reliable

clever wraith
#

@crude gyro what is K&R ?

crude gyro
#

I explained it in one of the other comments.

molten bough
#

The authors of that C book, I thought

#

What's it RE python?

crude gyro
#

it's an indentation style where the braces are like this:

things = (
    "stuff"
)
molten bough
#

Oh! Right

#

And it was the same guys that came up with it, wasn't it

clever wraith
#

why its called K&R

molten bough
#

Brian Kernighan and Dennis Ritchie

clever wraith
#

?

crude gyro
#

yeah, kernighan and ritchie

clever wraith
#

ritchie

#

that name is familiar

crude gyro
hardy gorge
molten bough
#

Those guys are legends, I haven't written a single line of C and I've heard of them

clever wraith
#

lemon will squeeze me now see.

molten bough
#

In this world, it's squeeze or be squeezed.

green oriole
#

Yes, but if you squeeze lemon you end up with a lemonade, and I'm not sure this is what you want

gusty sonnet
tough imp
#

what is the purpose of def setUp(self): pass?

gusty sonnet
#

Mostly to setup variables for the class, right now it is not doing anything, I can remove it

#

In fact, yeah, I will remove it

green oriole
#

@clever wraith before I go, I resolved all conversation that you addressed, but there is still the ones that left. Just two small thing, can you please not comment "Agreed" on all comments and can you also press the apply suggestion button when avaliable, so it dismiss the comment, make sure you have commuted the good changes and gave credits to the reviewer please

clever wraith
#

yeah i really didnt knew that agree were gonna look like that mess

#

i thought it will bundle up everything

green oriole
hardy gorge
#

This is a bot that we're using; it notifies us of updates in dependencies that fix security vulnerabilities and creates an automated PR for that

green oriole
#

I know, but there isn't a security report or something linked everytime?

hardy gorge
#

Click on "commits"

green oriole
#

Oh yeah thanks

#

Hmm seems like a pretty severe breach

hardy gorge
#

Yeah, but I don't think we're severly affected. Still, there's not reason for us not to update soon, but we'll need to test it. The reason we're not that affected is that the privilege escalation is restricted to users who are already logged into the admin interface, meaning that the user should already have admin access. I'm also don't think we're affected, as I don't think we implement the functionality that triggers this specific thing. Still, better safe than sorry, so obviously we're going update.

clever wraith
#

@crude gyro just to be clear all you wanted me to change

from
embed.set_thumbnail(url="https://emojipedia-us.s3."
"dualstack.us-west-1.amazonaws.com"
"/thumbs/240/twitter/"
"233/incoming-envelope_1f4e8.png")

to

    embed.set_thumbnail(url="https://emojipedia-us.s3."
                            "dualstack.us-west-1.amazonaws.com"
                            "/thumbs/240/twitter/"
                            "233/incoming-envelope_1f4e8.png"
                        )
#

thats it ?

#

this comment

green oriole
#

No you need to a line break after the first parenthesis

clever wraith
green oriole
#

I mean, look at my message

#

Should be pretty clear

clever wraith
#

its same

#

as yours

green oriole
#

Not is is not

#

look at the first line

#

and the indent

clever wraith
#

fine now ?

green oriole
#

Wait

#

It doesnโ€™t work at all, does it?

#

Hmm nah should be fine

clever wraith
#

pycharm not giving any errors , should be fine

green oriole
#

Anyway, why PyCharm is coloring the text in gray?

clever wraith
#

cuz thats a hyperlink

#

there is also a underline there

#

I am resolving this comment

green oriole
#

whatever

clever wraith
#

wdym

green oriole
#

Refresh the page, I thought it will leave a comment of the review

molten bough
#

I see you two are having fun again

green oriole
#

Yep.

molten bough
#

Anything I can help with?

green oriole
#

I think we can redo the 100 comment PR haha

molten bough
#

Could just squash it

green oriole
#

Not sure, maybe you just can review it?

clever wraith
#

i don't really understand that

molten bough
#

Solid advice, that

#

If you use parens you don't need to escape the newline with a backslash

clever wraith
#

what is parenthesis . ;-;

molten bough
#
(
    "text"
    "more text"
)
clever wraith
#

never face that thing

#

that thing was done by pycharm itself

molten bough
#

You probably called it a bracket

#

Anyway, doesn't matter, you still gotta address the review

clever wraith
#

that gives a issue

#

without \

molten bough
#

Yes, and add parens

green oriole
#

Put parenthesis around it

molten bough
#

Are you reading what we type?

green oriole
#

Like, I left three example about it in the review

molten bough
#

And I left an example above

#

Haha

green oriole
#

Should be pretty self explanatory

clever wraith
molten bough
#

Yeah, you'll need to line up that second line

clever wraith
#

DONE

green oriole
#

K&R lemon said :)

clever wraith
#

isn't that K&R

molten bough
#

It is

clever wraith
#

Nice

#

this look fine ?

molten bough
#

I'm not sure it needs the newlines in the actual message text, but sure

green oriole
#

See my latest comment, use an embed instead

molten bough
#

I'd probably indent the strings too

hardy gorge
#

The closing parenthesis needs to be at the same level of await

molten bough
#

Or, yeah

clever wraith
#

not gonna make a embed for this little thing

molten bough
#

What Ves said

#

Alright, AG

clever wraith
green oriole
#

Error messages are all embeds, you should use one

molten bough
#

I should say, you seem to be responding that way to a lot of reviews

#

Don't forget to put your rationale in the comments

clever wraith
#

removing that actually

#

as @green oriole suggested

#

it never get triggered anyways

#

lemon also said that

molten bough
#

And it also doesn't make sense based on the command only working in a commands channel

clever wraith
#

yeah

#

sadly

#

maybe in future if we get something , we can use that

green oriole
#

Well, if you can provide a message ID, that's not a problem

clever wraith
#

message_link

#

trivia quiz throwning errors

#

?

green oriole
#

I mean, just use the d.py message converter and you can use the command in a different channel from where I was sent plus you can use a message ID

#

Yeah that's a windows problem

clever wraith
#

the command in a different channel

#

NO

#

they mentioned it can't be done

green oriole
#

If you use the converter you can

clever wraith
#

no

#

give me that link

#

i will point it out

clever wraith
green oriole
#

You can provide the channelid

clever wraith
#

so you mean doing .bm message_id channel_id *hints

green oriole
#

{channel ID}-{message ID}

#

Look at the first lookup of the converter

clever wraith
#

it just create a messy command , breaking the simplicty

green oriole
#

Yes, but it makes it useful

clever wraith
#

.bm link *hints does all that

green oriole
#

Or allow the user to pass the channel then

clever wraith
#

link contain 3 things , server id, channel id , message id respectively

#

see

green oriole
#

Anyway, using the converter is better, it avoid to repeat the code of the library, plus if the API changes, we don't need to make the changes ourselves and let d.py handle it

clever wraith
#

as far i know people uses copy id . they can do copy link and everything will be fine

#

also if people self host the bot it will make issues , cuz we are not defining server.id anywhere in .bm message_id channel_id *hints

green oriole
#

You can get it from the config

clever wraith
#

you mean those environmental variables ?

#

it work regardless

#

of the error

green oriole
#

It is a warning not an error

#

Imagine that it doesn't find the message, what is going to happen?

clever wraith
#

yeah thats why there was that

#

but thats not happening

#

right ?

#

you said that in the comment

green oriole
#

That could happen if you provide a fake link

clever wraith
#

u sure link

green oriole
#

But anyway, let the converter search for the message

clever wraith
#

but that if only triggers if the jump_url is none or *

#

so its not getting any kind of link anyways

green oriole
#

So why are you looping over it?

clever wraith
#

it skips the .bm message , and take one over it

green oriole
#

Pretty sure there is a better way to do it

clever wraith
#

as history also consist that .bm message

#

there is always a better way

green oriole
#

Plus, what why do you take only the id to re-fetch the message later?

clever wraith
#

yeah

#

only the message id , cuz ofcourse channel id will be same as ctx.channel.id

#

same with guild.id

green oriole
#

You can just do message = x inside your loop

clever wraith
#

i only need id , i never needed the message itself

brazen charm
#

Or use the message directly with the loop doing nothing else if you're just assigning directly

green oriole
#

So just directly use the jump_url of the message inside the loop

clever wraith
#

its used when jump_url is None or *

#

we are just looping around the same topic

green oriole
#

Change it to

async for message in channel.history(limit=2):
  jump_url = message.jump_url```
clever wraith
#

no

green oriole
#

Yes?

#

Why?

clever wraith
#

whats message.jump_url

crude gyro
#

what the fuck no. if you're not gonna listen to the reviewers when they make suggestions, just save yourself the trouble and close the PR right away.

#

it's never gonna get merged if you're not willing to work with us.

clever wraith
#

his saying not work with my code , like he thinks

#

we are just looping around.

#

for 30 mins straight

green oriole
#

message.jump_url is the d.py generated jump url

#

Instead of building it yourself

clever wraith
#

isn't that convert something

#

done a fix

green oriole
hardy gorge
#

The converter will work on messages in other channels as long as it is in the bot's cache

#

The raw command words like that

clever wraith
#

F i forgot to change color of embed

green oriole
#

It says to d.py to convert the url, or id to an actual Message object

hardy gorge
#

(The converter first tries to get the message out of the cache based on the message ID, regardless of channel)

green oriole
#

^ see why we should use it

#

Plus among a lot of other things

hardy gorge
#

It won't work if the message is not longer in the cache, which is pretty soon, since we have a large message volume

green oriole
#

It calls the api if it is not in the cache right?

hardy gorge
#

Yes, but that needs the correct channel id

clever wraith
#

will add that next commit

hardy gorge
#

Now, I'm not up to date on the review comments, so that's what you should go by for the feature

#

Just clarifying a few things said above

green oriole
#

Your cog docstring is still not very descriptive

clever wraith
#

lint force me to not go any further

hardy gorge
#

You can make longer docstrings for something if it needs clarification (I haven't seen the docstring in question); it's just that the first line needs to be a summary line.

green oriole
#

It is the docstring of the cogs

clever wraith
hardy gorge
#
def something():
    """
    Do something and return nothing.

    This function is absolutely useless. It does something, I don't know what and
    returns nothing, that is, `None`. However, I'm just faking a longer, multi-line
    docstring as an example, so it's still useful in its own way.
    """
    do_something()
clever wraith
#

if you want i can write a 2 paragraph on this

green oriole
#

It doesn't describe how the cog works at all

hardy gorge
#

Okay, so, what's important for our docstrings is that it's going to be used for two things:

  • Developers trying to read the code
  • The help menu (I'm not entirely sure about Seasonalbot's help)
green oriole
#

Plus A cog for bookmarking message doesn't seems to help a lot

clever wraith
hardy gorge
#

Now, you don't have to put a description of the entire API in the class docstring, since you have individual methods with docstrings for that.

clever wraith
#

that doesn't do that also

green oriole
#

I mean, this cog isn't used by the average user

hardy gorge
#

A summary line and a quick description of what it does and why is still a good thing

#

I think that Uptime docstring is pretty clear, it summarizes exactly what the cog is for

green oriole
#

Just checked, it doesn't affect the help page

hardy gorge
#

For further information on the exact API of the cog, you can read the docstrings of the individual commands

green oriole
#

But the docstring of the command does

clever wraith
#

can you suggest me some cog description

green oriole
#

The docstring of your command is Bookmark a message which isn't very useful too

clever wraith
#

m so messed up

#

god i hate english sometime

green oriole
#

Don't have time, I'm going to got and look for food haha

#

Not sure mine is better than yours

clever wraith
#

CMON

#

just give me a cog string

green oriole
#

I don't know, Use this cog to bookmark the message to get a link to that message in dm

#

I don't have the other docstring I don't know how to write it exactly

#

And do not use this docstring, that's just an example, it is pretty poorly written

clever wraith
#

let me try the one ```py
async for message in channel.history(limit=2):
jump_url = message.jump_url

#

it surprisingly worked

green oriole
#

I wouldn't have gave you if it didn't worked :p

#

Also Fixed some things isn't a good commit message

#

You should do one commit per fix, and write comprehensive commits

clever wraith
#

last commit , its done then
fixed no . after No hint provided
used that way of yours
fixed color scheming of embed

green oriole
#

Have you used the converter and used embeds for error messages?

clever wraith
#

using Colours.soft_green

#

there is no error message except the usage one

#

that doesn't require a embed

#

from bot.constants import Colours right

#

why its not Colors ?

green oriole
#

Because it has been written by someone from the UK

clever wraith
green oriole
#

?

clever wraith
#

colour change

#

either i am now f uped cuz @hardy gorge is writing for so long , its freaking me out sweatcat

#

can someone give me perfect cog string pleaseeeee

green oriole
#

You need to do things by yourself

#

You'll never learn otherwise

clever wraith
#

i changed it , no one liked it

hardy gorge
#

@clever wraith

[11:53 AM] AG: CMON
[11:54 AM] AG: just give me a cog string

These things are important to us. It may feel like overly bureaucratic to you as, in your mind, it's just quickly hacking a feature together, but we have other concerns. The features we have need to be maintained and the code needs to be reliable. Our bots are important tools in our community and we rely heavily on them; we simply can't have them break on us. (When they do, it's always a major crisis and people literally drop their regular work to fix it.)

That means that we set fairly high standards that help us make sure that maintaining features doesn't become a pain (because of bad readability) and features don't break the bot (because of badly tested code). That's why we have such a strict review process. In addition, each feature we add to the bot increases the amount of effort needed to maintain the bot. That's why we feel it's important to seriously consider features in conversations in Issues even if the change seems small and especially if the change comes from a non-core developer. In addition, each feature the bot has, has an effect of the community: More bot commands in channels, even if they're deleted, means more (temporary) bot responses, more noise, and more disruption. That's why we keep it to the essentials and that's why we discuss everything, either in the issue or internally in the core developer group.

clever wraith
green oriole
#

Oh wow

#

Well

clever wraith
#

Just wanna say, nice punctuations skills.

green oriole
#

I want to bookmark this

clever wraith
#

how that make any sense

#

;-;

green oriole
#

Well, that's a season specific cog

#

But it shouldn't be that way

#

Are you going to change it, yes or no?

clever wraith
#

i am

#

trying

#

my best

green oriole
#

I mean, if you doesn't change it, you'll never get your PR merged

#

Nice

clever wraith
#

is this fine

#

NOW

#

or more ?

#

i think that's it

green oriole
#

No

#

Did you listened what gdude and ves said?

#

First line is a short description, then a blank line, then the extended description

clever wraith
#

oh

#

yeah

hardy gorge
#

If we ignore the docstring itself for a minute, what would you like to include in it?

clever wraith
#

include in the class

#

?

hardy gorge
#

Actually writing down a docstring can be quite difficult; it needs to be short and readable, but at the same time still capture the essence of the cog.

#

What do you think should be in it so someone unfamiliar with your function knows what this class is about when reading the code?

#

Remember: very specific details of individual commands are already captured by the docstrings of those methods, so you don't have to include those in the class docstring

clever wraith
#

A cog for the ultimate bookmark command

#

my mind not working anymore

hardy gorge
#

Okay, so, it's a cog that creates personal bookmarks. How does it do that?

clever wraith
#

looks fine

#

you said you wanted it to include how it works
so i did that

    if no jump_url is given it fetch the id of
    last message in ctx channel and sending it to user's DM . ```
#

how you would like to see it ?

hardy gorge
#

Okay, the first two things are more or less details, but the very last part seems important: A "bookmark" is a bit of a vague term as it can mean anything. It's also important to note that these are personal bookmarks, not public bookmarks for everyone

clever wraith
#

yeah

hardy gorge
#

So, what I'd do (although I usually think a bit longer about the exact wording) is write a docstring that captures that essence. Something like this:

#
class Name:
    """A cog that creates personal bookmarks by relaying a message to the user's DMs."""

Now, this is not yet perfect, normally I think this over for quite some time if it's a difficult case, but it captures the essentials: We want to establish the term bookmarks, we want to convey that they're personal, and we highlight that it works by relaying messages to DMs.

clever wraith
#

I think that is fine

hardy gorge
#

The details of how the interface works (jump links, message id) can be described in the actual bookmark command method

clever wraith
#

TBH the command itself is a very basic, it don't need any sort of explaination

#

I am pushing it

#

that's it

green oriole
#

You.. Need a docstring for the cog

clever wraith
#

I know

#

finally done

#

added all the changes requested by @crude gyro and @green oriole i can now go and take some rest i think

green oriole
#

You still don't use the converter, I suggested two changes and lemon asked you to delete the embed footer

clever wraith
#

he never asked to delete the footer

#

its cool

#

i used the convertor

#

that you gave

#

applied suggestion of that description ^^

green oriole
#

I left other comments

clever wraith
#

embeds

#

ok

green oriole
#

But of course you can take a break if you want

clever wraith
#

i wanna complete it

green oriole
#

Taking a break is also important to still be productive

clever wraith
#

can i use an NEGATIVE_REPLIES ?

#

Constant

crude gyro
#

you can and you should.

#

if you're giving any kind of negatory reply

clever wraith
#

error reply

#

ERROR_REPLIES

#

remove footer
"Why everything so heavy?"

#

?

green oriole
#

I think it is what he said

clever wraith
#

is this fine

green oriole
#

What is Error:-?

clever wraith
#

no title then

green oriole
#

Yep remove it

#

Well, not the random message, the Error:- thing

clever wraith
green oriole
#

How does other cogs implement it?

clever wraith
#

making it to ""

#

maybe

#

Nope

#

I will just add something like - there

molten bough
#

Don't put a field in

#

Just set the description

clever wraith
#

doesn't work

molten bough
#

Yeah it does

#

Fields are optional, you don't need to add one at all

molten bough
#

You can just set the embed's description.

green oriole
#

Just use the random message, and the error message

clever wraith
#

yeah

#

got it

molten bough
#

Embed title/header, embed description

clever wraith
green oriole
#

Perfect

molten bough
#

Well, I'd put the spaces at the end of the strings, not the start of the next one

clever wraith
#

done both error , embeds on baby

molten bough
#

Also, "this" needs a capital T

clever wraith
molten bough
#

Yup

green oriole
#

Space before the : ?

molten bough
#

I'm not 100% sure about this error personally

#

No, akarys

green oriole
#

Oki

#

Why are you not sure about it?

molten bough
#

Well, the error is that the message can't be found, right?

green oriole
#

Yep

molten bough
#

So why do we have command syntax here?

green oriole
#

Oh yeah

molten bough
#

I'd have thought just a simple That message could not be found, please try another. would suffice

green oriole
#

But a syntax error could lead to that error

molten bough
#

If we need to display the syntax then perhaps we should show the actual command help

#

But I don't think so

#

You could be more verbose

green oriole
#

Yeah not sure that's a good idea

molten bough
#

Like, for example, Message URL invalid: Unable to find message

green oriole
#

Also @clever wraith, you don't log anything

#

Well, that could be a message ID too

molten bough
#

Okay, but there's no reason you couldn't have handling for that too

clever wraith
#

NICE

#

now what tf is wrong

molten bough
#

That one should really just be the actual help message

green oriole
#

You have *args at the end of your function arguments?

molten bough
#

That's not necessarily the right way to do that

green oriole
#

That's a seasonalbot generated message

#

Yeah, but he did it that way

molten bough
#

Oh, it is? Okay