Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- import asyncio
- from discord.ext import commands
- class Quote:
- def __init__(self, id, msg):
- self.id = id
- self.msg = msg
- bot = commands.Bot(command_prefix = '-')
- q = open("maxID.txt","r")
- maxID = int(q.read())
- q.close()
- print(maxID)
- temp = [0 for x in range(len(quotes))]
- for i in range(0, len(quotes)):
- temp[i] = Quote(ids[i],quotes[i])
- quotes = temp
- @bot.event
- async def on_ready():
- print('Logged in as')
- print(bot.user.name)
- print(bot.user.id)
- print('------')
- @bot.event
- async def on_message(message):
- await bot.process_commands(message)
- @bot.command(pass_context=True)
- async def ping(ctx):
- await ctx.channel.send('Pong!')
- print(maxID)
- @bot.command(pass_context=True)
- async def add(ctx, *, arg):
- quotes.append(Quote(maxID, arg))
- maxID = maxID + 1
- await ctx.channel.send('Added Quote #' + str(len(quotes)))
- Ignoring exception in command add:
- Traceback (most recent call last):
- File "C:UsersAcemcbeanAppDataRoamingPythonPython36site-packagesdiscordextcommandscore.py", line 62, in wrapped
- ret = yield from coro(*args, **kwargs)
- File "C:IzunaBotrun.py", line 51, in add
- quotes.append(Quote(maxID, arg))
- UnboundLocalError: local variable 'maxID' referenced before assignment
Add Comment
Please, Sign In to add comment