#!/usr/bin/env python3 import discord from discord.ext import commands import logging import random import urllib from env import TOKEN # setup discord.py client = discord.Client() e = discord.Embed() # setup logging logger = logging.getLogger('jeeves') logger.setLevel(logging.DEBUG) handler = logging.FileHandler(filename='jeeves.log', encoding='utf-8', mode='w') handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')) logger.addHandler(handler) def resolve(url): return urllib.request.urlopen(url).url @client.event async def on_message(message): # we do not want the bot to reply to itself if message.author == client.user: return if message.content.startswith('https://tenor.com/'): crew = discord.Role.members("crew") print(crew) print(message.author) #embed_url = message.content #follow_url = embed_url + '.gif' #full_url = resolve(follow_url) #gif_url = full_url.split('?')[0] #print(gif_url) #embed = e.set_image(url=gif_url) #await message.channel.send(embed=embed) if message.content.startswith('https://giphy.com/'): embed_url = message.content image_code = embed_url.split('-')[-1] gif_url = 'https://media.giphy.com/media/' + image_code + '/giphy.gif' embed = e.set_image(url=gif_url) await message.channel.send(embed=embed) @client.event async def on_ready(): print('### Active with id %s as %s ###' % (client.user.id,client.user.name) ) # activity = discord.Activity(name='the threads of fate (pm !help for help)', type=discord.ActivityType.watching) # await client.change_presence(activity=activity) if __name__ == '__main__': client.run(TOKEN)