Add mc!about command

Closes #46
master
Tristan Gosselin-Hane 6 years ago
parent 2cfe3bb1cc
commit 6701641f03
No known key found for this signature in database
GPG Key ID: 0B7E55B60DCA15D5
  1. 24
      minecraft_discord_bridge/minecraft_discord_bridge.py

@ -23,6 +23,7 @@ import discord
from mcstatus import MinecraftServer from mcstatus import MinecraftServer
from bidict import bidict from bidict import bidict
import minecraft_discord_bridge
from .database_session import DatabaseSession from .database_session import DatabaseSession
from .elasticsearch_logger import ElasticsearchLogger, ConnectionReason from .elasticsearch_logger import ElasticsearchLogger, ConnectionReason
from .config import Configuration from .config import Configuration
@ -286,6 +287,28 @@ class MinecraftDiscordBridge():
await error_msg.delete() await error_msg.delete()
return return
elif message.content.startswith("mc!about"):
send_channel = message.channel
try:
if isinstance(message.channel, discord.abc.GuildChannel):
await message.delete()
dm_channel = message.author.dm_channel
if not dm_channel:
await message.author.create_dm()
send_channel = message.author.dm_channel
msg = "This bot is running minecraft-discord-bridge version {}.\n" \
"The source code is available at https://github.com/starcraft66/minecraft-discord-bridge" \
.format(minecraft_discord_bridge.__version__)
await send_channel.send(msg)
return
except discord.errors.Forbidden:
if isinstance(message.author, discord.abc.User):
msg = "{}, please allow private messages from this bot.".format(message.author.mention)
error_msg = await message.channel.send(msg)
await asyncio.sleep(3)
await error_msg.delete()
return
elif message.content.startswith("mc!"): elif message.content.startswith("mc!"):
# Catch-all # Catch-all
send_channel = message.channel send_channel = message.channel
@ -489,6 +512,7 @@ class MinecraftDiscordBridge():
"`mc!tab`: Sends you the content of the server's player/tab list\n" "`mc!tab`: Sends you the content of the server's player/tab list\n"
"`mc!register`: Starts the minecraft account registration process\n" "`mc!register`: Starts the minecraft account registration process\n"
"`mc!botlink`: Sends you the link to invite this bot to a guild\n" "`mc!botlink`: Sends you the link to invite this bot to a guild\n"
"`mc!about`: Sends you information about the running bridge\n"
"To start chatting on the minecraft server, please register your account using `mc!register`.") "To start chatting on the minecraft server, please register your account using `mc!register`.")
return help_str return help_str

Loading…
Cancel
Save