Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
Patch-2.2
Browse files Browse the repository at this point in the history
See v2.2 for more info!
  • Loading branch information
TheKaushikGoswami committed Jun 29, 2021
1 parent 43fe8da commit 4b60a9d
Show file tree
Hide file tree
Showing 8 changed files with 240 additions and 142 deletions.
19 changes: 18 additions & 1 deletion cogs/api_cmd.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import io
import discord
import praw
from discord.ext import commands, tasks
Expand Down Expand Up @@ -379,9 +380,25 @@ async def joke(self, ctx):
embed.set_footer(text='Prompted by {}'.format(ctx.author), icon_url=ctx.author.avatar_url)
await ctx.send(embed=embed)

#triggered pic CMD

@commands.command()
async def triggered(self, ctx, member: discord.Member = None):
if member == None:
member = ctx.author
await ctx.trigger_typing()
async with aiohttp.ClientSession() as session:
async with session.get(f'https://some-random-api.ml/canvas/triggered?avatar={member.avatar_url_as(format="png")}') as af:
if 300 > af.status >= 200:
fp = io.BytesIO (await af.read())
file = discord.File(fp, "triggered.png")
em = discord.Embed(title="", color=ctx.author.color)
em.set_image(url="attachment://triggered.png")
await ctx.send(embed=em, file=file)


def setup(bot):
bot.add_cog(Api(bot))
print("Api cog is Working!")

#👍: {ups} | 👎: {downs}
#👍: {ups} | 👎: {downs}
2 changes: 1 addition & 1 deletion cogs/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,4 +523,4 @@ async def kill(self, ctx, *, user: discord.Member = None):

def setup(bot):
bot.add_cog(Fun(bot))
print("Fun Cog is Loaded!")
print("Fun Cog is Loaded!")
2 changes: 1 addition & 1 deletion cogs/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,4 @@ async def embedtest(self, ctx):

def setup(Bot):
Bot.add_cog(SPIKE(Bot))
print("Help cog is working.")
print("Help cog is working.")
113 changes: 66 additions & 47 deletions cogs/mod.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import discord
from discord import guild
from discord.errors import HTTPException
from discord.ext import commands
from discord import User
import datetime
Expand All @@ -10,22 +11,6 @@

from discord.ext.commands.core import check

time_regex = re.compile("(?:(\d{1,5})(h|s|m|d))+?")
time_dict = {"h":3600, "s":1, "m":60, "d":86400}

class TimeConverter(commands.Converter):
async def convert(self, ctx, argument):
args = argument.lower()
matches = re.findall(time_regex, args)
time = 0
for v, k in matches:
try:
time += time_dict[k]*float(v)
except KeyError:
raise commands.BadArgument("{} is an invalid time-key! h/m/s/d are valid!".format(k))
except ValueError:
raise commands.BadArgument("{} is not a number!".format(v))
return time

class Mod(commands.Cog, name='Mod'):

Expand All @@ -52,7 +37,7 @@ async def nick(self, ctx, member: discord.Member, *, nick):
async def kick(self, ctx, user : discord.Member, *, reason = None):
"""Kicks a user from the server."""
if user == ctx.guild.owner:
return await ctx.send(f'**<a:RedTick:796628786102927390> You are not cool enough to mute that person.**')
return await ctx.send(f'**<a:RedTick:796628786102927390> You are not cool enough to kick that person.**')
if ctx.author == user:
await ctx.send("You cannot kick yourself.")
return
Expand Down Expand Up @@ -123,38 +108,69 @@ async def unban(self, ctx, *, member):
#mute CMD

@commands.command(aliases=['tempmute'])
@commands.has_permissions(manage_messages=True)
async def mute(self, ctx, member: discord.User=None, time:TimeConverter = None, *, reason=None):
if member in ctx.guild.members:
async def mute(self, ctx, member: discord.Member=None, time=None, *, reason=None):
if not member:
await ctx.send("You must mention a member to mute!")

if member == ctx.guild.owner:
return await ctx.send(f'**<a:RedTick:796628786102927390> You are not cool enough to mute that person.**')

if ctx.message.author.top_role <= member.top_role:
await ctx.send(f"**<a:RedTick:796628786102927390> You are not cool enough to mute that person.**")
return

