async def addStory(self, ctx: commands.Context, *storyTitle: str): # not kwarg so it works with multi storyTitle = " ".join(storyTitle) author = await getAuthorFromContext(ctx) now = time.time() isNewPost = False try: post = await self.getPost(ctx) except laprOSException: print("Creating new post.") archive = getArchiveFromContext(ctx) post = archive.createPost(author.id) last = self.addStoryCooldown diff = now - last print(diff) diff = (60 * 10) - diff if diff > 0: mins = round(diff / 60, 2) fail(A.addStory.errorCooldown(mins)) isNewPost = True try: newStory = Story() newStory.setTitle(storyTitle, ignoreMax=isModerator(ctx.author)) post.addStory(newStory) post.focusByTitle(newStory.title) except MaxLenException: fail(A.addStory.errorLen(len(storyTitle))) return except DuplicateException: fail(A.addStory.errorDup(storyTitle)) return await self.updatePost(ctx) if isinstance(ctx.channel, discord.DMChannel): if not post.messageID in self.dmPosts: await self.getMyPost(ctx) if isNewPost: self.addStoryCooldown = now
async def changeTitle(story: Story): try: story.setTitle(newTitle, ignoreMax=isModerator(ctx.author)) except MaxLenException: fail(A.setTitle.errorLen(len(newTitle)))