Handle empty glossary correctly
This commit is contained in:
parent
deeeaffd77
commit
313ec0dfa5
|
@ -451,6 +451,10 @@ class GlossBot(Bot):
|
|||
|
||||
def rand(self, **kwargs):
|
||||
"""List a random entry."""
|
||||
if not self.db.keys():
|
||||
self.reply("Glossary is empty", **kwargs)
|
||||
return
|
||||
|
||||
entry = choice(self.db.keys())
|
||||
self.reply(f"{entry} - {self.db[entry]}", **kwargs)
|
||||
|
||||
|
@ -458,6 +462,7 @@ class GlossBot(Bot):
|
|||
"""List all entries."""
|
||||
if not self.db.keys():
|
||||
self.reply("Glossary is empty", **kwargs)
|
||||
return
|
||||
|
||||
for entry in self.db.keys():
|
||||
self.reply(f"{entry} - {self.db[entry]}", **kwargs)
|
||||
|
|
Loading…
Reference in New Issue