elif not time:
await ctx.send("You must mention a time!")

else:
if not reason:
reason="No reason given"
#Now timed mute manipulation

if member == ctx.guild.owner:
return await ctx.send(f'**<a:RedTick:796628786102927390> You are not cool enough to mute that person.**')
if ctx.message.author.top_role <= member.top_role:
await ctx.send(f"**<a:RedTick:796628786102927390> You are not cool enough to mute that person.**")
try:
seconds = int(time[:-1]) #Gets the numbers from the time argument, start to -1
duration = time[-1] #Gets the timed maniulation, s, m, h, d
if duration == "s":
seconds = seconds * 1
elif duration == "m":
seconds = seconds * 60
elif duration == "h":
seconds = seconds * 60 * 60
elif duration == "d":
seconds = seconds * 86400
else:
await ctx.send("Invalid duration input")
return

except Exception as e:
print(e)
await ctx.send("Invalid time input")
return
if not member:
await ctx.send("You must mention a member to mute!")
elif not time:
await ctx.send("You must mention a time!")
else:
if not reason:
reason= "No Reason Mentioned"
guild = ctx.guild
Muted = discord.utils.get(guild.roles, name="Muted")
if not Muted:
Muted = await guild.create_role(name="Muted")
for channel in guild.channels:
await channel.set_permissions(Muted, speak=False, send_messages=False, read_message_history=True, read_messages=False)
await member.add_roles(Muted, reason=reason)
muted_embed = discord.Embed(title="New Punishment!", description=f"🤐 You were muted by {ctx.author.mention} for **{time}** coz of reason: **{reason}** in server **{guild.name}**", color=0xE91E63)
await ctx.send(f":ok_hand: {member.mention} was successfully muted!")

guild = ctx.guild
Muted = discord.utils.get(guild.roles, name="Muted")

if not Muted:
Muted = await guild.create_role(name="Muted")

for channel in guild.channels:
await channel.set_permissions(Muted, speak=False, send_messages=False, read_message_history=True, read_messages=False)

await member.add_roles(Muted, reason=reason)
muted_embed = discord.Embed(title="New Punishment!", description=f"🤐 You were muted by {ctx.author.mention} for **{time}** coz of reason: **{reason}** in server **{guild.name}**", color=0xE91E63)
await ctx.send(f":ok_hand: {member.mention} was successfully muted!")
try:
await member.send(embed=muted_embed)
await asyncio.sleep(time)
await member.remove_roles(Muted)
unmute_embed = discord.Embed(title="Mute over!", description=f'Your mute of time: {time} is over now!\n Reason was: `{reason}`\n Make sure not to repeat it again!', color=0xE91E63)
except HTTPException:
pass
await asyncio.sleep(seconds)
await member.remove_roles(Muted)
unmute_embed = discord.Embed(title="Mute over!", description=f'Your mute of time: {time} is over now!\n Reason was: `{reason}`\n Make sure not to repeat it again!', color=0xE91E63)
try:
await member.send(embed=unmute_embed)
else:
await ctx.send(f"**<a:RedTick:796628786102927390> The user is not present in the guild!**")
except HTTPException:
pass


#unmute CMD

Expand All @@ -166,7 +182,10 @@ async def unmute(self, ctx, member: discord.Member):
await member.remove_roles(role)
unmute_msg = f"``` You have been un-muted in {ctx.guild.name} by the Moderator - {ctx.author.name}```"
await ctx.send(f"{member.mention} was unmuted.")
await member.send(unmute_msg)
try:
await member.send(unmute_msg)
except HTTPException:
pass
else:
await ctx.send(f"**Is That Person even muted? <:hmm:815854699084644352>**")

Expand Down Expand Up @@ -219,7 +238,7 @@ def check(msg):
# nuke COMMAND

@commands.command()
@commands.has_permissions(administrator=True)
@commands.has_permissions(manage_channels=True)
async def nuke(self, ctx):
channel = ctx.channel
positions = ctx.channel.position
Expand Down
166 changes: 81 additions & 85 deletions cogs/nqn.py
Original file line number Diff line number Diff line change
@@ -1,110 +1,106 @@
from discord.ext import commands
from discord import utils
import discord
import sys

blacklist_servers = [795231055954313236]
# blacklist_servers = [795231055954313236, 773185292211453974]

