|
24 | 24 | #Init |
25 | 25 | discord.VoiceClient.warn_nacl = False |
26 | 26 | load_dotenv() |
27 | | -BOT_VERSION = '1.7.6' |
| 27 | +BOT_VERSION = '1.7.7' |
28 | 28 | APP_FOLDER_NAME = 'AutoPublisher' |
29 | 29 | BOT_NAME = 'AutoPublisher' |
30 | 30 | if not os.path.exists(f'{APP_FOLDER_NAME}//Logs'): |
@@ -599,104 +599,107 @@ async def broadcast(message): |
599 | 599 | @tree.command(name = 'support', description = 'Get invite to our support server.') |
600 | 600 | @discord.app_commands.checks.cooldown(1, 60, key=lambda i: (i.user.id)) |
601 | 601 | async def support_invite_command(interaction: discord.Interaction): |
| 602 | + await interaction.response.defer(ephemeral = True) |
| 603 | + |
602 | 604 | if str(interaction.guild.id) != SUPPORT_ID: |
603 | | - await interaction.response.defer(ephemeral = True) |
604 | 605 | await interaction.followup.send(await Functions.create_support_invite(interaction), ephemeral = True) |
605 | 606 | else: |
606 | | - await interaction.response.send_message('You are already in our support server!', ephemeral = True) |
| 607 | + await interaction.followup.send('You are already in our support server!', ephemeral = True) |
607 | 608 |
|
608 | 609 |
|
609 | 610 | #Tell user what permissions are required |
610 | 611 | @tree.command( |
611 | 612 | name='permissions', |
612 | 613 | description='Tell what permissions are required or check if the bot has necessary permissions in a channel.' |
613 | 614 | ) |
| 615 | +@discord.app_commands.guild_only() |
614 | 616 | @discord.app_commands.describe(choice='Choose an option.', channel='Select channel.') |
615 | 617 | @discord.app_commands.choices(choice=[ |
616 | 618 | discord.app_commands.Choice(name="Explain permissions", value="explain"), |
617 | 619 | discord.app_commands.Choice(name="Check bot permissions", value="check") |
618 | 620 | ]) |
619 | 621 | async def permissions_command(interaction: discord.Interaction, choice: str, channel: discord.abc.GuildChannel = None): |
620 | | - if interaction.guild is None: |
621 | | - await interaction.response.send_message('This command can only be used in a server.', ephemeral=True) |
622 | | - return |
| 622 | + await interaction.response.defer(ephemeral=True) |
| 623 | + |
623 | 624 | if interaction.user.guild_permissions.manage_roles or interaction.user.guild_permissions.manage_channels: |
624 | 625 | if choice == 'explain': |
625 | | - await interaction.response.send_message('In order for this bot to be able to publish messages, he needs the following permissions for each channel he publishes messages for:\n`View Channel`, `Send Messages`, `Manage Messages` and `Read Message History`.', ephemeral=True) |
| 626 | + await interaction.followup.send('In order for this bot to be able to publish messages, he needs the following permissions for each channel he publishes messages for:\n`View Channel`, `Send Messages`, `Manage Messages` and `Read Message History`.', ephemeral=True) |
626 | 627 | elif choice == 'check': |
627 | 628 | if channel is None: |
628 | | - await interaction.response.send_message('Please specify a channel.', ephemeral=True) |
| 629 | + await interaction.followup.send('Please specify a channel.', ephemeral=True) |
629 | 630 | return |
630 | 631 |
|
631 | 632 | if isinstance(channel, discord.TextChannel): |
632 | 633 | if not channel.is_news(): |
633 | | - await interaction.response.send_message('The specified channel is not an announcement channel.', ephemeral=True) |
| 634 | + await interaction.followup.send('The specified channel is not an announcement channel.', ephemeral=True) |
634 | 635 | return |
635 | 636 |
|
636 | 637 | perms = channel.permissions_for(interaction.guild.me) |
637 | 638 | needed_permissions = ['view_channel', 'send_messages', 'manage_messages', 'read_message_history', 'add_reactions'] |
638 | 639 | missing_permissions = [perm for perm in needed_permissions if not getattr(perms, perm)] |
639 | 640 |
|
640 | 641 | if interaction.guild.me.guild_permissions.administrator: |
641 | | - await interaction.response.send_message('The bot has Administrator, so he has all the necessary permissions in this channel.', ephemeral=True) |
| 642 | + await interaction.followup.send('The bot has Administrator, so he has all the necessary permissions in this channel.', ephemeral=True) |
642 | 643 | elif not missing_permissions: |
643 | | - await interaction.response.send_message('The bot has all the necessary permissions in this channel.', ephemeral=True) |
| 644 | + await interaction.followup.send('The bot has all the necessary permissions in this channel.', ephemeral=True) |
644 | 645 | else: |
645 | | - await interaction.response.send_message(f'The bot is missing the following permissions in this channel: {", ".join(missing_permissions)}.\nYou can also give him Administrator.', ephemeral=True) |
| 646 | + await interaction.followup.send(f'The bot is missing the following permissions in this channel: {", ".join(missing_permissions)}.\nYou can also give him Administrator.', ephemeral=True) |
646 | 647 | else: |
647 | | - await interaction.response.send_message('Please specify a text channel.', ephemeral=True) |
| 648 | + await interaction.followup.send('Please specify a text channel.', ephemeral=True) |
648 | 649 | else: |
649 | | - await interaction.response.send_message('You need the `manage_roles` or `manage_channels` permission to use this command.', ephemeral=True) |
| 650 | + await interaction.followup.send('You need the `manage_roles` or `manage_channels` permission to use this command.', ephemeral=True) |
650 | 651 |
|
651 | 652 |
|
652 | 653 | #Bot Information |
653 | 654 | @tree.command(name = 'botinfo', description = 'Get information about the bot.') |
654 | 655 | @discord.app_commands.checks.cooldown(1, 60, key=lambda i: (i.user.id)) |
655 | 656 | async def botinfo_command(interaction: discord.Interaction): |
656 | | - member_count = sum(guild.member_count for guild in bot.guilds) |
657 | | - |
658 | | - embed = discord.Embed( |
659 | | - title=f"Information about {bot.user.name}", |
660 | | - color=discord.Color.blue() |
661 | | - ) |
662 | | - embed.set_thumbnail(url=bot.user.avatar.url if bot.user.avatar else '') |
663 | | - |
664 | | - embed.add_field(name="Created at", value=bot.user.created_at.strftime("%d.%m.%Y, %H:%M:%S"), inline=True) |
665 | | - embed.add_field(name="Version", value=BOT_VERSION, inline=True) |
666 | | - embed.add_field(name="Uptime", value=str(datetime.timedelta(seconds=int((datetime.datetime.now() - start_time).total_seconds()))), inline=True) |
667 | | - |
668 | | - embed.add_field(name="Owner", value=f"<@!{OWNERID}>", inline=True) |
669 | | - embed.add_field(name="\u200b", value="\u200b", inline=True) |
670 | | - embed.add_field(name="\u200b", value="\u200b", inline=True) |
671 | | - |
672 | | - embed.add_field(name="Server", value=f"{len(bot.guilds)}", inline=True) |
673 | | - embed.add_field(name="Member count", value=str(member_count), inline=True) |
674 | | - embed.add_field(name="\u200b", value="\u200b", inline=True) |
675 | | - |
676 | | - embed.add_field(name="Shards", value=f"{bot.shard_count}", inline=True) |
677 | | - embed.add_field(name="Shard ID", value=f"{interaction.guild.shard_id if interaction.guild else 'N/A'}", inline=True) |
678 | | - embed.add_field(name="\u200b", value="\u200b", inline=True) |
679 | | - |
680 | | - embed.add_field(name="Python", value=f"{platform.python_version()}", inline=True) |
681 | | - embed.add_field(name="discord.py", value=f"{discord.__version__}", inline=True) |
682 | | - embed.add_field(name="Sentry", value=f"{sentry_sdk.consts.VERSION}", inline=True) |
683 | | - |
684 | | - embed.add_field(name="Repo", value=f"[GitHub](https://github.com/Serpensin/DiscordBots-AutoPublisher)", inline=True) |
685 | | - embed.add_field(name="Invite", value=f"[Invite me](https://discord.com/oauth2/authorize?client_id={bot.user.id})", inline=True) |
686 | | - embed.add_field(name="\u200b", value="\u200b", inline=True) |
687 | | - |
688 | | - if interaction.user.id == int(OWNERID): |
689 | | - # Add CPU and RAM usage |
690 | | - process = psutil.Process(os.getpid()) |
691 | | - cpu_usage = process.cpu_percent() |
692 | | - ram_usage = round(process.memory_percent(), 2) |
693 | | - ram_real = round(process.memory_info().rss / (1024 ** 2), 2) |
694 | | - |
695 | | - embed.add_field(name="CPU", value=f"{cpu_usage}%", inline=True) |
696 | | - embed.add_field(name="RAM", value=f"{ram_usage}%", inline=True) |
697 | | - embed.add_field(name="RAM", value=f"{ram_real} MB", inline=True) |
698 | | - |
699 | | - await interaction.response.send_message(embed=embed) |
| 657 | + await interaction.response.defer(ephemeral = False) |
| 658 | + |
| 659 | + member_count = sum(guild.member_count for guild in bot.guilds) |
| 660 | + |
| 661 | + embed = discord.Embed( |
| 662 | + title=f"Information about {bot.user.name}", |
| 663 | + color=discord.Color.blue() |
| 664 | + ) |
| 665 | + embed.set_thumbnail(url=bot.user.avatar.url if bot.user.avatar else '') |
| 666 | + |
| 667 | + embed.add_field(name="Created at", value=bot.user.created_at.strftime("%d.%m.%Y, %H:%M:%S"), inline=True) |
| 668 | + embed.add_field(name="Version", value=BOT_VERSION, inline=True) |
| 669 | + embed.add_field(name="Uptime", value=str(datetime.timedelta(seconds=int((datetime.datetime.now() - start_time).total_seconds()))), inline=True) |
| 670 | + |
| 671 | + embed.add_field(name="Owner", value=f"<@!{OWNERID}>", inline=True) |
| 672 | + embed.add_field(name="\u200b", value="\u200b", inline=True) |
| 673 | + embed.add_field(name="\u200b", value="\u200b", inline=True) |
| 674 | + |
| 675 | + embed.add_field(name="Server", value=f"{len(bot.guilds)}", inline=True) |
| 676 | + embed.add_field(name="Member count", value=str(member_count), inline=True) |
| 677 | + embed.add_field(name="\u200b", value="\u200b", inline=True) |
| 678 | + |
| 679 | + embed.add_field(name="Shards", value=f"{bot.shard_count}", inline=True) |
| 680 | + embed.add_field(name="Shard ID", value=f"{interaction.guild.shard_id if interaction.guild else 'N/A'}", inline=True) |
| 681 | + embed.add_field(name="\u200b", value="\u200b", inline=True) |
| 682 | + |
| 683 | + embed.add_field(name="Python", value=f"{platform.python_version()}", inline=True) |
| 684 | + embed.add_field(name="discord.py", value=f"{discord.__version__}", inline=True) |
| 685 | + embed.add_field(name="Sentry", value=f"{sentry_sdk.consts.VERSION}", inline=True) |
| 686 | + |
| 687 | + embed.add_field(name="Repo", value=f"[GitHub](https://github.com/Serpensin/DiscordBots-AutoPublisher)", inline=True) |
| 688 | + embed.add_field(name="Invite", value=f"[Invite me](https://discord.com/oauth2/authorize?client_id={bot.user.id})", inline=True) |
| 689 | + embed.add_field(name="\u200b", value="\u200b", inline=True) |
| 690 | + |
| 691 | + if interaction.user.id == int(OWNERID): |
| 692 | + # Add CPU and RAM usage |
| 693 | + process = psutil.Process(os.getpid()) |
| 694 | + cpu_usage = process.cpu_percent() |
| 695 | + ram_usage = round(process.memory_percent(), 2) |
| 696 | + ram_real = round(process.memory_info().rss / (1024 ** 2), 2) |
| 697 | + |
| 698 | + embed.add_field(name="CPU", value=f"{cpu_usage}%", inline=True) |
| 699 | + embed.add_field(name="RAM", value=f"{ram_usage}%", inline=True) |
| 700 | + embed.add_field(name="RAM", value=f"{ram_real} MB", inline=True) |
| 701 | + |
| 702 | + await interaction.followup.send(embed=embed) |
700 | 703 |
|
701 | 704 |
|
702 | 705 |
|
|
0 commit comments