From bde0ff1f660bdbf1c3046cf1efdb81877145fc08 Mon Sep 17 00:00:00 2001 From: beacon Date: Sat, 2 Jul 2022 09:24:20 +0300 Subject: [PATCH] all bot messages are wisible only for command sender, fix permission error --- cogs/first_cog.py | 20 ++++++++++++++++++-- test.py | 8 ++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/cogs/first_cog.py b/cogs/first_cog.py index d7cb195..e1c113c 100644 --- a/cogs/first_cog.py +++ b/cogs/first_cog.py @@ -1,5 +1,6 @@ import logging +import discord from discord.ext import commands @@ -12,8 +13,23 @@ class Test_Cog(commands.Cog): logging.info(f'Cog {__name__.split(".")[1]} is ready!.') @commands.command() # this is for making a command - async def ping(self, ctx): - await ctx.send(f'Pong! {round(self.bot.latency * 1000)}') + async def bot_info(self, ctx, bot): + # await ctx.send(f'Pong! {round(self.bot.latency * 1000)}') + emb = discord.Embed( + title=f"General information", + description=f"General information on about {bot}", + icon=bot.avatar_url + ) + emb.set_thumbnail(url=bot.avatar_url) + emb.add_field(name="General info", + value=f"Username: {bot}\n" + f"Nickname: {bot.nick}\n" + f"Joined at: {bot.joined_at.strftime('%A, %B %d %Y @ %H:%M:%S')}", inline=False) + # emb.add_field(name="Audio list", value=f"{audios}", inline=True) + # emb.add_field(name="Roles list", value=f"{roles}", inline=True) + emb.set_footer(text="Information requested by: {}".format(ctx.author.display_name)) + + await ctx.reply(embed=emb, ephemeral=True) def setup(bot): # a extension must have a setup function diff --git a/test.py b/test.py index df40253..0c3d60a 100644 --- a/test.py +++ b/test.py @@ -312,7 +312,7 @@ async def slash_set_prefix(ctx, prefix: str): @slash_set_prefix.error @command_set_prefix.error -async def set_prefix_error(ctx): +async def set_prefix_error(ctx, prefix): await ctx.reply('You don`t have permissions', ephemeral=True) @@ -364,7 +364,7 @@ async def info(ctx, user=None): @commands.has_permissions(administrator=True) async def set_trigger_role(ctx, role): await Commands.write_json(ctx.guild.id, "tigger_role", role.id) - await ctx.send(f"Role to trigger set to : `{role.name}`") + await ctx.send(f"Role to trigger set to : `{role.name}`", ephemeral=True) @inter_client.slash_command( @@ -377,7 +377,7 @@ async def set_trigger_role(ctx, role): @commands.has_permissions(administrator=True) async def set_bot_role(ctx, role): await Commands.write_json(ctx.guild.id, "bot_role", role.id) - await ctx.send(f"Setted up bot role to: `{role.name}`") + await ctx.send(f"Setted up bot role to: `{role.name}`", ephemeral=True) @inter_client.slash_command( @@ -421,7 +421,7 @@ async def slash_cogs(ctx, what_do, cogs=None): @commands.has_permissions(administrator=True) async def set_guest_role(ctx, role): await Commands.write_json(ctx.guild.id, "guest_role", role.id) - await ctx.send(f"Setted up bot role to: `{role.name}`") + await ctx.send(f"Setted up bot role to: `{role.name}`", ephemeral=True) bot.run('OTQ3OTUzOTAxNzgzNjIxNjYy.GTXbMv.KrztaTO7-ivsPEAVjsyikSQ-GP-ANwULmDraig')