Better fix for Permission errors

pull/47/head
bobloy 6 years ago
parent 8d73e48ab5
commit f3e8929d2a

@ -415,7 +415,7 @@ class PlantTycoon(Cog):
try:
await self._apply_degradation(gardener)
except discord.Forbidden:
await ctx.send("You blocked me, didn't you?")
await ctx.send("ERROR\nYou blocked me, didn't you?")
em = discord.Embed(color=discord.Color.green()) # , description='\a\n')
avatar = author.avatar_url if author.avatar else author.default_avatar_url
@ -524,7 +524,12 @@ class PlantTycoon(Cog):
"""Check the state of your plant."""
author = ctx.author
gardener = await self._gardener(author)
try:
await self._apply_degradation(gardener)
except discord.Forbidden:
# Couldn't DM the degradation
await ctx.send("ERROR\nYou blocked me, didn't you?")
if not gardener.current:
message = "You're currently not growing a plant."
em_color = discord.Color.red()
@ -644,7 +649,11 @@ class PlantTycoon(Cog):
author = ctx.author
channel = ctx.channel
gardener = await self._gardener(author)
try:
await self._apply_degradation(gardener)
except discord.Forbidden:
# Couldn't DM the degradation
await ctx.send("ERROR\nYou blocked me, didn't you?")
product = "water"
product_category = "water"
if not gardener.current:
@ -657,7 +666,11 @@ class PlantTycoon(Cog):
async def _fertilize(self, ctx, fertilizer):
"""Fertilize the soil."""
gardener = await self._gardener(ctx.author)
try:
await self._apply_degradation(gardener)
except discord.Forbidden:
# Couldn't DM the degradation
await ctx.send("ERROR\nYou blocked me, didn't you?")
channel = ctx.channel
product = fertilizer
product_category = "fertilizer"
@ -671,7 +684,11 @@ class PlantTycoon(Cog):
async def _prune(self, ctx):
"""Prune your plant."""
gardener = await self._gardener(ctx.author)
try:
await self._apply_degradation(gardener)
except discord.Forbidden:
# Couldn't DM the degradation
await ctx.send("ERROR\nYou blocked me, didn't you?")
channel = ctx.channel
product = "pruner"
product_category = "tool"
@ -732,7 +749,12 @@ class PlantTycoon(Cog):
for user_id in users:
user = self.bot.get_user(user_id)
gardener = await self._gardener(user)
try:
await self._apply_degradation(gardener)
except discord.Forbidden:
# Couldn't DM the degradation
pass
if gardener.current:
health = gardener.current["health"]
if health < self.defaults["notification"]["max_health"]:

Loading…
Cancel
Save