From 67b50c3b8cfad26c6ba85798920f7cf3b8f92e6b Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 11 Aug 2020 18:07:31 +0200 Subject: [PATCH] Fixed permissions for embed usage --- cogs/kanji.py | 8 ++++++-- cogs/search.py | 8 ++++++-- utils/jisho.py | 9 +++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/cogs/kanji.py b/cogs/kanji.py index 32f62aa..9f67ba1 100644 --- a/cogs/kanji.py +++ b/cogs/kanji.py @@ -3,10 +3,11 @@ from discord.ext import commands from utils import jisho class JishoKanjiObject(): - def __init__(self, query): + def __init__(self, query, owner): self.response = jisho.JishoKanji(query) self.total_pages = self.response.entries self.page = 0 + self.owner = owner def prev(self): self.page -= 1 @@ -54,6 +55,9 @@ class Kanji(commands.Cog): if user == self.bot.user: return + if user.id != self.activeObject.owner: + return + if reaction.me: if reaction.emoji == "⬅️": self.activeObject.prev() @@ -72,7 +76,7 @@ class Kanji(commands.Cog): if kanji is None: return - self.activeObject = JishoKanjiObject(kanji) + self.activeObject = JishoKanjiObject(kanji, ctx.author.id) embed = await self.createEmbed() message = await ctx.send(embed=embed) self.latestMessage = message.id diff --git a/cogs/search.py b/cogs/search.py index 41a1f5d..b3835ee 100644 --- a/cogs/search.py +++ b/cogs/search.py @@ -3,10 +3,11 @@ from discord.ext import commands from utils import jisho class JishoObject(): - def __init__(self, query): + def __init__(self, query, owner): self.response = jisho.JishoResponse(query) self.total_pages = self.response.entries self.page = 0 + self.owner = owner def prev(self): self.page -= 1 @@ -64,6 +65,9 @@ class Search(commands.Cog): if user == self.bot.user: return + if user.id != self.activeObject.owner: + return + if reaction.me: if reaction.emoji == "⬅️": self.activeObject.prev() @@ -83,7 +87,7 @@ class Search(commands.Cog): if query == None: return - self.activeObject = JishoObject(query) + self.activeObject = JishoObject(query, ctx.author.id) embed = await self.createEmbed() message = await ctx.send(embed=embed) self.latestMessage = message.id diff --git a/utils/jisho.py b/utils/jisho.py index c72acc4..800cff5 100644 --- a/utils/jisho.py +++ b/utils/jisho.py @@ -90,6 +90,10 @@ class JishoKanjiNode(): self.meaning = "" self.kun = [] self.on = [] + self.radical = "" + self.grade = "" + self.jlpt = "" + class JishoKanji(): def __init__(self, query): @@ -138,3 +142,8 @@ class JishoKanji(): readings = on_block.findChildren("a", recursive=True) for reading in readings: self.nodes[-1].on.append(reading.string) + + # Radical + radical_block = readings_block.findChild("div", {"class": "radicals"}, recursive=True) + print(radical_block) +