update(doc|readme): Add cogs.admin's commands todo

refactor(command|admin): rewrite some of all admin's command
This commit is contained in:
Romain J 2019-09-13 11:20:17 +02:00
parent d6f155e682
commit d0a9e658a6
9 changed files with 121 additions and 22 deletions

View file

@ -27,4 +27,22 @@
## Ultimate :
- [ ] Send email or Telegram's message when something is wrong on the bot
- [ ] Create skynet (group of multiple commands about sky (planes, meteo,...))
- [ ] Create skynet (group of multiple commands about sky (planes, meteo,...))
---
# Cogs.admin commands
- [ ] upload
- [x] ban
- [x] kick
- [x] clear
- [x] say
- [x] sayto `removed`, now : `say to`
- [x] sayto_dm `removed`, now : `say to`
- [x] editsay `removed`, now : `say edit`
- [x] addreaction `renamed`
- [ ] delete
- [ ] deletefrom
- [ ] embed

View file

@ -1,4 +1,5 @@
import datetime
from typing import Union
import discord
from discord.ext import commands
@ -55,22 +56,49 @@ class Admin(commands.Cog):
"""---------------------------------------------------------------------"""
@commands.command(name='say')
async def _say(self, ctx: commands.Context, *, to_say: str):
@commands.group(name='say', invoke_without_command=True)
async def _say(self, ctx: commands.Context, *, content: str):
try:
await ctx.message.delete()
await ctx.send(to_say)
except discord.errors.Forbidden:
await ctx.send(to_say)
pass
await ctx.send(content)
@_say.command(name='edit')
async def _say_edit(self, ctx: commands.Context, message_id: int, *,
content: str):
try:
await ctx.message.delete()
except discord.errors.Forbidden:
pass
try:
message: discord.Message = await ctx.channel.fetch_message(
message_id)
await message.edit(content=content)
except (discord.errors.NotFound, discord.errors.Forbidden):
await ctx.send(Texts('utils').get("Unable to find the message"))
@_say.command(name='to')
async def _say_to(self, ctx: commands.Context,
channel: Union[discord.TextChannel, discord.User], *,
content):
try:
await ctx.message.delete()
except discord.errors.Forbidden:
pass
await channel.send(content)
"""---------------------------------------------------------------------"""
@commands.command(name='ban')
async def _ban(self, ctx: commands.Context, user: discord.User, *,
reason=""):
member: discord.Member = await ctx.guild.fetch_member(user.id)
try:
member: discord.Member = await ctx.guild.fetch_member(user.id)
if member:
try:
await member.ban(reason=reason)
e: discord.Embed = await self.kick_ban_message(
@ -83,17 +111,17 @@ class Admin(commands.Cog):
await ctx.send(embed=e)
except discord.Forbidden:
await ctx.send(Texts('admin').get("Unable to ban this user"))
else:
await ctx.send(Texts('admin').get("Unable to find the user..."))
except discord.errors.NotFound:
await ctx.send(Texts('utils').get("Unable to find the user..."))
"""---------------------------------------------------------------------"""
@commands.command(name='kick')
async def _kick(self, ctx: commands.Context, user: discord.User, *,
reason=""):
member: discord.Member = await ctx.guild.fetch_member(user.id)
try:
member: discord.Member = await ctx.guild.fetch_member(user.id)
if member:
try:
await member.kick(reason=reason)
e: discord.Embed = await self.kick_ban_message(
@ -105,9 +133,9 @@ class Admin(commands.Cog):
await ctx.send(embed=e)
except discord.Forbidden:
await ctx.send(Texts('admin').get("Unable to ban this user"))
else:
await ctx.send(Texts('admin').get("Unable to find the user..."))
await ctx.send(Texts('admin').get("Unable to kick this user"))
except discord.errors.NotFound:
await ctx.send(Texts('utils').get("Unable to find the user..."))
"""---------------------------------------------------------------------"""
@ -130,15 +158,24 @@ class Admin(commands.Cog):
async def _react_add(self, ctx: commands.Context, message_id: int, *,
emojis: str):
emojis: list = emojis.split(' ')
message: discord.Message = await ctx.channel.fetch_message(message_id)
for emoji in emojis:
await message.add_reaction(emoji)
try:
message: discord.Message = await ctx.channel.fetch_message(
message_id)
for emoji in emojis:
await message.add_reaction(emoji)
except discord.errors.NotFound:
await ctx.send(Texts('utils').get("Unable to find the message"))
@_react.command(name='clear')
async def _react_remove(self, ctx: commands.Context, message_id: int):
message: discord.Message = await ctx.channel.fetch_message(message_id)
await message.clear_reactions()
try:
message: discord.Message = await ctx.channel.fetch_message(
message_id)
await message.clear_reactions()
except discord.errors.NotFound:
await ctx.send(Texts('utils').get("Unable to find the message"))
"""---------------------------------------------------------------------"""

View file

@ -21,5 +21,5 @@ msgstr ""
msgid "Unable to ban this user"
msgstr ""
msgid "Unable to find the user..."
msgid "Unable to kick this user"
msgstr ""

Binary file not shown.

View file

@ -0,0 +1,22 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2019-09-08 19:04+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
msgid "Unable to find the user..."
msgstr ""
msgid "Unable to find the message"
msgstr ""

Binary file not shown.

View file

@ -21,5 +21,5 @@ msgstr "Merci d'entrer une raison"
msgid "Unable to ban this user"
msgstr "Impossible de bannir cet utilisateur"
msgid "Unable to find the user..."
msgstr "Impossibe de trouver l'utilisateur..."
msgid "Unable to kick this user"
msgstr "Impossible d'expulser cet utilisateur"

Binary file not shown.

View file

@ -0,0 +1,22 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2019-09-08 19:04+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
msgid "Unable to find the user..."
msgstr "Impossibe de trouver l'utilisateur..."
msgid "Unable to find the message"
msgstr "Impossible de trouver le message"