def emojis(): return [ Emoji(id="1", name="swranged", server=None), Emoji(id="2", name="swfocus", server=None), Emoji(id="3", name="swdisrupt", server=None), Emoji(id="4", name="swresource", server=None), Emoji(id="5", name="swblank", server=None) ]
async def on_emoji_removed(self, emoji: discord.Emoji) -> None: """flags an emoji as cached should be called when an emoji is removed from the guild """ emoji = self.find_emoji(d_id=emoji.id, name=emoji.name) if emoji: emoji.cache() await self._update_emojis_db((emoji, ))
async def action(message, client): line = random.choice(list(open('snooplinks.txt'))) if random.choice([1, 2, 3, 4, 5]) == 1: # 4/20 choice to post a video msg = '<{0}>'.format(line) await client.send_message(message.channel, msg) else: weedmoj = Emoji(server='Cafe of Broken Dreams', id='260293426401116160') await client.add_reaction(message, weedmoj)
async def emoji(self, ctx, *, emoji:discord.Emoji): emoji_str = "<{0}:{1}:{2}>".format("a" if emoji.animated else "", emoji.name, emoji.id) title = ("Emoji Info " + emoji_str) if emoji.is_usable() else "Emoji Info" embed = discord.Embed(title=title, type="Rich", color=discord.Color.blue()) embed.set_thumbnail(url=emoji.url) embed.add_field(name="Name", value=emoji.name) embed.add_field(name="ID", value=emoji.id) embed.add_field(name="Non-Nitro Copy-Paste (For badge creation)", value="`" + emoji_format(emoji_str) + "`", inline=False) await ctx.send(embed=embed)
def get_emoji(self, **data): id_ = data['id'] if not id_: return data['name'] for server in self.bot.servers: for emoji in server.emojis: if emoji.id == id_: return emoji return Emoji(server=None, **data)
async def _create_role_management(self, ctx: Context, role: Role, emoji: Emoji): if not role.mentionable: return await ctx.send("Error: role is not mentionable") if not emoji.is_usable(): return await ctx.send("Error: I can't use that emoji") message = await ctx.send(f"React with {emoji} to join {role.mention}") await message.add_reaction(emoji) redis = get_redis() key = f"role_mgmt:{message.id}" redis.hset(key, "emoji_id", emoji.id) redis.hset(key, "role_id", role.id)
def create_bot_instance(cfg: Index, dat: dict): inst = Bot(command_prefix=cfg["init"]["pre"], pm_help=True) reactions = {} for each in cfg["hk emoji"]: d = Emoji(require_colons=True, managed=False, name=each.tag, id=each.val, server=cfg["init"]["server"]) reactions.update({each.tag: d}) for each in cfg["discord emoji"]: reactions.update({each.tag: chr(int(each.val))}) dat.update({"reactions": reactions}) initialize_events(inst, cfg, dat) initialize_commands(inst, cfg, dat) return inst
async def react(ctx, id, emote: discord.Emoji, channel=None): if not channel: channel = ctx.channel or ctx.author msg = await channel.fetch_message(id) if emote[0] == ':' or emote[0] == '<': emote = emote.split(':')[1] e = None if ctx.guild: em = ems.setdefault(ctx.guild.id, EmoteManager(ctx.guild)) if em.eCycle: await em.addEmote(emote, ctx.guild) e = discord.utils.get(ctx.guild.emojis, name=emote) if not e: e = discord.utils.get(bot.emojis, name=emote) if not e: e = emoji.emojize(':' + emote + ':', use_aliases=True) if e == ':' + emote + ':': e = emote await msg.add_reaction(e) print('Reacted', emote)
def sroll(message): """Rolls d6 dice in N format.""" # Validate syntax try: rollArg = util.getArg(message.content, 1) rolls = int(rollArg) except: return if rolls < 1 or rolls > 30: return result = '' hits = 0 glitches = 0 for r in range(0, rolls): roll = randint(1, 6) if roll >= 5: hits += 1 elif roll == 1: glitches += 1 earr = [ 360257354694000641, 360257354765434892, 360257354853253121, 360257355142922240, 360257355134402560, 360257355138727946 ] emoji = Emoji(id=earr[roll - 1], server=stormbird.get_server(112471696346255360)) result += str(emoji) glitch = '' if glitches > int(rolls / 2): if hits == 0: glitch = ' - ‼️***Critical Glitch*** ‼' else: glitch = ' - ❗ ***Glitch*** ❗' yield from stormbird.send_message( message.channel, '🎲 **' + str(hits) + '** ' + util.pl('hit', hits) + glitch + '\n' + result)
def setup(bot): bot.add_cog(Emoji(bot))
async def info(self, ctx, emoji : discord.Emoji, types = None): if types != None: embed = discord.Embed() embed.set_thumbnail(url = emoji.url) embed.title = f"Emoji Info: {emoji.name} - {emoji.id}" if str(types).lower() == "name": embed.add_field( name = "Name:", value = "{}".format(str(emoji.name)) ) elif str(types).lower() == "unicode": embed.add_field( name = "Unicode:", value = f"{f'`<a:{emoji.name}:{emoji.id}>`' if emoji.animated else f'`<:{emoji.name}:{emoji.id}>`'}" ) elif str(types).lower() in ("type", "types", "animated"): embed.add_field( name = "Is Animated?", value = str(emoji.animated) ) elif str(types).replace("-", "").replace("_", "").replace(".", "").lower() == "createdat": embed.add_field( name = "Created At:", value = emoji.created_at() ) elif str(types).replace("-", "").replace("_", "").replace(".", "").lower() == "createdby": try: embed.add_field( name = "Created By:", value = str(emoji.user) ) except: return await ctx.send("You have no permission to view this command!") else: return await ctx.send("No such type as {}!".format(types)) return await ctx.send(embed=embed) embed = discord.Embed() embed.set_thumbnail(url = emoji.url) embed.title = f"Emoji Info: {emoji.name} - {emoji.id}" embed.add_field( name = "Name:", value = "{}".format(str(emoji.name)) ) embed.add_field( name = "ID:", value = str(emoji.animated) ) embed.add_field( name = "Unicode:", value = f"{f'`<a:{emoji.name}:{emoji.id}>`' if emoji.animated else f'`<:{emoji.name}:{emoji.id}>`'}" ) embed.add_field( name = "Is Animated?", value = str(emoji.animated) ) embed.add_field( name = "Created At:", value = emoji.created_at() ) try: embed.add_field( name = "Created By:", value = str(emoji.user) ) except: pass await ctx.send(embed=embed)
async def emoji(ctx, emoji: discord.Emoji): await ctx.send(':{}:{}'.format(emoji.name, emoji.id)) if not emoji.is_usable(): await ctx.send('Unavailable') await ctx.send(emoji.url)
def create_emoji(_name, _id): return Emoji(name=_name, id=_id, server=338594020101980160)