@@ -215,117 +215,6 @@ async def embed(self, context: Context, *, message: str) -> None:
215215 embed = discord .Embed (description = message , color = 0xBEBEFE )
216216 await context .send (embed = embed )
217217
218- @commands .hybrid_group (
219- name = "blacklist" ,
220- description = "Get the list of all blacklisted users." ,
221- )
222- @commands .is_owner ()
223- async def blacklist (self , context : Context ) -> None :
224- """
225- Lets you add or remove a user from not being able to use the bot.
226-
227- :param context: The hybrid command context.
228- """
229- if context .invoked_subcommand is None :
230- embed = discord .Embed (
231- description = "You need to specify a subcommand.\n \n **Subcommands:**\n `add` - Add a user to the blacklist.\n `remove` - Remove a user from the blacklist." ,
232- color = 0xE02B2B ,
233- )
234- await context .send (embed = embed )
235-
236- @blacklist .command (
237- base = "blacklist" ,
238- name = "show" ,
239- description = "Shows the list of all blacklisted users." ,
240- )
241- @commands .is_owner ()
242- async def blacklist_show (self , context : Context ) -> None :
243- """
244- Shows the list of all blacklisted users.
245-
246- :param context: The hybrid command context.
247- """
248- blacklisted_users = await self .bot .database .get_blacklisted_users ()
249- if len (blacklisted_users ) == 0 :
250- embed = discord .Embed (
251- description = "There are currently no blacklisted users." , color = 0xE02B2B
252- )
253- await context .send (embed = embed )
254- return
255-
256- embed = discord .Embed (title = "Blacklisted Users" , color = 0xBEBEFE )
257- users = []
258- for bluser in blacklisted_users :
259- user = self .bot .get_user (int (bluser [0 ])) or await self .bot .fetch_user (
260- int (bluser [0 ])
261- )
262- users .append (f"• { user .mention } ({ user } ) - Blacklisted <t:{ bluser [1 ]} >" )
263- embed .description = "\n " .join (users )
264- await context .send (embed = embed )
265-
266- @blacklist .command (
267- base = "blacklist" ,
268- name = "add" ,
269- description = "Lets you add a user from not being able to use the bot." ,
270- )
271- @app_commands .describe (user = "The user that should be added to the blacklist" )
272- @commands .is_owner ()
273- async def blacklist_add (self , context : Context , user : discord .User ) -> None :
274- """
275- Lets you add a user from not being able to use the bot.
276-
277- :param context: The hybrid command context.
278- :param user: The user that should be added to the blacklist.
279- """
280- user_id = user .id
281- if await self .bot .database .is_blacklisted (user_id ):
282- embed = discord .Embed (
283- description = f"**{ user .name } ** is already in the blacklist." ,
284- color = 0xE02B2B ,
285- )
286- await context .send (embed = embed )
287- return
288- total = await self .bot .database .add_user_to_blacklist (user_id )
289- embed = discord .Embed (
290- description = f"**{ user .name } ** has been successfully added to the blacklist" ,
291- color = 0xBEBEFE ,
292- )
293- embed .set_footer (
294- text = f"There { 'is' if total == 1 else 'are' } now { total } { 'user' if total == 1 else 'users' } in the blacklist"
295- )
296- await context .send (embed = embed )
297-
298- @blacklist .command (
299- base = "blacklist" ,
300- name = "remove" ,
301- description = "Lets you remove a user from not being able to use the bot." ,
302- )
303- @app_commands .describe (user = "The user that should be removed from the blacklist." )
304- @commands .is_owner ()
305- async def blacklist_remove (self , context : Context , user : discord .User ) -> None :
306- """
307- Lets you remove a user from not being able to use the bot.
308-
309- :param context: The hybrid command context.
310- :param user: The user that should be removed from the blacklist.
311- """
312- user_id = user .id
313- if not await self .bot .database .is_blacklisted (user_id ):
314- embed = discord .Embed (
315- description = f"**{ user .name } ** is not in the blacklist." , color = 0xE02B2B
316- )
317- await context .send (embed = embed )
318- return
319- total = await self .bot .database .remove_user_from_blacklist (user_id )
320- embed = discord .Embed (
321- description = f"**{ user .name } ** has been successfully removed from the blacklist" ,
322- color = 0xBEBEFE ,
323- )
324- embed .set_footer (
325- text = f"There { 'is' if total == 1 else 'are' } now { total } { 'user' if total == 1 else 'users' } in the blacklist"
326- )
327- await context .send (embed = embed )
328-
329218
330219async def setup (bot ) -> None :
331220 await bot .add_cog (Owner (bot ))
0 commit comments