forked from Darkempire78/Mee6-Bypasser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove.py
57 lines (44 loc) · 2.13 KB
/
remove.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import discord
import json
from discord.ext import commands
from discord.ext.commands import has_permissions
# ------------------------ COGS ------------------------ #
class RemoveCog(commands.Cog, name="remove command"):
def __init__(self, bot):
self.bot = bot
# ------------------------------------------------------ #
@commands.command(name = 'remove')
@has_permissions(administrator = True)
async def remove (self, ctx, levelNumber):
# Trying set levelnumber to int
try:
levelNumber = int(levelNumber)
except:
embed = discord.Embed(title=f"**ERROR**", description=f"The level number must be a number\nFollow the example : ``{self.bot.command_prefix}remove <Level number>``", color=0xe00000) # Red
embed.set_footer(text="Bot Created by Darkempire#8245")
return await ctx.channel.send(embed=embed)
# Read json file
with open("roles.json", "r+") as roleFile:
data = json.load(roleFile)
try:
# Remove
numberOfLevelReward = -1
for x in data["roles"]:
numberOfLevelReward += 1
if x["level"] == levelNumber:
del data["roles"][numberOfLevelReward]
newdata = data
except:
embed = discord.Embed(title=f"**ERROR**", description=f"The level number is not valid.", color=0xe00000) # Red
embed.set_footer(text="Bot Created by Darkempire#8245")
return await ctx.channel.send(embed=embed)
newdata = json.dumps(data, indent=4, ensure_ascii=False)
# Write new json file
with open("roles.json", "w") as roleFile:
roleFile.write(newdata)
embed = discord.Embed(title=f"**SUCCESS**", description=f"The role reward has been remove.", color=0x1eb823) # Green
embed.set_footer(text="Bot Created by Darkempire#8245")
await ctx.channel.send(embed=embed)
# ------------------------ BOT ------------------------ #
def setup(bot):
bot.add_cog(RemoveCog(bot))