🔀 Fixed message deletion bug

This commit is contained in:
NikolajDanger
2021-04-06 15:53:02 +02:00
committed by GitHub
2 changed files with 18 additions and 15 deletions

View File

@ -62,10 +62,10 @@ class BedreNetflix():
await message.add_reaction("")
#Adds the requested movie to Bedre Netflix
async def addMovie(self,channel,imdbId):
async def addMovie(self, message, imdbId):
if imdbId == None:
self.bot.log("Did not find what the user was searching for")
await channel.send("Try searching for the IMDB id")
await message.edit(embed = None, content = "Try searching for the IMDB id")
else:
self.bot.log("Trying to add movie "+str(imdbId))
apiKey = self.bot.credentials.radarrKey
@ -81,12 +81,13 @@ class BedreNetflix():
r = requests.post(url= self.radarrURL+"movie?apikey="+apiKey,json = postData)
if r.status_code == 201:
await channel.send(postData["title"]+" successfully added to Bedre Netflix")
await message.edit(embed = None, content = postData["title"]+" successfully added to Bedre Netflix")
self.bot.log("Added "+postData["title"]+" to Bedre Netflix")
elif r.status_code == 400:
await channel.send("The movie is already requested for or added to Bedre Netflix")
text = f"{postData['title']} is either already on Bedre Netflix, downloading, or not available"
await message.edit(embed = None, content = text)
else:
await channel.send("Something went wrong")
await message.edit(embed = None, content = "Something went wrong")
self.bot.log(str(r.status_code)+" "+r.reason)
#Returns a list of no more than 5 options when user requests a show
@ -140,10 +141,10 @@ class BedreNetflix():
await message.add_reaction("")
#Adds the requested show to Bedre Netflix
async def addShow(self,channel,imdbName):
async def addShow(self, message, imdbName):
if imdbName == None:
self.bot.log("Did not find what the user was searching for")
await channel.send("Try searching for the IMDB id")
await message.edit(embed = None, content = "Try searching for the IMDB id")
else:
self.bot.log("Trying to add show "+str(imdbName))
apiKey = self.bot.credentials.sonarrKey
@ -159,12 +160,13 @@ class BedreNetflix():
r = requests.post(url= self.sonarrURL+"series?apikey="+apiKey,json = postData)
if r.status_code == 201:
await channel.send(postData["title"]+" successfully added to Bedre Netflix")
await message.edit(embed = None, content = postData["title"]+" successfully added to Bedre Netflix")
self.bot.log("Added a "+postData["title"]+" to Bedre Netflix")
elif r.status_code == 400:
await channel.send("The show is already requested for or added to Bedre Netflix")
text = f"{postData['title']} is either already on Bedre Netflix, downloading, or not available"
await message.edit(embed = None, content = text)
else:
await channel.send("Something went wrong")
await message.edit(embed = None, content = "Something went wrong")
self.bot.log(str(r.status_code)+" "+r.reason)
#Generates a list of all torrents and returns formatted list and whether all torrents are downloaded

View File

@ -23,7 +23,7 @@ class EventHandler():
game = discord.Game("Use /help for commands")
await self.bot.change_presence(activity=game, status = discord.Status.online)
async def on_reaction_add(self, reaction, user):
async def on_reaction_add(self, reaction : discord.Reaction, user):
if user.bot == False:
message = reaction.message
channel = message.channel
@ -40,20 +40,21 @@ class EventHandler():
await self.bot.games.connectFour.placePiece(message, f"#{user.id}", column-1)
elif bedreNetflixMessage and addMovie:
moviePick = emojiToCommand(reaction.emoji)
await message.delete()
if moviePick == "none":
imdbID = None
else:
imdbID = imdbIds[moviePick-1]
await self.bot.other.bedreNetflix.addMovie(channel,imdbID)
await message.clear_reactions()
await self.bot.other.bedreNetflix.addMovie(message, imdbID)
elif bedreNetflixMessage and not addMovie:
showPick = emojiToCommand(reaction.emoji)
await message.delete()
if showPick == "none":
imdbName = None
else:
imdbName = imdbIds[showPick-1]
await self.bot.other.bedreNetflix.addShow(channel,imdbName)
await message.clear_reactions()
await self.bot.other.bedreNetflix.addShow(message, imdbName)
elif self.bot.databaseFuncs.hangmanReactionTest(channel, message, f"#{user.id}"):
self.bot.log("They reacted to the hangman message")
if ord(reaction.emoji) in range(127462,127488):