Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get all tags from author #26

Open
tarto-dev opened this issue Apr 14, 2024 · 9 comments
Open

Get all tags from author #26

tarto-dev opened this issue Apr 14, 2024 · 9 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@tarto-dev
Copy link
Owner

No description provided.

@tarto-dev tarto-dev added enhancement New feature or request good first issue Good for newcomers labels Apr 14, 2024
@kaestro
Copy link
Contributor

kaestro commented Apr 15, 2024

Hi, I'm interested in joining this project for this seems to be useful when using discord and I'm a fan of it

I want to start from this issue but have hard time where to start reading the source code from

Would you mind giving me some hints on it?

Also, where can i find the test codes and the code conventions?

@tarto-dev
Copy link
Owner Author

Hello @kaestro, thanks for reaching me on this issue.

You can find mostly all the information you need within the contributing guide and Readme.

Here, the main task is to implement a author @commands.slash_command into commands/tag_commands.py who will look into the database for a given author.

You'll need to implement a new database query into /db.py to allow this command to works, and maybe into /context_menu.py if you intend to add a new app-subcommand.

Please don't hesitate to reach me here if you need further explains about the issue, bot setup or this project

@kaestro
Copy link
Contributor

kaestro commented May 1, 2024

@tarto-dev

Do get all tags from author mean that this needs to specify which author has written the tag?

if it's so, I wonder how I can test to create tags from other user.

Or does it mean to get all tags from the user who used the command itself?

@kaestro
Copy link
Contributor

kaestro commented May 1, 2024

Another question

kaestro@5d16e73

I tried creating the command, and the problem is the if I type in author as my discord account 'kaestro' no message comes out.

My guess is that when saving tags, created by isn't saved as raw string, or does it? Is there any way that I should be formatting before using sqlite?

@tarto-dev
Copy link
Owner Author

Hey @kaestro, authors are stored by user_id to handle names changes.

As you can notice here https://github.com/tarto-dev/tagsy-discord/blob/master/modals%2Fadd_tag.py#L61

The trick is to search for users in the current server with that ID and recover the username with it.

@tarto-dev
Copy link
Owner Author

This should do the work

async def get_username(guild_id, user_id):
    guild = client.get_guild(guild_id)
    if guild:
        member = await guild.fetch_member(user_id)
        if member:
            return member.name
    return "User not found"

(they're might be some mistake as I'm typing with my phone ^^')

@kaestro
Copy link
Contributor

kaestro commented May 2, 2024

This should do the work

async def get_username(guild_id, user_id):
    guild = client.get_guild(guild_id)
    if guild:
        member = await guild.fetch_member(user_id)
        if member:
            return member.name
    return "User not found"

(they're might be some mistake as I'm typing with my phone ^^')

I couldn't find where get_guild or client are at. Is it supposed to be inside context_menu?

Only place I could spot guild_id was inside context_menu.py and couldn't find where client is initialized.

Also, can you guide me on opening up db of tagsy-discord project? I think this kind of problem is happening for I don't know the structure of db itself, use of disnake, etc.

Thank you for your support even when you couldn't access the pc :)

@tarto-dev
Copy link
Owner Author

Hey! Sorry for the late reply, I was in vacation.

Those two methods are herited by the discord SDK (Disnake) and are accessible from Client or Context variables. You should be able to get the information from the documentation.

I can give you a database dump, but you can access it just by running the app and adding a tag. You then should be able to mount/read it with vscode and it's sqlite plug-in.

If you want, I can share my discord username to avoid github delay and give you further explanation 😉

Just let me know if you need anything else

@kaestro
Copy link
Contributor

kaestro commented May 9, 2024

How was your vacation? Did you go to abroad?

It's really glad to hear that you've gone for a vacation had maybe had a good time there :)

I agree with the idea that sharing discord username will help a lot. Send me yours through my email address (xxxxxxxxxxxxxxxx) or maybe opening up a channel can help.

EDIT Tarto : Since issues are public, I edited your post to remove your mail address.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants