Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions cogs/discord_data_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import discord
import os, dateutil, json, sys
from datetime import datetime

from asyncio import sleep
from utils.db import SupabaseInterface
from utils.api import GithubAPI
import csv
Expand Down Expand Up @@ -106,23 +106,27 @@ def valid_user(ctx):

@commands.command()
@commands.check(valid_user)
async def enable_webhooks(self, ctx):
try:
guild = await self.bot.fetch_guild(os.getenv("SERVER_ID"))
channels = await guild.fetch_channels()
for channel in channels:
feedback = f'''Channel: {channel.name}\nCategory: {channel.category} '''
await ctx.send(feedback)
webhook = await channel.create_webhook('New Ticket Alert')
feedback = f'''URL: {webhook.url}\n Token:{"Yes" if webhook.token else "No"}'''
ctx.send(feedback)
SupabaseInterface("discord_channels").insert({
"channel_id": channel.id,
"channel_name": channel.name,
"webhook": webhook.url
})
except Exception as e:
await ctx.send(e)
async def enable_webhook(self, ctx):
guild = await self.bot.fetch_guild(os.getenv("SERVER_ID"))
channels = await guild.fetch_channels()
enabled = [channel["channel_id"] for channel in SupabaseInterface("discord_channels").read_all()]
for channel in channels:
try:
feedback = f'''Channel: {channel.name}\nCategory: {channel.category} '''
await ctx.send(feedback)
if isinstance(channel, TextChannel) and channel.id not in enabled:
sleep(120)
webhook = await channel.create_webhook(name = 'New Ticket Alert')
feedback = f'''URL: {webhook.url}\n Token:{"Yes" if webhook.token else "No"}'''
await ctx.send(feedback)
SupabaseInterface("discord_channels").insert({
"channel_id": channel.id,
"channel_name": channel.name,
"webhook": webhook.url
})
except Exception as e:
await ctx.send(e)
continue



Expand Down
30 changes: 30 additions & 0 deletions cogs/server_management.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from discord.ext import commands
import discord
class ServerManagement(commands.Cog):
def __init__(self, bot):
self.bot = bot
def validUser(self, ctx):
authorised_users = [1042682119035568178, 1120262151676895274, 1107555866422562926, 1107555866422562926, 599878601143222282] #bhavya, devaraj, navaneeth, venkatesh, sukhpreet
return ctx.author.id in authorised_users


#Channel Notifications Management
@commands.command()
@commands.check(validUser)
async def assign_channel(self, ctx, args):
pass

async def dissociate_channel(self,ctx, args):
pass

async def notifs_on(self,ctx,args):
pass

async def notifs_off(self, ctx, args):
pass

# async def


async def setup(bot):
await bot.add_cog(ServerManagement(bot))
30 changes: 16 additions & 14 deletions cogs/user_interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,21 +285,23 @@ async def get_points(self, ctx):
"high": 0
}
for pr in prs_raised:
raise_points+=pr["points"]
if pr["points"] == 10:
raiseTicketComplexity["low"]+=1
if pr["points"] == 20:
raiseTicketComplexity["medium"]+=1
if pr["points"] == 30:
raiseTicketComplexity["high"]+=1
if pr["is_merged"]:
raise_points+=pr["points"]
if pr["points"] == 10:
raiseTicketComplexity["low"]+=1
if pr["points"] == 20:
raiseTicketComplexity["medium"]+=1
if pr["points"] == 30:
raiseTicketComplexity["high"]+=1
for pr in prs_merged:
merge_points+=pr["points"]
if pr["points"] == 10:
mergeTicketComplexity["low"]+=1
if pr["points"] == 20:
mergeTicketComplexity["medium"]+=1
if pr["points"] == 30:
mergeTicketComplexity["high"]+=1
if pr["is_merged"]:
merge_points+=pr["points"]
if pr["points"] == 10:
mergeTicketComplexity["low"]+=1
if pr["points"] == 20:
mergeTicketComplexity["medium"]+=1
if pr["points"] == 30:
mergeTicketComplexity["high"]+=1

text = f'''Hey {ctx.author.name}

Expand Down