1
Fork 0
mirror of https://github.com/RGBCube/minearchy-bot synced 2025-07-27 17:07:45 +00:00

add count command and check if the channel exists

This commit is contained in:
RGBCube 2022-06-06 09:20:34 +00:00
parent 0f40fc65d0
commit 2c8c271ef1
3 changed files with 31 additions and 12 deletions

View file

@ -1,3 +1,4 @@
from __future__ import annotations from __future__ import annotations
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
@ -26,14 +27,17 @@ class MinecraftServer(
f"Java edition IP: `{self.bot.mc_server.ip}`\nBedrock edition IP: `{self.bot.mc_server.bedrock_ip}`" f"Java edition IP: `{self.bot.mc_server.ip}`\nBedrock edition IP: `{self.bot.mc_server.bedrock_ip}`"
) )
@ip.command(brief="Sends the Java edition IP.", help="Sends the Java edition IP.") @ip.command(
brief="Sends the Java edition IP.", help="Sends the Java edition IP."
)
async def java(self, ctx: commands.Context, /) -> None: async def java(self, ctx: commands.Context, /) -> None:
await ctx.reply( await ctx.reply(
f"The IP to connect on Minecraft Java edition is `{self.bot.mc_server.ip}`" f"The IP to connect on Minecraft Java edition is `{self.bot.mc_server.ip}`"
) )
@ip.command( @ip.command(
brief="Sends the Bedrock edition IP.", help="Sends the Bedrock edition IP." brief="Sends the Bedrock edition IP.",
help="Sends the Bedrock edition IP.",
) )
async def bedrock(self, ctx: commands.Context, /) -> None: async def bedrock(self, ctx: commands.Context, /) -> None:
await ctx.reply( await ctx.reply(
@ -59,19 +63,22 @@ class MinecraftServer(
view = discord.ui.View() view = discord.ui.View()
view.add_item( view.add_item(
discord.ui.Button( discord.ui.Button(
label="Go to the wiki!", url="https://www.landsofminearchy.com/wiki" label="Go to the wiki!",
url="https://www.landsofminearchy.com/wiki",
) )
) )
await ctx.reply(view=view) await ctx.reply(view=view)
@commands.command( @commands.command(
brief="Sends the link to the store.", help="Sends the link to the store." brief="Sends the link to the store.",
help="Sends the link to the store.",
) )
async def store(self, ctx: commands.Context, /) -> None: async def store(self, ctx: commands.Context, /) -> None:
view = discord.ui.View() view = discord.ui.View()
view.add_item( view.add_item(
discord.ui.Button( discord.ui.Button(
label="Go to the store!", url="https://www.landsofminearchy.com/store" label="Go to the store!",
url="https://www.landsofminearchy.com/store",
) )
) )
await ctx.reply(view=view) await ctx.reply(view=view)

View file

@ -51,7 +51,17 @@ class Miscellanious(
@commands.command(brief="Hello!", help="Hello!") @commands.command(brief="Hello!", help="Hello!")
async def hello(self, ctx: commands.Context, /) -> None: async def hello(self, ctx: commands.Context, /) -> None:
await ctx.reply(f"Hi {es_md(ctx.author.name)}, yes the bot is running :)") await ctx.reply(
f"Hi {es_md(ctx.author.name)}, yes the bot is running :)"
)
@commands.command(
aliases=["server_count", "server-count"],
brief="Sends how many servers the bot is in.",
help="Sends how many servers the bot is in.",
)
async def count(self, ctx: commands.Context, /) -> None:
await ctx.reply(f"Currently in `{len(self.bot.guilds)}` servers.")
@commands.Cog.listener() @commands.Cog.listener()
async def on_message_delete(self, message: discord.Message, /) -> None: async def on_message_delete(self, message: discord.Message, /) -> None:
@ -76,9 +86,11 @@ class Miscellanious(
self, ctx: commands.Context, channel: discord.TextChannel = None, / self, ctx: commands.Context, channel: discord.TextChannel = None, /
) -> None: ) -> None:
if channel is None: if channel is None:
channel = ( channel = ctx.channel
ctx.channel
) # i am not checking if the channel is in the current server, since this bot is for a private server if not any(channel.id == ch.id for ch in ctx.guild.chanels):
await ctx.reply("Invalid channel.")
return
logs = self.sniped[channel.id] logs = self.sniped[channel.id]