Skip to content

Commit

Permalink
Fix edit_origin, /edit profile check
Browse files Browse the repository at this point in the history
  • Loading branch information
0x16c3 committed Sep 8, 2021
1 parent 45ae4b4 commit 2fb25f4
Showing 1 changed file with 33 additions and 24 deletions.
57 changes: 33 additions & 24 deletions cogs/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def __init__(self, username: str, feed: int) -> None:
self.arguments = None
self.type = None

self.errors = 0

if self.feed == self.TYPE["ANIME"]:
self.type = CListActivity
self.function = anilist.get_activity
Expand Down Expand Up @@ -107,8 +109,11 @@ async def retrieve(
obj = self.type.create(item, self.username)
res.append(obj)

self.errors = 0

except Exception as e:
logger.print("Error on {}: {}".format(self.username, e))
self.errors += 1
return [], []

return res[:15], res
Expand Down Expand Up @@ -567,7 +572,7 @@ def check_author(cctx: ComponentContext):
),
color=color_errr,
)
await button_ctx.edit_origin("An error occured!", embed=embed)
await button_ctx.edit_origin(content="An error occured!", embed=embed)
return

user = None
Expand Down Expand Up @@ -828,24 +833,38 @@ def check_author(cctx: ComponentContext):
activities = []
activities_failed = []

try:
profile = await anilist.get_user(name=username)
profile = CUser.create(profile)
except:
embed = discord.Embed(
title="Could not start tracking!",
description=(
"There has been an error fetching this profile.\n"
"Please double-check the username or try again later."
),
color=color_errr,
for i in [
x
for x in self.feeds
if x.username == username and x.type not in selected
]:
self.feeds.remove(i)
await database.feed_remove([i.JSON()])
activities.append(
f"`Stopped {list(Feed.TYPE.keys())[list(Feed.TYPE.values()).index(int(i.type))].lower()}`"
)
await button_ctx.edit_origin("An error occured!", embed=embed)
return

user = None
profile = None

for i in selected:

if not profile:
try:
profile = await anilist.get_user(name=username)
profile = CUser.create(profile)
except:
embed = discord.Embed(
title="Could not start tracking!",
description=(
"There has been an error fetching this profile.\n"
"Please double-check the username or try again later."
),
color=color_errr,
)
await button_ctx.edit_origin(content="An error occured!", embed=embed)
return

user: Activity = await Activity.create(
username, ctx.channel, i, profile
)
Expand All @@ -866,16 +885,6 @@ def check_author(cctx: ComponentContext):
activities.append(
f"`Started {list(Feed.TYPE.keys())[list(Feed.TYPE.values()).index(i)].lower()}`"
)
for i in [
x
for x in self.feeds
if x.username == username and x.type not in selected
]:
self.feeds.remove(i)
await database.feed_remove([i.JSON()])
activities.append(
f"`Stopped {list(Feed.TYPE.keys())[list(Feed.TYPE.values()).index(int(i.type))].lower()}`"
)

embed = discord.Embed(
title="Done!",
Expand Down

0 comments on commit 2fb25f4

Please sign in to comment.