Skip to content

Commit

Permalink
Add command /selftimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
viotalJiplk committed May 27, 2023
1 parent 744aeee commit c90a51b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions cogs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ Containing timeout commands and manipulating with timeout.\
- /timeout user
- /timeout remove
- /timeout list
- /selftimeout
**Tasks:**

- refresh_timeout
Expand Down
18 changes: 18 additions & 0 deletions cogs/timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import utils
from cogs.base import Base
from config import cooldowns
from config.app_config import config
from config.messages import Messages
from permissions import permission_check
Expand Down Expand Up @@ -341,6 +342,23 @@ async def on_audit_log_entry_create(self, entry):

await self.submod_helper_room.send(embed=embed)

@cooldowns.default_cooldown
@commands.slash_command(name="selftimeout", description=Messages.self_timeout)
async def self_timeout(self, inter: disnake.ApplicationCommandInteraction, endtime: str = commands.Param(
autocomplete=autocomplete_times,
max_length=20, description=Messages.timeout_time
)):
await inter.response.defer(ephemeral=True)
endtime = await self.timeout_parse(inter, inter.user, endtime, Messages.self_timeout_reason)
if endtime is None:
raise commands.BadArgument
starttime = inter.created_at.astimezone(tz=utils.get_local_zone()).replace(tzinfo=None)
# convert to local time and remove timezone info
self.timeout_repo.add_timeout(inter.user.id, inter.author.id, starttime,
endtime, Messages.self_timeout_reason)
await inter.send(content=Messages.self_timeout_success, ephemeral=True)

@self_timeout.error
@timeout_user.error
async def timeout_error(self, inter: disnake.ApplicationCommandInteraction, error):
if isinstance(error, commands.BadArgument):
Expand Down
6 changes: 6 additions & 0 deletions config/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,12 @@ class Messages:
timeout_list_none = "Nenalezeny žádné umlčení."
timeout_member_not_found = "{member} Nikoho takového jsem na serveru nenašel. Ujisti se, že jsi uživatele zadal @tagem."

# SELFTIMEOUT COG
self_timeout = "Dočasně si zakážeš interakce na serveru"
self_timeout_reason = "Sebeumlčení"
self_timeout_something_went_wrong = "Něco se pokazilo"
self_timeout_success = "Sebeumlčení proběhlo úspěšně"

# TIMEOUT WARS
timeout_wars_user = "Uživatel {user} byl umlčen na {time:.0f} minut."
timeout_wars_message_delete = "Uživatel {user} byl přistižen při mazání zpráv. Byl proto umlčen na {time:.0f} minut."
Expand Down

0 comments on commit c90a51b

Please sign in to comment.