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

4
bot.py
View file

@ -70,8 +70,8 @@ class MinearchyBot(commands.Bot):
async with self, aiohttp.ClientSession() as session:
self.session = session
self.log_webhook = discord.Webhook.from_url(
self.webhook_url, session=self.session, bot_token=self.token
)
self.webhook_url, session=self.session, bot_token=self.token
)
await self.load_extensions()
await self.start(self.token, reconnect=True)

View file

@ -1,3 +1,4 @@
from __future__ import annotations
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}`"
)
@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:
await ctx.reply(
f"The IP to connect on Minecraft Java edition is `{self.bot.mc_server.ip}`"
)
@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:
await ctx.reply(
@ -59,19 +63,22 @@ class MinecraftServer(
view = discord.ui.View()
view.add_item(
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)
@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:
view = discord.ui.View()
view.add_item(
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)

View file

@ -51,7 +51,17 @@ class Miscellanious(
@commands.command(brief="Hello!", help="Hello!")
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()
async def on_message_delete(self, message: discord.Message, /) -> None:
@ -76,9 +86,11 @@ class Miscellanious(
self, ctx: commands.Context, channel: discord.TextChannel = None, /
) -> None:
if channel is None:
channel = (
ctx.channel
) # i am not checking if the channel is in the current server, since this bot is for a private server
channel = ctx.channel
if not any(channel.id == ch.id for ch in ctx.guild.chanels):
await ctx.reply("Invalid channel.")
return
logs = self.sniped[channel.id]