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:
parent
0f40fc65d0
commit
2c8c271ef1
3 changed files with 31 additions and 12 deletions
4
bot.py
4
bot.py
|
@ -70,8 +70,8 @@ class MinearchyBot(commands.Bot):
|
||||||
async with self, aiohttp.ClientSession() as session:
|
async with self, aiohttp.ClientSession() as session:
|
||||||
self.session = session
|
self.session = session
|
||||||
self.log_webhook = discord.Webhook.from_url(
|
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.load_extensions()
|
||||||
await self.start(self.token, reconnect=True)
|
await self.start(self.token, reconnect=True)
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
|
|
20
cogs/misc.py
20
cogs/misc.py
|
@ -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]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue