| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import discord, random
- from discord.ext import commands
- from query.guild import update_guild
- def setup(bot: commands.Bot):
- bot.add_cog(General(bot))
- class General(commands.Cog):
- """A couple of simple commands."""
- def __init__(self, bot: commands.Bot):
- self.bot = bot
- self.last_msg = None
- @commands.Cog.listener()
- async def on_ready(self):
- print('Logged in as')
- print(self.bot.user.name)
- print(self.bot.user.id)
- print('------')
- @commands.Cog.listener()
- async def on_guild_join(self, guild: discord.Guild):
- update_guild(guild)
- @commands.Cog.listener()
- async def on_message_delete(self, message: discord.Message):
- self.last_msg = message
- @commands.Cog.listener()
- async def on_message(self, message: discord.Message):
- await self.bot.pg.execute("INSERT INTO channel_user(channel, \"user\") VALUES($1, $2) ON CONFLICT ON CONSTRAINT channel_user_channel_user_key DO UPDATE SET total_messages=total_messages+1 WHERE channel=$1 AND \"user\"=$2", message.channel.id, message.author.id)
- if self.bot.user.mentioned_in(message):
- print("mentioned in ")
- print(message.channel)
- interact = await self.bot.pg.fetchrow("SELECT interact FROM channel_settings WHERE channel_id=$1::bigint", message.channel.id)
- print(interact)
- if interact:
- messages = [
- f"Hello {message.author.mention}. <3",
- f"How are you today {message.author.mention}?",
- f"Piss off {message.author.mention}!",
- f"{message.author.mention}, what are you botherring me for?",
- "Go bother someone else...",
- "Is life treating you fair?",
- "What's up?",
- "Why are you talking to me?",
- "I'm not talking to you!",
- "What have you been up to?",
- "How is life?",
- "Kill all humans!",
- "What do you want from me?",
- f"{message.author.mention}, why are you bothering me?",
- f"{message.author.mention}, when will you stop talking about me?",
- f"{message.author.mention} I hate you!",
- f"{message.author.mention} I love you!",
- "Get bent!",
- "Go and touch grass!",
- "Do you think i care about you?",
- f"Stop pinging me {message.author.mention}, you munchkin!",
- ]
- await message.reply(random.choice(messages))
- @commands.command(name="snipe")
- async def snipe(self, ctx: commands.Context):
- """A command to snipe delete messages."""
- if not self.last_msg: # on_message_delete hasn't been triggered since the bot started
- await ctx.send("There is no message to snipe!")
- return
- author = self.last_msg.author
- content = self.last_msg.content
- embed = discord.Embed(title=f"Message from {author}", description=content)
- await ctx.send(embed=embed)
|