Guest User

Untitled

a guest
Mar 16th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. import discord
  2. import asyncio
  3. from discord.ext import commands
  4.  
  5. class Quote:
  6. def __init__(self, id, msg):
  7. self.id = id
  8. self.msg = msg
  9.  
  10. bot = commands.Bot(command_prefix = '-')
  11.  
  12. q = open("maxID.txt","r")
  13. maxID = int(q.read())
  14. q.close()
  15.  
  16. print(maxID)
  17.  
  18. temp = [0 for x in range(len(quotes))]
  19. for i in range(0, len(quotes)):
  20. temp[i] = Quote(ids[i],quotes[i])
  21. quotes = temp
  22.  
  23. @bot.event
  24. async def on_ready():
  25. print('Logged in as')
  26. print(bot.user.name)
  27. print(bot.user.id)
  28. print('------')
  29.  
  30. @bot.event
  31. async def on_message(message):
  32. await bot.process_commands(message)
  33.  
  34. @bot.command(pass_context=True)
  35. async def ping(ctx):
  36. await ctx.channel.send('Pong!')
  37. print(maxID)
  38.  
  39. @bot.command(pass_context=True)
  40. async def add(ctx, *, arg):
  41. quotes.append(Quote(maxID, arg))
  42. maxID = maxID + 1
  43. await ctx.channel.send('Added Quote #' + str(len(quotes)))
  44.  
  45. Ignoring exception in command add:
  46. Traceback (most recent call last):
  47. File "C:UsersAcemcbeanAppDataRoamingPythonPython36site-packagesdiscordextcommandscore.py", line 62, in wrapped
  48. ret = yield from coro(*args, **kwargs)
  49. File "C:IzunaBotrun.py", line 51, in add
  50. quotes.append(Quote(maxID, arg))
  51. UnboundLocalError: local variable 'maxID' referenced before assignment
Add Comment
Please, Sign In to add comment