Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
fix(MassDM): only allow use of safe model attributes
- Loading branch information
1 parent
32eccab
commit 92325be
Showing
2 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import discord | ||
|
|
||
|
|
||
| class SafeMember: | ||
| def __init__(self, member: discord.Member) -> None: | ||
| self.name = str(member.name) | ||
| self.display_name = str(member.display_name) | ||
| self.nick = str(member.nick) | ||
| self.id = str(member.id) | ||
| self.mention = str(member.mention) | ||
| self.discriminator = str(member.discriminator) | ||
| self.color = str(member.color) | ||
| self.colour = str(member.colour) | ||
| self.created_at = str(member.created_at) | ||
| self.joined_at = str(member.joined_at) | ||
|
|
||
| def __str__(self): | ||
| return self.name | ||
|
|
||
| def __getattr__(self, name): | ||
| return self | ||
|
|
||
|
|
||
| class SafeRole: | ||
| def __init__(self, role: discord.Role) -> None: | ||
| self.name = str(role.name) | ||
| self.id = str(role.id) | ||
| self.mention = str(role.mention) | ||
| self.color = str(role.color) | ||
| self.colour = str(role.colour) | ||
| self.position = str(role.position) | ||
| self.created_at = str(role.created_at) | ||
|
|
||
| def __str__(self): | ||
| return self.name | ||
|
|
||
| def __getattr__(self, name): | ||
| return self | ||
|
|
||
|
|
||
| class SafeGuild: | ||
| def __init__(self, guild: discord.Guild) -> None: | ||
| self.name = str(guild.name) | ||
| self.id = str(guild.id) | ||
| self.description = str(guild.description) | ||
| self.created_at = str(guild.created_at) | ||
|
|
||
| def __str__(self): | ||
| return self.name | ||
|
|
||
| def __getattr__(self, name): | ||
| return self |