Skip to content

Instantly share code, notes, and snippets.

@NotSoSuper
Created July 14, 2017 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NotSoSuper/274338f428c1447743a79459e61abc18 to your computer and use it in GitHub Desktop.
Save NotSoSuper/274338f428c1447743a79459e61abc18 to your computer and use it in GitHub Desktop.
@commands.command(pass_context=True)
@commands.cooldown(2, 5, commands.BucketType.server)
@checks.bot_has_perm(add_reactions=True)
async def react(self, ctx, *, txt:str):
msg = None
channel = ctx.message.channel
for c in ctx.message.channel_mentions:
channel = c
txt = txt.replace(c.mention, '')
if not channel.is_private:
elif not channel.permissions_for(ctx.message.author).send_messages:
return await self.bot.say('\N{NO ENTRY} `You do not have permission to message in that channel.`')
for s in txt.split():
if s.isdigit():
if len(s) > 13:
try:
if self.bot.self_bot:
#well, i trust ill give the command the right message id, no need to get logs_from with "check=lambda x: x.id == s" xd
msg = discord.Message(id=s, channel=discord.Object(id=ctx.message.channel.id), reactions=())
else:
msg = await self.bot.get_message(channel, s)
except:
continue
else:
txt = txt.replace(s, '')
break
if not msg:
msg = ctx.message
count = 0
icount = 0
continue_count = 0
added = []
indexs = {}
_x = False
word_emotes = ['cool', 'ok', 'ng', 'up', 'new', 'ab', 'cl', 'sos', 'id']
for split in txt.lower().split():
if split in word_emotes and split not in added:
indexs[txt.lower().rindex(split)] = [len(split), self.emojis[split]]
match = self.emote_regex.match(split)
if match:
em = None
for e in self.bot.get_all_emojis():
if e.id == str(match.group('id')):
em = e
break
if em:
indexs[txt.lower().rindex(split)] = [len(split), em]
for s in txt.lower():
if len(added) == 20:
break
if s == ' ':
continue
if icount in indexs:
i = indexs[icount]
if i[1] in added:
continue
continue_count += i[0]
await self.bot.add_reaction(msg, i[1])
added.append(i[1])
count += 1
else:
if icount == 0:
icount += 1
if continue_count != 0:
icount += 1
continue_count -= 1
continue
em = None
if s not in added:
if s in self.regional_map:
em = self.regional_map[s]
elif s in self.emojis:
em = self.emojis[s]
else:
for e in self.emojis:
if self.emojis[e] == s:
em = self.emojis[e]
break
if em is None:
if s == '?':
em = self.emojis['question']
elif s == '!':
em = self.emojis['exclamation']
elif s == '#':
em = self.emojis['hash']
else:
if s == 'a' or s == 'b' or s == 'm':
em = self.emojis[s]
elif s == 'c':
em = self.emojis['copyright']
elif s == 'r':
em = self.emojis['registered']
elif s == 'o':
em = self.emojis['o2']
elif s == 'p':
em = self.emojis['parking']
elif s == 'i':
em = self.emojis['information_source']
elif s == 'l':
if txt.lower().count('i') <= 1:
em = self.regional_map['i']
elif s == 'e':
em = self.emojis['email']
elif s == 'm':
em = self.emojis['scorpius']
elif s == 'o':
em = self.emojis['zero']
elif s == 'x':
if _x:
em = self.emojis['heavy_multiplication_x']
else:
em = self.emojis[s]
_x = True
if em:
await self.bot.add_reaction(msg, em)
added.append(s)
count += 1
await asyncio.sleep(0.21)
icount += 1
if count == 0:
await self.bot.say('\N{NO ENTRY} Invalid Text.')
else:
x = await self.bot.say('\N{WHITE HEAVY CHECK MARK} Added `{0}` reactions.'.format(count))
await asyncio.sleep(5)
try:
if msg != ctx.message:
await self.bot.delete_messages([x, ctx.message])
else:
await self.bot.delete_message(x)
except:
pass
@kayaked
Copy link

kayaked commented Jul 21, 2018

thanks bud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment