Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord, random, json,requests
- from discord.ext import commands
- # create bot instance
- bot = commands.Bot(command_prefix='!', description='jeth discord Bot By Juji')
- # load file into json and data define
- o = json.load(open('jessf.json','r',encoding='utf-8-sig'))
- data = [(m['datestamp'],m['content']) for m in o]
- # load commands txt
- # login
- @bot.event
- async def on_ready():
- channel = discord.Object(id=432066274336440330)
- print("Logged in as: name={}, id={}".format( bot.user.name, bot.user.id ))
- client = discord.Client()
- @bot.command(pass_context=True)
- async def jeth(ctx):
- # Chooses a random quote
- content = random.choice(data)
- msg = "{}".format(content)
- await bot.say(msg)
- async def timedjeth():
- await bot.wait_until_ready()
- while not bot.is_closed():
- await asyncio.sleep(60)
- bot.timedjeth = bot.loop.create_task(timedjeth())
- bot.timedjeth
- channel = bot.get_channel(457515801369640971)
- content = random.choice(data)
- msg = "{}".format(content)
- await bot.send(msg)
- @bot.command(pass_context=True)
- async def jethx(ctx, n: int = 1):
- """Chooses a random quote."""
- msg = ["{}".format(content) for content in [random.choice(data) for _ in range(0,n)]]
- await bot.say('\n'.join(msg))
- @bot.command(pass_context=True)
- async def search(ctx, phrase : str):
- # Match data with a search-phrase
- results = []
- for datestamp, content in data:
- if phrase in content: results.append( "{} \n{}\n".format(datestamp, content))
- if len(results) > 8: break
- if len(results) > 0:
- msg = "\n\n {}".format( "\n".join(results) )
- else:
- msg = "` {} jeth Never Said That Before I Gayce`".format(phrase)
- await bot.say(msg)
- @bot.command(pass_context=True)
- async def jethashackscommands(ctx):
- # Returns Commands
- with open('commands.txt','r',encoding='utf-8-sig') as content_file:
- read = content_file.read()
- msg = "{}".format(read)
- await bot.say(msg)
Advertisement
Add Comment
Please, Sign In to add comment