diff --git a/cogs/commands.py b/cogs/commands.py index 3120913..2e1a647 100644 --- a/cogs/commands.py +++ b/cogs/commands.py @@ -1,6 +1,6 @@ -import discord +import nextcord import json -from discord.ext import commands +from nextcord.ext import commands class Commands(commands.Cog): def __init__(self, client): @@ -16,10 +16,10 @@ async def createstatusmsg(self, ctx): with open('data.json') as data: self.data = json.load(data) - embed = discord.Embed( + embed = nextcord.Embed( title="MCStatusBot Configured 🎉", description=f"This message will be updated with the status message automatically.", - color=discord.Colour.blue()) + color=nextcord.Colour.blue()) message = await ctx.send(embed=embed) await ctx.message.delete() @@ -34,14 +34,14 @@ async def createstatusmsg(self, ctx): @commands.command() async def help(self, ctx): - embed = discord.Embed( + embed = nextcord.Embed( title="Commands of MCStatusBot", description=f"{self.config['bot_prefix']}createstatusmsg - allow you to create a message where will be configured the status message.", - color=discord.Colour.dark_blue()) + color=nextcord.Colour.dark_blue()) embed.set_footer(text="Bot developed by SuperKali#8716") await ctx.send(embed=embed) -def setup(client): - client.add_cog(Commands(client)) \ No newline at end of file +async def setup(client): + client.add_cog(Commands(client)) \ No newline at end of file diff --git a/main.py b/main.py index 2a31c8e..8330a16 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,10 @@ -import discord +import asyncio +import nextcord import time import json import os -from discord.ext import commands +from nextcord.ext import commands from mcstatus import JavaServer, BedrockServer from colorama import init, Fore, Style, Back from apscheduler.schedulers.asyncio import AsyncIOScheduler @@ -11,13 +12,12 @@ with open('config.json') as config_file: config = json.load(config_file) -client = commands.Bot(command_prefix=config["bot_prefix"], help_command=None, intents=discord.Intents.all()) +client = commands.Bot(command_prefix=config["bot_prefix"], help_command=None, intents=nextcord.Intents.all()) bot_token = config['bot_token'] count_all_servers = {} - @client.event async def on_ready(): @@ -25,7 +25,7 @@ async def on_ready(): init(autoreset=True) # Initialize the status of the bot in the presence - await client.change_presence(status=discord.Status.online, activity=discord.Activity(type=discord.ActivityType.playing, name="...loading")) + await client.change_presence(status=nextcord.Status.online, activity=nextcord.Activity(type=nextcord.ActivityType.playing, name="...loading")) # Check if you have configured the discord server id @@ -46,7 +46,7 @@ async def on_ready(): print(f"[{time.strftime('%d/%m/%y %H:%M:%S')}] ERROR: The owner_id set in the configuration file is invalid!") global enabled_cogs - # Enable all cogs to the bot + # Search all cogs for i in os.listdir('./cogs'): if i.endswith('.py'): client.load_extension(f'cogs.{i[:-3]}') @@ -71,7 +71,7 @@ async def update_servers_status(): channel_message = server_id.get_channel(config['channel_status_id']) if channel_message is not None: - txt = discord.Embed(title=config['message_title'], description=f"{config['message_description']}\n", colour=discord.Colour.orange()) + txt = nextcord.Embed(title=config['message_title'], description=f"{config['message_description']}\n", colour=nextcord.Colour.orange()) with open('data.json') as data_file: data = json.load(data_file) @@ -81,10 +81,10 @@ async def update_servers_status(): try: pinger_message = await channel_message.fetch_message(int(data['pinger_message_id'])) - checking = discord.Embed(description=config["message_checking_embed"], colour=discord.Colour.orange()) + checking = nextcord.Embed(description=config["message_checking_embed"], colour=nextcord.Colour.orange()) await pinger_message.edit(embed=checking) - except discord.errors.NotFound: + except nextcord.errors.NotFound: return print(Style.NORMAL + Fore.RED + "[MCStatusBot] " + Fore.RESET + Fore.CYAN + f"The bot is not configured yet.. missing the command {config['bot_prefix']}createstatusmsg on the text channel") @@ -122,7 +122,7 @@ async def update_servers_status(): print(f"[{time.strftime('%d/%m/%y %H:%M:%S')}] I could not find the indicated discord server.") return 0 else: - await client.change_presence(status=discord.Status.idle, activity=discord.Activity(type=discord.ActivityType.playing, name="🟠 Maintenance")) + await client.change_presence(status=nextcord.Status.idle, activity=nextcord.Activity(type=nextcord.ActivityType.playing, name="🟠 Maintenance")) async def update_presence_status(): servers = count_all_servers.values() @@ -131,7 +131,7 @@ async def update_presence_status(): if value.get("count_on_presence", False): status.append(int(value.get('online', 0))) - await client.change_presence(status=discord.Status.online, activity=discord.Activity(type=discord.ActivityType.playing, name=config["presence_name"].format(players=sum(status)))) + await client.change_presence(status=nextcord.Status.online, activity=nextcord.Activity(type=nextcord.ActivityType.playing, name=config["presence_name"].format(players=sum(status)))) count_all_servers.clear() async def send_console_status(): diff --git a/requirements.txt b/requirements.txt index 0e785c7..877ff5f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ mcstatus -discord +nextcord asyncio apscheduler colorama \ No newline at end of file