-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
81 lines (72 loc) · 2.72 KB
/
bot.py
File metadata and controls
81 lines (72 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import discord
import json
import PIL
import textwrap
from PIL import Image, ImageDraw, ImageChops, ImageFont
from discord import client
from discord.ext import commands
import requests
import creds
from os import remove
bot = commands.Bot(command_prefix='*', description='Your Description')
bot.remove_command('help')
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('Future is loading ...')
print('----------------------------------------------------------')
await bot.change_presence(status=discord.Status.online,activity=discord.Game(name='*help || YOPI'))
@bot.command()
async def quotes(ctx):
author = ctx.message.author.id
response = requests.get("https://zenquotes.io/api/random")
json_data = json.loads(response.text)
quote = json_data[0]['q'] + " -" + json_data[0]['a']
await ctx.send(f'<@{author}>\n{quote}')
base = Image.open('backgrounds/temp2.jpg')
basee = base.convert('RGB')
para = textwrap.wrap(quote, width=80)
W, H = (1280,417)
draw = ImageDraw.Draw(basee)
w, h = draw.textsize(quote)
font = ImageFont.truetype("backgrounds/Quote.ttf", 40)
current_h, pad = 210,30
for line in para:
x, y = draw.textsize(line, font=font)
draw.text(((W-x)/2,current_h), line,font = font)
current_h += h + pad
newimage = basee.resize((1280,417))
newimage.save(f'final.jpg')
with open(f'final.jpg','rb') as final:
await ctx.send(file=discord.File(final,filename=f"final.jpg"))
remove(f'final.jpg')
@bot.command()
async def quotes1(ctx):
author = ctx.message.author.id
response = requests.get("https://zenquotes.io/api/random")
json_data = json.loads(response.text)
quote = json_data[0]['q'] + " -" + json_data[0]['a']
await ctx.send(f'<@{author}>\n{quote}')
base = Image.open('backgrounds/template.jpg')
para = textwrap.wrap(quote, width=90)
W, H = (1280,417)
draw = ImageDraw.Draw(base)
w, h = draw.textsize(quote)
font = ImageFont.truetype("backgrounds/Quote.ttf", 36)
current_h, pad = 335,25
for line in para:
x, y = draw.textsize(line, font=font)
draw.text(((W-x)/2,current_h), line,font = font)
current_h += h + pad
newimage = base.resize((1280,417))
newimage.save(f'final.jpg')
with open(f'final.jpg','rb') as final:
await ctx.send(file=discord.File(final,filename=f"final.jpg"))
remove(f'final.jpg')
@bot.group()
async def owner(ctx):
yopi = discord.Embed(title = 'Owned by YOPI', description = f'Check out my [twitter](https://twitter.com/YONINUX) and [github](https://github.com/YOPll) ',color = discord.Colour.teal())
await ctx.send(embed = yopi)
bot.run(creds.token)