mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 15:48:29 +02:00
Snipe, fixes #43
This commit is contained in:
parent
ce1e2e7272
commit
01266b1346
6 changed files with 117 additions and 10 deletions
40
data/embeds/snipe.py
Normal file
40
data/embeds/snipe.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
from data.snipe import Snipe
|
||||
import discord
|
||||
from startup.didier import Didier
|
||||
|
||||
|
||||
class EditSnipe:
|
||||
"""
|
||||
Creates an Embed to snipe people that edited a message
|
||||
"""
|
||||
def __init__(self, snipe: Snipe):
|
||||
self.snipe = snipe
|
||||
|
||||
def to_embed(self, client: Didier) -> discord.Embed:
|
||||
guild: discord.Guild = client.get_guild(self.snipe.guild)
|
||||
member: discord.Member = guild.get_member(self.snipe.user)
|
||||
|
||||
embed = discord.Embed(title="Edit Snipe", colour=discord.Colour.blue())
|
||||
embed.set_author(name=member.display_name, icon_url=member.avatar_url)
|
||||
embed.add_field(name="Voor", value=self.snipe.old, inline=False)
|
||||
embed.add_field(name="Na", value=self.snipe.new, inline=False)
|
||||
|
||||
return embed
|
||||
|
||||
|
||||
class DeleteSnipe:
|
||||
"""
|
||||
Creates an Embed to snipe people that removed a message
|
||||
"""
|
||||
def __init__(self, snipe: Snipe):
|
||||
self.snipe = snipe
|
||||
|
||||
def to_embed(self, client: Didier) -> discord.Embed:
|
||||
guild: discord.Guild = client.get_guild(self.snipe.guild)
|
||||
member: discord.Member = guild.get_member(self.snipe.user)
|
||||
|
||||
embed = discord.Embed(title="Delete Snipe", colour=discord.Colour.blue())
|
||||
embed.set_author(name=member.display_name, icon_url=member.avatar_url)
|
||||
embed.add_field(name="Message", value=self.snipe.old)
|
||||
|
||||
return embed
|
||||
24
data/snipe.py
Normal file
24
data/snipe.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
from enum import Enum
|
||||
|
||||
from attr import dataclass
|
||||
|
||||
|
||||
class Action(Enum):
|
||||
"""
|
||||
Enum to indicate what action was performed by the user
|
||||
"""
|
||||
Edit = 0
|
||||
Remove = 1
|
||||
|
||||
|
||||
@dataclass
|
||||
class Snipe:
|
||||
"""
|
||||
Dataclass to store Snipe info
|
||||
"""
|
||||
user: int
|
||||
channel: int
|
||||
guild: int
|
||||
action: Action
|
||||
old: str
|
||||
new: str = None
|
||||
Loading…
Add table
Add a link
Reference in a new issue