-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReputationScore.py
More file actions
129 lines (99 loc) · 3.52 KB
/
Copy pathReputationScore.py
File metadata and controls
129 lines (99 loc) · 3.52 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import random
import discord
import json
import os
from discord.ext import commands
from discord.commands import *
from firebase_admin import db
standart_Ctzn_Score = 300;
if os.path.exists(os.getcwd() + "/config.json"):
with open("./config.json") as f:
configData = json.load(f)
bannedWords = configData["bannedWords"]
class Reputation(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command()
async def addbannedword(self, ctx, word):
if str(word).lower() in bannedWords:
await ctx.send("Already banned")
else:
bannedWords.append(str(word).lower())
with open("./config.json", "r+") as f:
data = json.load(f)
data["bannedWords"] = bannedWords
f.seek(0)
f.write(json.dumps(data))
f.truncate()
await ctx.message.delete()
await ctx.send("Word added to banned Words")
@commands.command()
async def removebannedword(self, ctx, word):
if str(word).lower() in bannedWords:
bannedWords.remove(word.lower())
with open("./config.json", "r+") as f:
data = json.load(f)
data["bannedWords"] = bannedWords
f.seek(0)
f.write(json.dumps(data))
f.truncate()
await ctx.message.delete()
await ctx.send("Word removed from banned words.")
else:
await ctx.send("Word isnt banned")
@commands.command()
async def addPoints(self, ctx, member: discord.Member, points):
ref = db.reference("Users")
Score = ref.child(str(member.id)).child('Ctzn_Score').get()
print(Score)
newScore = Score + int(points)
ref.update({
member.id:{
"Ctzn_Score": newScore
}
})
@commands.command()
async def removePoints(self, ctx, member: discord.Member, points):
ref = db.reference("Users")
Score = ref.child(str(member.id)).child('Ctzn_Score').get()
print(Score)
newScore = Score - int(points)
ref.update({
member.id:{
"Ctzn_Score": newScore
}
})
@commands.command()
async def setPoints(self, ctx, member: discord.Member, points):
ref = db.reference("Users")
Score = ref.child(str(member.id)).child('Ctzn_Score').get()
print(Score)
newScore = int(points)
ref.update({
member.id:{
"Ctzn_Score": newScore
}
})
@commands.command()
async def myPoints(self, ctx,):
member = ctx.message.author
ref = db.reference("Users")
Score = ref.child(str(member.id)).child('Ctzn_Score').get()
await ctx.send(f'Ni hao {member} the party got reports you have {Score} Points')
@commands.command()
async def checkDatabase(self, ctx):
names = list()
users = db.reference("Users").get()
for user in ctx.guild.members:
names.append(user.id)
for x in range(len(names)):
if names[x] not in users.values():
ref = db.reference(f"/Users")
ref.update({
names[x]:{
"Ctzn_Score": standart_Ctzn_Score
}
}
)
def setup(client):
client.add_cog(Reputation(client))