class Nqn(commands.Cog, name='Nqn'):
class emoji(commands.Cog):
def __init__(self, bot):
self.bot = bot

def cog_check(self, ctx):
if ctx.guild.id in blacklist_servers:
return
# def cog_check(self, ctx):
# if ctx.guild.id in blacklist_servers:
# return

async def getemote(self, arg):
emoji = utils.get(self.bot.emojis, name = arg.strip(":"))
async def getemote(self, arg):
emoji = utils.get(self.bot.emojis, name = arg.strip(":"))

if emoji is not None:
if emoji.animated:
add = "a"
else:
add = ""
return f"<{add}:{emoji.name}:{emoji.id}>"
if emoji is not None:
if emoji.animated:
add = "a"
else:
return None

async def getinstr(self, content):
ret = []

spc = content.split(" ")
cnt = content.split(":")

if len(cnt) > 1:
for item in spc:
if item.count(":") > 1:
wr = ""
if item.startswith("<") and item.endswith(">"):
ret.append(item)
else:
cnt = 0
for i in item:
if cnt == 2:
add = ""
return f"<{add}:{emoji.name}:{emoji.id}>"
else:
return None

async def getinstr(self, content):
ret = []
spc = content.split(" ")
cnt = content.split(":")

if len(cnt) > 1:
for item in spc:
if item.count(":") > 1:
wr = ""
if item.startswith("<") and item.endswith(">"):
ret.append(item)
else:
cnt = 0
for i in item:
if cnt == 2:
aaa = wr.replace(" ", "")
ret.append(aaa)
wr = ""
cnt = 0

if i != ":":
wr += i
else:
if wr == "" or cnt == 1:
wr += " : "
cnt += 1
else:
aaa = wr.replace(" ", "")
ret.append(aaa)
wr = ""
cnt = 0
wr = ":"
cnt = 1

if i != ":":
wr += i
else:
if wr == "" or cnt == 1:
wr += " : "
cnt += 1
else:
aaa = wr.replace(" ", "")
ret.append(aaa)
wr = ":"
cnt = 1

aaa = wr.replace(" ", "")
ret.append(aaa)
else:
ret.append(item)
else:
return content
aaa = wr.replace(" ", "")
ret.append(aaa)
else:
ret.append(item)
else:
return content

return ret
return ret


# i added extra indent by mistake -_-

@commands.Cog.listener()
async def on_message(self, message):
if message.author.bot:
return

if ":" in message.content:
msg = await self.getinstr(message.content)
ret = ""
em = False
smth = message.content.split(":")
if len(smth) > 1:
for word in msg:
if word.startswith(":") and word.endswith(":") and len(word) > 1:
emoji = await self.getemote(word)
if emoji is not None:
em = True
ret += f" {emoji}"
else:
ret += f" {word}"
@commands.Cog.listener()
async def on_message(self, message):
if message.author.bot:
return

if ":" in message.content:
msg = await self.getinstr(message.content)
ret = ""
em = False
smth = message.content.split(":")
if len(smth) > 1:
for word in msg:
if word.startswith(":") and word.endswith(":") and len(word) > 1:
emoji = await self.getemote(word)
if emoji is not None:
em = True
ret += f" {emoji}"
else:
ret += f" {word}"
else:
ret += f" {word}"

else:
ret += msg
else:
ret += msg


if em:
webhooks = await message.channel.webhooks()
webhook = utils.get(webhooks, name = "Imposter NQN")
if webhook is None:
webhook = await message.channel.create_webhook(name = "Imposter NQN")

await webhook.send(ret, username = message.author.name, avatar_url = message.author.avatar_url)
await message.delete()
if em:
webhooks = await message.channel.webhooks()
webhook = utils.get(webhooks, name = "SPIKE NQN")
if webhook is None:
webhook = await message.channel.create_webhook(name = "SPIKE NQN")
await webhook.send(ret, username = message.author.name, avatar_url = message.author.avatar_url)
await message.delete()

def setup(Bot):
Bot.add_cog(Nqn(Bot))
print("Nqn cog is loaded!")
def setup(bot):
bot.add_cog(emoji(bot))
Loading

0 comments on commit 4b60a9d

Please sign in to comment.