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