Convert files to the new discord.File format
This commit is contained in:
parent
74d22f2d8d
commit
79994c6cf4
|
@ -263,7 +263,8 @@ class Core:
|
|||
|
||||
image = await utils.download_image(filename)
|
||||
filename = re.search('.*\/i\/(.*)', filename).group(1)
|
||||
await ctx.send(file=image, filename=filename)
|
||||
f = discord.File(image, filename=filename)
|
||||
await ctx.send(file=f)
|
||||
|
||||
|
||||
@commands.command(aliases=['dog', 'rd'])
|
||||
|
@ -282,7 +283,8 @@ class Core:
|
|||
return
|
||||
|
||||
image = await utils.download_image("http://random.dog/{}".format(filename))
|
||||
await ctx.send(file=image, filename=filename)
|
||||
f = discord.File(image, filename=filename)
|
||||
await ctx.send(file=f)
|
||||
|
||||
@commands.command()
|
||||
@utils.custom_perms(send_messages=True)
|
||||
|
@ -294,7 +296,7 @@ class Core:
|
|||
# Find a random image based on how many we currently have
|
||||
f = random.SystemRandom().choice(glob.glob('images/snek*'))
|
||||
with open(f, 'rb') as f:
|
||||
await ctx.send(file=f)
|
||||
await ctx.send(file=discord.File(f))
|
||||
|
||||
@commands.command()
|
||||
@utils.custom_perms(send_messages=True)
|
||||
|
|
|
@ -137,16 +137,17 @@ class Interaction:
|
|||
|
||||
url = member.avatar_url
|
||||
if ctx.message.guild.me.permissions_in(ctx.message.channel).attach_files:
|
||||
file = await utils.download_image(url)
|
||||
if file is None:
|
||||
filedata = await utils.download_image(url)
|
||||
if filedata is None:
|
||||
await ctx.send(url)
|
||||
else:
|
||||
if '.gif' in url:
|
||||
filename = 'avatar.gif'
|
||||
else:
|
||||
filename = 'avatar.jpg'
|
||||
file = utils.convert_to_jpeg(file)
|
||||
await ctx.send(file=file, filename=filename)
|
||||
filedata = utils.convert_to_jpeg(filedata)
|
||||
f = discord.File(filedata, filename=filename)
|
||||
await ctx.send(file=f)
|
||||
else:
|
||||
await ctx.send(url)
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ class Overwatch:
|
|||
output_data.append((k.title().replace("_", " "), r))
|
||||
try:
|
||||
banner = await utils.create_banner(user, "Overwatch", output_data)
|
||||
await ctx.send(file=banner)
|
||||
await ctx.send(file=discord.File(banner))
|
||||
except (FileNotFoundError, discord.Forbidden):
|
||||
fmt = "\n".join("{}: {}".format(k, r) for k, r in output_data)
|
||||
await ctx.send("Overwatch stats for {}: ```py\n{}```".format(user.name, fmt))
|
||||
|
|
|
@ -80,7 +80,7 @@ class Stats:
|
|||
("Your Usage", member_usage),
|
||||
("This Server's Usage", server_usage)]
|
||||
banner = await utils.create_banner(ctx.message.author, "Command Stats", data)
|
||||
await ctx.send(file=banner)
|
||||
await ctx.send(file=discord.File(banner))
|
||||
except (FileNotFoundError, discord.Forbidden):
|
||||
fmt = "The command {} has been used a total of {} times\n" \
|
||||
"{} times on this server\n" \
|
||||
|
@ -117,7 +117,7 @@ class Stats:
|
|||
try:
|
||||
top_5 = [(data[0], data[1]) for data in sorted_stats[:5]]
|
||||
banner = await utils.create_banner(ctx.message.author, "Your command usage", top_5)
|
||||
await ctx.send(file=banner)
|
||||
await ctx.send(file=discord.File(banner))
|
||||
except (FileNotFoundError, discord.Forbidden):
|
||||
top_5 = "\n".join("{}: {}".format(data[0], data[1]) for data in sorted_stats[:5])
|
||||
await ctx.send(
|
||||
|
@ -132,7 +132,7 @@ class Stats:
|
|||
try:
|
||||
top_5 = [(data[0], data[1]) for data in sorted_stats[:5]]
|
||||
banner = await utils.create_banner(ctx.message.author, "Server command usage", top_5)
|
||||
await ctx.send(file=banner)
|
||||
await ctx.send(file=discord.File(banner))
|
||||
except (FileNotFoundError, discord.Forbidden):
|
||||
top_5 = "\n".join("{}: {}".format(data[0], data[1]) for data in sorted_stats[:5])
|
||||
await ctx.send(
|
||||
|
@ -201,7 +201,7 @@ class Stats:
|
|||
output = [("{0.display_name}".format(ctx.message.guild.get_member(m_id)), amt)
|
||||
for m_id, amt in sorted_booped_members]
|
||||
banner = await utils.create_banner(ctx.message.author, "Your booped victims", output)
|
||||
await ctx.send(file=banner)
|
||||
await ctx.send(file=discord.File(banner))
|
||||
except (FileNotFoundError, discord.Forbidden):
|
||||
output = "\n".join(
|
||||
"{0.display_name}: {1} times".format(ctx.message.guild.get_member(m_id), amt) for
|
||||
|
@ -285,7 +285,7 @@ class Stats:
|
|||
fmt = [('Record', record), ('Server Rank', '{}/{}'.format(server_rank, len(server_members))),
|
||||
('Overall Rank', '{}/{}'.format(total_rank, len(all_members))), ('Rating', rating)]
|
||||
banner = await utils.create_banner(member, title, fmt)
|
||||
await ctx.send(file=banner)
|
||||
await ctx.send(file=discord.File(banner))
|
||||
except (FileNotFoundError, discord.Forbidden):
|
||||
fmt = 'Stats for {}:\n\tRecord: {}\n\tServer Rank: {}/{}\n\tOverall Rank: {}/{}\n\tRating: {}'
|
||||
fmt = fmt.format(member.display_name, record, server_rank, len(server_members), total_rank,
|
||||
|
|
Loading…
Reference in a new issue