mirror of
https://github.com/uhIgnacio/EmoteManager.git
synced 2024-08-15 02:23:13 +00:00
format
This commit is contained in:
parent
84c5276076
commit
35f019a490
3 changed files with 101546 additions and 101544 deletions
|
@ -127,7 +127,7 @@ class Emotes(commands.Cog):
|
||||||
You can use it like this:
|
You can use it like this:
|
||||||
`add :thonkang:` (if you already have that emote)
|
`add :thonkang:` (if you already have that emote)
|
||||||
`add rollsafe https://image.noelshack.com/fichiers/2017/06/1486495269-rollsafe.png`
|
`add rollsafe https://image.noelshack.com/fichiers/2017/06/1486495269-rollsafe.png`
|
||||||
`add speedtest <https://cdn.nextcordapp.com/emojis/379127000398430219.png>`
|
`add speedtest <https://cdn.discord.com/emojis/379127000398430219.png>`
|
||||||
|
|
||||||
With a file attachment:
|
With a file attachment:
|
||||||
`add name` will upload a new emote using the first attachment as the image and call it `name`
|
`add name` will upload a new emote using the first attachment as the image and call it `name`
|
||||||
|
@ -204,7 +204,7 @@ class Emotes(commands.Cog):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def format_emote_filename(filename):
|
def format_emote_filename(filename):
|
||||||
"""format a filename to an emote name as nextcord does when you upload an emote image"""
|
"""format a filename to an emote name as discord does when you upload an emote image"""
|
||||||
left, sep, right = posixpath.splitext(filename)[0].rpartition('-')
|
left, sep, right = posixpath.splitext(filename)[0].rpartition('-')
|
||||||
return (left or right).replace(' ', '')
|
return (left or right).replace(' ', '')
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ class Emotes(commands.Cog):
|
||||||
|
|
||||||
name = f'{name}.{"gif" if emote.animated else "png"}'
|
name = f'{name}.{"gif" if emote.animated else "png"}'
|
||||||
|
|
||||||
# place some level of trust on nextcord's CDN to actually give us images
|
# place some level of trust on discord's CDN to actually give us images
|
||||||
data = await self.fetch_safe(str(emote.url), validate_headers=False)
|
data = await self.fetch_safe(str(emote.url), validate_headers=False)
|
||||||
if type(data) is str: # error case
|
if type(data) is str: # error case
|
||||||
await context.send(f'{emote}: {data}')
|
await context.send(f'{emote}: {data}')
|
||||||
|
|
20
cogs/meta.py
20
cogs/meta.py
|
@ -3,11 +3,12 @@
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
|
|
||||||
import discord
|
import nextcord
|
||||||
from discord.ext import commands
|
from nextcord.ext import commands
|
||||||
|
|
||||||
import utils
|
import utils
|
||||||
|
|
||||||
|
|
||||||
class Meta(commands.Cog):
|
class Meta(commands.Cog):
|
||||||
# TODO does this need to be configurable?
|
# TODO does this need to be configurable?
|
||||||
INVITE_DURATION_SECONDS = 60 * 60 * 3
|
INVITE_DURATION_SECONDS = 60 * 60 * 3
|
||||||
|
@ -39,22 +40,22 @@ class Meta(commands.Cog):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await context.author.send(f'Official support server invite: {invite}')
|
await context.author.send(f'Official support server invite: {invite}')
|
||||||
except discord.Forbidden:
|
except nextcord.Forbidden:
|
||||||
with contextlib.suppress(discord.HTTPException):
|
with contextlib.suppress(nextcord.HTTPException):
|
||||||
await context.message.add_reaction(utils.SUCCESS_EMOJIS[True])
|
await context.message.add_reaction(utils.SUCCESS_EMOJIS[True])
|
||||||
with contextlib.suppress(discord.HTTPException):
|
with contextlib.suppress(nextcord.HTTPException):
|
||||||
await context.send('Unable to send invite in DMs. Please allow DMs from server members.')
|
await context.send('Unable to send invite in DMs. Please allow DMs from server members.')
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
await context.message.add_reaction('📬')
|
await context.message.add_reaction('📬')
|
||||||
except discord.HTTPException:
|
except nextcord.HTTPException:
|
||||||
with contextlib.suppress(discord.HTTPException):
|
with contextlib.suppress(nextcord.HTTPException):
|
||||||
await context.send('📬')
|
await context.send('📬')
|
||||||
|
|
||||||
@commands.command(aliases=['inv'])
|
@commands.command(aliases=['inv'])
|
||||||
async def invite(self, context):
|
async def invite(self, context):
|
||||||
"""Gives you a link to add me to your server."""
|
"""Gives you a link to add me to your server."""
|
||||||
permissions = discord.Permissions()
|
permissions = nextcord.Permissions()
|
||||||
permissions.update(**dict.fromkeys((
|
permissions.update(**dict.fromkeys((
|
||||||
'read_messages',
|
'read_messages',
|
||||||
'send_messages',
|
'send_messages',
|
||||||
|
@ -65,7 +66,8 @@ class Meta(commands.Cog):
|
||||||
'attach_files',
|
'attach_files',
|
||||||
), True))
|
), True))
|
||||||
|
|
||||||
await context.send('<%s>' % discord.utils.oauth_url(self.bot.user.id, permissions))
|
await context.send('<%s>' % nextcord.utils.oauth_url(self.bot.user.id, permissions))
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
bot.add_cog(Meta(bot))
|
bot.add_cog(Meta(bot))
|
||||||
|
|
Loading…
Reference in a new issue