最初这只是针对特定 Minecraft 版本和特定加载器的一个冷门项目,但现在它已扩展到了所有我关心的 Minecraft 版本!
Nilcord | 又一个用于 Minecraft 的 Discord 桥接模组
Nilcord 通过 Discord 机器人(可选地配合 Webhook),将你的 Minecraft 服务器聊天连接到一个指定的 Discord 文本频道。
安装
要设置此模组,只需将模组文件放入 mods 目录中(如果使用 NilLoader,则放入 nilmods 目录),启动你的 Minecraft 服务器,并等待它生成配置文件(由于配置尚未填充,此时会崩溃)。
配置文件名为 nilcord.toml,位于 config 文件夹中,其内容相当一目了然。
(默认配置)
# 与 Discord 相关的设置
[discord]
# 要使用的 Discord 机器人令牌
# 默认值:
token = ""
# 机器人发送消息至 / 接收消息的默认 Discord 频道 ID。需与 send_to 和 receive_from 配合使用。可以为空!
# 默认值:
channel_id = ""
# 机器人发送消息的其他 Discord 频道 ID
send_to = []
# 机器人接收消息的其他 Discord 频道 ID
receive_from = []
# 与 Discord Webhook 相关的设置
[discord.webhook]
# 是否使用 Webhook 将玩家的聊天消息发送到 Discord
# 默认值:false
enabled = false
# 要使用的 Webhook URL
# 默认值:
url = ""
# 与 Minecraft 本身相关的设置
[minecraft]
# 是否允许从 Minecraft 提及 Discord 用户
# 默认值:false
enable_mentions = false
# 是否允许从 Minecraft 提及 @everyone 和 @here
# 默认值:false
enable_everyone_and_here = false
# 是否在游戏内显示 Discord 消息附件
# 默认值:true
show_attachments = true
# 是否在游戏内显示其他 Discord 机器人的消息
# 默认值:false
show_bot_messages = false
# 是否在游戏内显示来自 Discord Webhook 的消息
# 默认值:true
show_webhook_messages = true
# 忽略消息的应用程序 / 用户 ID
ignored_ids = ["000000000000000000"]
# 与消息格式化相关的设置
[formatting]
# 与在 Discord 中可见的消息相关的设置
# 可用占位符: <displayname> <username>
[formatting.discord]
# 服务器启动消息
# 可用占位符:无
# 默认值:**Server starting...**
server_starting_message = "**Server starting...**"
# 服务器已启动消息
# 可用占位符:无
# 默认值:**Server started!**
server_started_message = "**Server started!**"
# 服务器停止消息
# 可用占位符:无
# 默认值:**Server stopping...**
server_stopping_message = "**Server stopping...**"
# 服务器已停止消息
# 可用占位符:无
# 默认值:**Server stopped!**
server_stopped_message = "**Server stopped!**"
# 服务器崩溃消息
# 可用占位符:无
# 默认值:**Server crashed :(**
server_crash_message = "**Server crashed :(**"
# 玩家聊天消息
# 额外占位符:<message>
# 默认值:**<<username>>** <message>
chat_message = "**<<username>>** <message>"
# 玩家加入消息
# 额外占位符:无
# 默认值:> **<username> joined the game**
join_message = "> **<username> joined the game**"
# 玩家离开消息
# 额外占位符:无
# 默认值:> **<username> left the game**
leave_message = "> **<username> left the game**"
# 玩家进度消息
# 额外占位符:<advancement_description> <advancement_title>
# 默认值:> **<username>** has just earned the achievement **[<advancement_title>]**
#> \> _<advancement_description>_
advancement_fallback_message = "> **<username>** has just earned the achievement **[<advancement_title>]**\n> \\> _<advancement_description>_"
# 默认值:> **<username>** has completed the challenge **[<advancement_title>]**
#> \> _<advancement_description>_
advancement_challenge_message = "> **<username>** has completed the challenge **[<advancement_title>]**\n> \\> _<advancement_description>_"
# 默认值:> **<username>** has reached the goal **[<advancement_title>]**
#> \> _<advancement_description>_
advancement_goal_message = "> **<username>** has reached the goal **[<advancement_title>]**\n> \\> _<advancement_description>_"
# 默认值:> **<username>** has made the advancement **[<advancement_title>]**
#> \> _<advancement_description>_
advancement_task_message = "> **<username>** has made the advancement **[<advancement_title>]**\n> \\> _<advancement_description>_"
# 玩家死亡消息
# 额外占位符:<death_message>
# 默认值:**<username> died:** _<death_message>_
death_message = "**<username> died:** _<death_message>_"
# 与从 Webhook 发送的消息相关的设置(如果启用)
[formatting.discord.webhook]
# 用于 Webhook 头像的 URL
# 额外占位符:<skin_id> <skin_model> <uuid>
# 默认值:https://visage.surgeplay.com/bust/128/<skin_id>?<skin_model>
avatar_url = "https://visage.surgeplay.com/bust/128/<skin_id>?<skin_model>"
# Webhook 头像的默认皮肤 ID,如果无法加载玩家皮肤
# 默认值:31f477eb1a7beee631c2ca64d06f8f68fa93a3386d04452ab27f43acdf1b60cb
default_skin_id = "31f477eb1a7beee631c2ca64d06f8f68fa93a3386d04452ab27f43acdf1b60cb"
# Webhook 头像的默认皮肤模型,如果无法加载玩家皮肤
# 默认值:wide
default_skin_model = "wide"
# Webhook 的用户名
# 额外占位符:无
# 默认值:<username>
username = "<username>"
# 玩家聊天消息
# 额外占位符:<message>
# 默认值:<message>
chat_message = "<message>"
# 关于在 Minecraft 中可见消息的设置
# 可用的占位符: <message> <message_url> <nickname> <role_color> <username>
[formatting.minecraft]
# Discord 消息
# 额外的占位符: <attachment_format> <discord_format> <reply_format> <username_format>
# 默认值: [Discord] <reply_format><click type:open_url value:'<message_url>'><<username_format>></click> <message><attachment_format>
discord_message = "[Discord] <reply_format><click type:open_url value:'<message_url>'><<username_format>></click> <message><attachment_format>"
# 用户名格式
# 额外的占位符:无
# 默认值: <hover type:show_text value:'@<username>'><color value:'<role_color>'><nickname></color></hover>
username_format = "<hover type:show_text value:'@<username>'><color value:'<role_color>'><nickname></color></hover>"
# 提及格式
# 额外的占位符:无
# 默认值: <underline><hover type:show_text value:'@<username>'>@<nickname></hover></underline>
mention_format = "<underline><hover type:show_text value:'@<username>'>@<nickname></hover></underline>"
# 回复格式
# 额外的占位符: <reply_message> <reply_nickname> <reply_role_color> <reply_url> <reply_username>
# 默认值: <click type:open_url value:'<reply_url>'><hover type:show_text value:'@<reply_username>: <reply_message>'>[<aqua>←</aqua><color value:'<reply_role_color>'><reply_nickname></color>]</hover></click>
reply_format = "<click type:open_url value:'<reply_url>'><hover type:show_text value:'@<reply_username>: <reply_message>'>[<aqua>←</aqua><color value:'<reply_role_color>'><reply_nickname></color>]</hover></click> "
# 附件格式
# 额外的占位符: <attachment_url>
# 默认值: <click type:open_url value:'<attachment_url>'>[<aqua>Attachment</aqua>]</click>
attachment_format = "<click type:open_url value:'<attachment_url>'>[<aqua>Attachment</aqua>]</click>"
(请注意,这是 Nilcord 4.2+26.2+fabric 的配置文件。其他版本的外观可能有所不同。)
只有 discord 类别下的 token 和 channel_id 字段是必须填写的;对于其他所有设置,模组会使用合理的默认值。当然,你也可以根据自己的喜好进行修改!
说明
要设置 Discord 应用程序(以获取机器人令牌),请遵循 discord.js 的指南:设置机器人应用程序 | discord.js 指南
要查找 Discord 频道的“频道 ID”,请遵循 Discord 的指南:在哪里可以找到我的用户/服务器/消息 ID? - Discord
在 1.21.1 及更低版本中,Fabric 版本还可以使用 简化文本格式,以及由 Text Placeholder API 和支持该 API 的各种模组提供的占位符。
在 1.21.2 及更高版本中,Fabric 版本还允许使用 QuickText。
在 1.20.4 以及 26.1 及更高版本中,NeoForge 版本也允许使用简化文本格式和 QuickText。
Forge 1.7.10 版本额外支持 ChromatiCraft 的进度消息,以及 ServerUtilities 的 AFK 消息。
评论?问题?建议?要求?请在 问题追踪器 上提交 issue!
What started as a niche project for a niche modloader for a niche Minecraft version has now been extended to all Minecraft versions (that I personally care about)!
Nilcord | Yet another Discord bridge for Minecraft
Nilcord connects the chat of your Minecraft server to a specified Discord text channel, using a Discord bot and (optionally) webhook.
Installation
To get the mod set up, simply place the mod file in the mods directory (or nilmods with NilLoader), start your Minecraft server, and wait for it to generate the config file (and crash because it's not yet populated).
The config file, named nilcord.toml, is found in the config folder, and is pretty self-explanatory.
(default configuration)
# Settings pertaining to Discord itself
[discord]
# The Discord bot token to use
# default:
token = ""
# The default Discord channel ID for the bot to send messages to / receive messages from. Used ALONGSIDE send_to and receive_from. Can be blank!
# default:
channel_id = ""
# Other Discord channel ID(s) for the bot to send messages to
send_to = []
# Other Discord channel ID(s) for the bot to receive messages from
receive_from = []
# Settings pertaining to the Discord webhook
[discord.webhook]
# Whether to use a webhook for sending players' chat messages to Discord
# default: false
enabled = false
# The webhook URL to use
# default:
url = ""
# Settings pertaining to Minecraft itself
[minecraft]
# Whether to allow mentioning Discord users from Minecraft
# default: false
enable_mentions = false
# Whether to allow mentioning @everyone and @here from Minecraft
# default: false
enable_everyone_and_here = false
# Whether to show Discord message attachments in-game
# default: true
show_attachments = true
# Whether to show messages from other Discord bots in-game
# default: false
show_bot_messages = false
# Whether to show messages from Discord webhooks in-game
# default: true
show_webhook_messages = true
# Application / User IDs to ignore messages from
ignored_ids = ["000000000000000000"]
# Settings pertaining to message formatting
[formatting]
# Settings pertaining to messages visible in Discord
# Available placeholders: <displayname> <username>
[formatting.discord]
# Server starting message
# Available placeholders: N/A
# default: **Server starting...**
server_starting_message = "**Server starting...**"
# Server started message
# Available placeholders: N/A
# default: **Server started!**
server_started_message = "**Server started!**"
# Server stopping message
# Available placeholders: N/A
# default: **Server stopping...**
server_stopping_message = "**Server stopping...**"
# Server stopped message
# Available placeholders: N/A
# default: **Server stopped!**
server_stopped_message = "**Server stopped!**"
# Server crash message
# Available placeholders: N/A
# default: **Server crashed :(**
server_crash_message = "**Server crashed :(**"
# Player chat messages
# Additional placeholders: <message>
# default: **<<username>>** <message>
chat_message = "**<<username>>** <message>"
# Player join messages
# Additional placeholders: N/A
# default: > **<username> joined the game**
join_message = "> **<username> joined the game**"
# Player leave messages
# Additional placeholders: N/A
# default: > **<username> left the game**
leave_message = "> **<username> left the game**"
# Player advancement messages
# Additional placeholders: <advancement_description> <advancement_title>
# default: > **<username>** has just earned the achievement **[<advancement_title>]**
#> \> _<advancement_description>_
advancement_fallback_message = "> **<username>** has just earned the achievement **[<advancement_title>]**\n> \\> _<advancement_description>_"
# default: > **<username>** has completed the challenge **[<advancement_title>]**
#> \> _<advancement_description>_
advancement_challenge_message = "> **<username>** has completed the challenge **[<advancement_title>]**\n> \\> _<advancement_description>_"
# default: > **<username>** has reached the goal **[<advancement_title>]**
#> \> _<advancement_description>_
advancement_goal_message = "> **<username>** has reached the goal **[<advancement_title>]**\n> \\> _<advancement_description>_"
# default: > **<username>** has made the advancement **[<advancement_title>]**
#> \> _<advancement_description>_
advancement_task_message = "> **<username>** has made the advancement **[<advancement_title>]**\n> \\> _<advancement_description>_"
# Player death messages
# Additional placeholders: <death_message>
# default: **<username> died:** _<death_message>_
death_message = "**<username> died:** _<death_message>_"
# Settings pertaining to messages sent from the webhook, if enabled
[formatting.discord.webhook]
# The URL to use for the webhook's avatar
# Additional placeholders: <skin_id> <skin_model> <uuid>
# default: https://visage.surgeplay.com/bust/128/<skin_id>?<skin_model>
avatar_url = "https://visage.surgeplay.com/bust/128/<skin_id>?<skin_model>"
# Default skin ID for the webhook's avatar, if the player's cannot be loaded
# default: 31f477eb1a7beee631c2ca64d06f8f68fa93a3386d04452ab27f43acdf1b60cb
default_skin_id = "31f477eb1a7beee631c2ca64d06f8f68fa93a3386d04452ab27f43acdf1b60cb"
# Default skin model for the webhook's avatar, if the player's cannot be loaded
# default: wide
default_skin_model = "wide"
# The webhook's username
# Additional placeholders: N/A
# default: <username>
username = "<username>"
# Player chat messages
# Additional placeholders: <message>
# default: <message>
chat_message = "<message>"
# Settings pertaining to messages visible in Minecraft
# Available placeholders: <message> <message_url> <nickname> <role_color> <username>
[formatting.minecraft]
# Discord messages
# Additional placeholders: <attachment_format> <discord_format> <reply_format> <username_format>
# default: [Discord] <reply_format><click type:open_url value:'<message_url>'><<username_format>></click> <message><attachment_format>
discord_message = "[Discord] <reply_format><click type:open_url value:'<message_url>'><<username_format>></click> <message><attachment_format>"
# Username format
# Additional placeholders: N/A
# default: <hover type:show_text value:'@<username>'><color value:'<role_color>'><nickname></color></hover>
username_format = "<hover type:show_text value:'@<username>'><color value:'<role_color>'><nickname></color></hover>"
# Mention format
# Additional placeholders: N/A
# default: <underline><hover type:show_text value:'@<username>'>@<nickname></hover></underline>
mention_format = "<underline><hover type:show_text value:'@<username>'>@<nickname></hover></underline>"
# Reply format
# Additional placeholders: <reply_message> <reply_nickname> <reply_role_color> <reply_url> <reply_username>
# default: <click type:open_url value:'<reply_url>'><hover type:show_text value:'@<reply_username>: <reply_message>'>[<aqua>←</aqua><color value:'<reply_role_color>'><reply_nickname></color>]</hover></click>
reply_format = "<click type:open_url value:'<reply_url>'><hover type:show_text value:'@<reply_username>: <reply_message>'>[<aqua>←</aqua><color value:'<reply_role_color>'><reply_nickname></color>]</hover></click> "
# Attachment format
# Additional placeholders: <attachment_url>
# default: <click type:open_url value:'<attachment_url>'>[<aqua>Attachment</aqua>]</click>
attachment_format = "<click type:open_url value:'<attachment_url>'>[<aqua>Attachment</aqua>]</click>"
(Note that this is the config file for Nilcord 4.2+26.2+fabric. It may look different on other versions.)
Only the token and channel_id fields (under the discord category) are strictly required to be filled out; the mod falls back to sensible defaults for everything else. But feel free to change it to your liking!
Notes
For setting up a Discord application (to get a bot token), follow discord.js' guide: Setting up a bot application | discord.js Guide
For finding a Discord channel's "Channel ID", follow Discord's guide: Where can I find my User/Server/Message ID? - Discord
With 1.21.1 and below, the Fabric versions can also make use of the Simplified Text Format, as well as placeholders supplied by Text Placeholder API and the various mods that support it.
With 1.21.2 and above, the Fabric versions allow using QuickText as well.
With 1.20.4, as well as 26.1 and above, the NeoForge versions also allow using Simplified Text Format and QuickText.
The Forge 1.7.10 version has additional support for ChromatiCraft's progression messages, as well as ServerUtilities' AFK messages.
Comments? Questions? Suggestions? Demands? Open an issue on the issue tracker!
评论 0
登录后参与评分
还没有评论,来抢沙发吧