|
1 | 1 | import requests |
| 2 | +import yaml |
2 | 3 | from django.conf import settings |
3 | 4 | from django.core.management.base import BaseCommand, CommandError |
| 5 | +from pathlib import Path |
4 | 6 | from pprint import pformat |
5 | 7 |
|
6 | | -from apps.players.models.game_type import GameType |
7 | | - |
8 | 8 |
|
9 | 9 | class Command(BaseCommand): |
10 | 10 | """Get Discord bot commands.""" |
@@ -45,117 +45,12 @@ def handle(self, *args, **options): |
45 | 45 | ) |
46 | 46 | ) |
47 | 47 |
|
48 | | - all_commands = [ |
49 | | - { |
50 | | - "type": 1, |
51 | | - "name": "challenges", |
52 | | - "description": "Link to the list of MUD challenges.", |
53 | | - }, |
54 | | - { |
55 | | - "type": 1, |
56 | | - "name": "cycle", |
57 | | - "description": "Show when challenges will cycle next.", |
58 | | - }, |
59 | | - { |
60 | | - "type": 1, |
61 | | - "name": "deadhead", |
62 | | - "description": "Show the player with the most deaths.", |
63 | | - }, |
64 | | - { |
65 | | - "type": 1, |
66 | | - "name": "events", |
67 | | - "description": "Show any active events.", |
68 | | - }, |
69 | | - { |
70 | | - "type": 1, |
71 | | - "name": "faq", |
72 | | - "description": "Link to frequently asked questions (FAQs).", |
73 | | - }, |
74 | | - { |
75 | | - "type": 1, |
76 | | - "name": "feedback", |
77 | | - "description": |
78 | | - "Link to feedback page to send bug report," |
79 | | - " idea, or suggestion.", |
80 | | - }, |
81 | | - { |
82 | | - "name": "leader", |
83 | | - "type": 1, |
84 | | - "description": "List the leading player, by game type.", |
85 | | - "options": [{ |
86 | | - "name": "type", |
87 | | - "description": "Game type to find the leader of.", |
88 | | - "type": 3, |
89 | | - "required": False, |
90 | | - "choices": [ |
91 | | - { |
92 | | - "name": "Classic", |
93 | | - "value": str(GameType.CLASSIC.value) |
94 | | - }, |
95 | | - { |
96 | | - "name": "Hardcore", |
97 | | - "value": str(GameType.HARDCORE.value) |
98 | | - }, |
99 | | - { |
100 | | - "name": "Survival", |
101 | | - "value": str(GameType.SURVIVAL.value) |
102 | | - } |
103 | | - ] |
104 | | - }] |
105 | | - }, |
106 | | - { |
107 | | - "type": 1, |
108 | | - "name": "leaders", |
109 | | - "description": "Link to the list of leading MUD players.", |
110 | | - }, |
111 | | - { |
112 | | - "type": 1, |
113 | | - "name": "mudhelp", |
114 | | - "description": "Search MUD help for a topic.", |
115 | | - "options": [ |
116 | | - { |
117 | | - "name": "topic", |
118 | | - "description": "Name of the help topic to search for.", |
119 | | - "type": 3, |
120 | | - "required": True, |
121 | | - } |
122 | | - ], |
123 | | - }, |
124 | | - { |
125 | | - "type": 1, |
126 | | - "name": "mudtime", |
127 | | - "description": "Show current server time.", |
128 | | - }, |
129 | | - { |
130 | | - "type": 1, |
131 | | - "name": "runtime", |
132 | | - "description": "Show current server runtime.", |
133 | | - }, |
134 | | - { |
135 | | - "type": 1, |
136 | | - "name": "season", |
137 | | - "description": "Show the current season.", |
138 | | - }, |
139 | | - { |
140 | | - "type": 1, |
141 | | - "name": "spell", |
142 | | - "description": "Search MUD help for a spell.", |
143 | | - "options": [ |
144 | | - { |
145 | | - "name": "spell", |
146 | | - "description": "Name of the spell to search for.", |
147 | | - "type": 3, |
148 | | - "required": True, |
149 | | - } |
150 | | - ], |
151 | | - }, |
152 | | - { |
153 | | - "type": 1, |
154 | | - "name": "upgrades", |
155 | | - "description": |
156 | | - "Link to available remort upgrades and their renown costs." |
157 | | - }, |
158 | | - ] |
| 48 | + with open( |
| 49 | + file=Path(Path(__file__).parent, "commands.yaml"), |
| 50 | + mode="r", |
| 51 | + encoding="utf-8" |
| 52 | + ) as cmd_yml: |
| 53 | + all_commands = yaml.safe_load(cmd_yml) |
159 | 54 |
|
160 | 55 | reg = requests.put( |
161 | 56 | url=discord_url, |
|
0 commit comments