Skip to content

Commit

Permalink
delete command update
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhruvacube committed Aug 1, 2021
1 parent 36dd159 commit 3f6caa6
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 18 deletions.
36 changes: 34 additions & 2 deletions minato_namikaze/botmain/bot/cogs/developer/developer.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async def dev(self, ctx, command=None):
else:
pass

@dev.group(name='postcommand', alisases=['postfates'])
@dev.group(name='postcommand', alisases=['postfates','post_commands_to_fates_list'])
async def post_commands_to_fates_list(self, ctx):
'''Post all the commands to FATES LIST'''
import time
Expand All @@ -82,7 +82,7 @@ async def post_commands_to_fates_list(self, ctx):
content=f'Posted! :inbox_tray: {ctx.message.author.mention}',
embed=discord.Embed(
title='Commands Posted!',
description=f'**Time taken**: {start_time-time.time()} sec',
description=f'**Time taken**: {round(time.time()-start_time)} sec',
timestamp=ctx.message.created_at,
color=discord.Color.random()
)
Expand All @@ -94,6 +94,38 @@ async def post_commands_to_fates_list(self, ctx):
name='over Naruto'
)
)


@dev.group(name='deletecommand', alisases=['postfates','deletefateslistcommand'])
async def deletefateslistcommand(self, ctx):
'''Deletes all the commands from FATES LIST'''
import time
start_time=time.time()
await self.bot.change_presence(
status=discord.Status.dnd,
activity=discord.CustomActivity(
name='Internal Cleanup!',
emoji=':broom:',
type=discord.ActivityType.playing,
)
)
post_start = await ctx.send('Deleting :broom:')
await PostStats(self.bot).delete_commands()
await post_start.edit(
content=f'Deleted! :wastebasket: {ctx.message.author.mention}',
embed=Embed(
title='Commands Deleted!',
description=f'**Time taken**: {start_time-time.time()} sec',
timestamp=ctx.message.created_at,
)
)
await self.bot.change_presence(
status=discord.Status.idle,
activity=discord.Activity(
type=discord.ActivityType.watching,
name='over Naruto'
)
)

@dev.group(name='sharedservers', usage="<user>")
async def sharedservers(self, ctx, *, user: discord.Member):
Expand Down
54 changes: 38 additions & 16 deletions minato_namikaze/botmain/bot/lib/util/post_user_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,27 @@ class PostStats:
def __init__(self, bot):
self.bot = bot

async def delete_commands(self):
try:
allcmd = requests.get(
f'https://fateslist.xyz/api/v2/bots/{self.bot.user.id}/commands',
headers={"Authorization": fateslist,"Content-Type": "application/json"}
)
if allcmd.status_code != 404:
for i in allcmd1:
for j in allcmd1.get(i):
requests.delete(
f'https://fateslist.xyz/api/v2/bots/{self.bot.user.id}/commands/{j.get("id")}',
headers={"Authorization": fateslist,"Content-Type": "application/json"}
)
await asyncio.sleep(5)
return True
else:
return False
return True
except:
return False

async def post_commands(self):
commands_list = []
for i in self.bot.commands:
Expand Down Expand Up @@ -54,24 +75,25 @@ async def post_commands(self):
json=i,
)
else:
await asyncio.sleep(15)
allcmd = requests.get(
f'https://fateslist.xyz/api/v2/bots/{self.bot.user.id}/commands',
headers={"Authorization": fateslist,"Content-Type": "application/json"}
)
await asyncio.sleep(5)
try:
allcmd1 = allcmd.json()
allcmd = requests.get(
f'https://fateslist.xyz/api/v2/bots/{self.bot.user.id}/commands',
headers={"Authorization": fateslist,"Content-Type": "application/json"}
)
if allcmd.status_code != 404:
allcmd1 = allcmd.json()
all_cogs = list(self.bot.cogs.keys())
for i in allcmd1:
for j in allcmd1.get(i):
if j.get('cmd_name') in all_cogs:
requests.delete(
f'https://fateslist.xyz/api/v2/bots/{self.bot.user.id}/commands/{j.get("id")}',
headers={"Authorization": fateslist,"Content-Type": "application/json"}
)
await asyncio.sleep(5)
except:
return
all_cogs = list(self.bot.cogs.keys())
for i in allcmd1:
for j in allcmd1.get(i):
if j.get('cmd_name') in allcmd1:
requests.delete(
f'https://fateslist.xyz/api/v2/bots/{self.bot.user.id}/commands/{j.get("id")}',
headers={"Authorization": fateslist,"Content-Type": "application/json"}
)
await asyncio.sleep(15)
pass


async def post(self, url, headers, data: dict = None, json: dict = None, getrequestobj=False):
Expand Down

0 comments on commit 3f6caa6

Please sign in to comment.