Skip to content

Commit 1c36bc8

Browse files
committed
add discord command to list characters
1 parent c7a020d commit 1c36bc8

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

prompts/discord-en-us.yml

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
prompts:
2+
discord_characters_none: There are no characters available to play.
3+
discord_characters_list: |
4+
**Characters:**
5+
{{ characters | and_list }}
26
discord_help: |
37
**Commands:**
48
- `!help` - Show this help message

taleweave/bot/discord.py

+26-6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
)
3838
from taleweave.render.comfy import render_event
3939
from taleweave.utils.prompt import format_prompt
40+
from taleweave.utils.search import list_characters
4041

4142
logger = getLogger(__name__)
4243
client = None
@@ -103,15 +104,13 @@ async def on_message(self, message):
103104
await message.channel.send(world_message)
104105
return
105106

106-
# TODO: command to list available characters
107-
108-
if content.startswith("!help"):
107+
if content.startswith(config.bot.discord.command_prefix + "help"):
109108
await message.channel.send(
110109
format_prompt("discord_help", bot_name=config.bot.discord.name_command)
111110
)
112111
return
113112

114-
if content.startswith("!join"):
113+
if content.startswith(config.bot.discord.command_prefix + "join"):
115114
character_name = content.replace("!join", "").strip()
116115
if has_player(character_name):
117116
await channel.send(
@@ -149,14 +148,35 @@ def prompt_player(event: PromptEvent):
149148
join_event = PlayerEvent("join", character_name, user_name)
150149
return broadcast(join_event)
151150

152-
if content.startswith("!players"):
151+
if content.startswith(config.bot.discord.command_prefix + "characters"):
152+
world = get_current_world()
153+
if not world:
154+
await channel.send(
155+
format_prompt(
156+
"discord_characters_none",
157+
bot_name=config.bot.discord.name_title,
158+
)
159+
)
160+
return
161+
162+
characters = [character.name for character in list_characters(world)]
163+
await channel.send(
164+
format_prompt(
165+
"discord_characters_list",
166+
bot_name=config.bot.discord.name_title,
167+
characters=characters,
168+
)
169+
)
170+
return
171+
172+
if content.startswith(config.bot.discord.command_prefix + "players"):
153173
players = list_players()
154174
await channel.send(embed=format_players(players))
155175
return
156176

157177
player = get_player(user_name)
158178
if isinstance(player, RemotePlayer):
159-
if content.startswith("!leave"):
179+
if content.startswith(config.bot.discord.command_prefix + "leave"):
160180
remove_player(user_name)
161181

162182
# revert to LLM agent

0 commit comments

Comments
 (0)