Skip to content
This repository has been archived by the owner on Nov 22, 2021. It is now read-only.

Add a command to view all warned users and their warns. #70

Open
TKelsier opened this issue Sep 30, 2020 · 4 comments
Open

Add a command to view all warned users and their warns. #70

TKelsier opened this issue Sep 30, 2020 · 4 comments

Comments

@TKelsier
Copy link

Everyone, but those who have access to the db warns table, have no way of seeing who they have warned without remembering it or writing it down themselves. I've started developing a method to accomplish this task and will make a pull request when finished but thought I should share the idea asap. The plan is for a Menu Embed like the help menu which will display the usual embed upon using the warn list (user) command, furthermore, it will be one page per warned user. Also, the command, as of right now, is >>warns listall. If you have any thoughts on a different name for it please lmk.

Question: Should the permissions to use this command be only for those who can make warns or @everyone? I personally feel that normal users should not have the ability to see the warns of another user -- they should only be able to view their own warning list.

@parafoxia
Copy link
Owner

The warn list command can load other people's warns, so it depends whether I want to lock that down, or keep it open.

@TKelsier
Copy link
Author

TKelsier commented Sep 30, 2020

This is the logic behind the cmd, everything else is formatting. Going to wait to do formatting until the warn points system gets updated and code is accessible.

To sum it up, you search through the db for all userIDs with the current guild then insert that list into a key dictionary to remove duplicates. Then you take that dictionary and revert it back into a list. The list has "(" at the beginning and ",)" at the end of each userID so they are "removed" at each iteration, [1:19]. A user object is created from this id which can be used for everything else, getting the warns for that user, user's display name, colour, etc.

warned_users = await self.bot.db.records(
    "SELECT UserID FROM warns WHERE GuildID = ?", ctx.guild.id
)

warned_users = list(dict.fromkeys(warned_users))

for user_id in warned_users:
    user = self.bot.get_user(int(str(user_id)[1:19]))```

@parafoxia
Copy link
Owner

parafoxia commented Sep 30, 2020

You can use db.column to do the same thing. You won't need the from keys line at all.

@TKelsier
Copy link
Author

Perfect, thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants