Fixed permissions for embed usage

This commit is contained in:
Robert 2020-08-11 18:07:31 +02:00
parent 1d1b66f87a
commit 67b50c3b8c
3 changed files with 21 additions and 4 deletions

View file

@ -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

View file

@ -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

View file

@ -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)