Date: 2020/07/28 02:56:35 UTC-07:00
Type: Denizen Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Lunaboot:
type: world
debug: true
events:
on server start:
- wait 5s
- run bot_init instantly context:-a
- wait 1s
- discord id:lunaboot message channel:<server.flag[discord.channel.bridge]> "*- Server has started -*"
on player chats:
- choose <player.flag[channel]>:
- case default:
- discord id:lunaboot channel:<server.flag[discord.channel.bridge]> message "**<player.groups.get[1]||[Player]>** **<player.display_name.strip_color>**: <context.message.strip_color>"
- case staff:
- discord id:lunaboot channel:<server.flag[discord.channel.staff]> message "**<player.groups.get[1]||[Player]>** **<player.display_name.strip_color>**: <context.message.strip_color>"
on discord message received for:discord_chat_relay:
# Check if the author is the bot, or if the message received is a webhook.
- if <context.author||Webhook> == <context.bot.self_user>:
- stop
# Check if the channel is being sent in the mainchat, if the message is blank
- choose <context.channel.id>:
- case <server.flag[discord.channel.bridge]> && <context.message> != "":
- announce format:DiscordRelayChatFormat " | <context.author.nickname[<context.group>]||<context.author.name>><&r> <&8>»<&f> <context.message.parse_color>"
- case <server.flag[discord.channel.staff]> && <context.message> != "":
- narrate "<&e><&a>Staff Chat Discord<&e> » <context.author.nickname[<context.group>]||<context.author.name>><&r> <&8>»<&f> <context.message.parse_color>" targets:<server.online_players_flagged[staffchat].filter[flag[staffchat].is[==].to[allow]]>
on player first join:
- discord id:discord_chat_relay message channel:<server.flag[discord.channel.mainchat]> "<&co>confetti_ball<&co> **<player.name> has logged in for the first time. Welcome them!** <&co>confetti_ball<&co>"
on player dies:
- discord id:discord_chat_relay message channel:<server.flag[discord.channel.mainchat]> "<&co>skull<&co> **<context.message>**"
on shutdown:
- discord id:discord_chat_relay message channel:<server.flag[discord.channel.mainchat]> "<&co>octagonal_sign<&co> **Server is restarting - Please wait**"
- flag server discord.botstatus:!
bot_init:
type: task
debug: true
definitions: Arg2
script:
- if !<server.list_files[data].contains[lbot_config.yml]>:
- announce to_console "<&2>Configuration file missing.<&nl>Stopping bot..."
- stop
- yaml load:data/lbot_config.yml id:lbot_config_temp
- flag server discord.key:loaded
# Full Reload
- if <[Arg2]> == "-a":
- flag server discord:!
- discord id:lunaboot disconnect
# Connect the Bot
- discord id:lunaboot connect code:<yaml[lbot_config_temp].read[bots.discord.botToken]>
- flag server botstatus:running
- flag server discord.link:<yaml[lbot_config_temp].read[bots.discord.discordlink]>
# Flags all the channels
- flag server discord.channels:!
- define Channels <yaml[lbot_config_temp].list_keys[bots.discord.channel]>
- flag server discord.channels:|:<[Channels]>
- foreach <[Channels].exclude[bridge]> as:Channel:
- flag server discord.channel.<[Channel]>:<yaml[lbot_config_temp].read[bots.discord.channel.<[Channel]>]>
- flag server discord.channel.bridge:<yaml[lbot_config_temp].read[bots.discord.channel.bridge]>
- flag server discord.channel.staff:<yaml[lbot_config_temp].read[bots.discord.channel.staff]>
- yaml unload id:lbot_config_temp
- flag server discord.key:!