This repository has been archived by the owner on Mar 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
disc.py
204 lines (143 loc) · 6.53 KB
/
disc.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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
import discord
from discord.ext import commands
import requests
from points import pointSystem
from tierscore import ProblemTracker
import random
from webscraper import Webscraper
image_path = "./worldMap.jpg"
image_path2 = "./tier2.jpg"
image_path3 = "./portal.jpg"
user_id = ''
#problemtracker = ProblemTracker(userName)
leet_dict = {}
marketplace = {
100: ['axe', 'bows', 'sword', 'dagger'],
200: ['poison potion', 'health potion', 'strength potion'],
300: ['chespiece', 'helmet', 'pants', 'boots'],
1000: ['todoro']
}
# Define your intents
intents = discord.Intents.default()
# Enable specific intents based on your needs
intents.message_content = True
intents.guilds = True
# Add more intents as needed
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.command(name='beginjourney')
async def beginjourney(ctx, leetcode_username):
global user_id
user_id = ctx.author.id
# Store the LeetCode username in the dictionary
leet_dict[user_id] = leetcode_username
problemTracker = ProblemTracker(leetcode_username)
leetcode_score = problemTracker.calculate_user_score()
leetcode_tier = problemTracker.calculate_user_tier()
array = list()
array.append(leetcode_username)
array.append(leetcode_score)
array.append(leetcode_tier)
array.append(list())
leet_dict[user_id] = array
await ctx.send(f"LeetCode username set for {ctx.author.name}: {leetcode_username}")
await ctx.send(f"Youre score is {leetcode_score}")
await ctx.send(" In the mystical world of Algol, where coding is the language of power, an ancient order known as the Guild of Developers has maintained the balance between magic and technology. However, an evil force, the NullByte Sorcerer, has emerged, threatening to plunge Algol into chaos by corrupting the very fabric of code.\n\n As the chosen one, a skilled programmer, you embark on a heroic journey to restore order to Algol and defeat the NullByte Sorcerer. To do so, you must venture through the CodeQuest, a series of dungeons filled with coding challenges that test your programming skills and problem-solving abilities.")
await ctx.send(file=discord.File(image_path))
print(leet_dict)
@bot.command(name='checkXP')
async def checkXP(ctx):
arr = leet_dict[user_id]
await ctx.send(f"XP: {arr[1]}")
@bot.command(name='checkRank')
async def checkRank(ctx):
arr = leet_dict[user_id]
await ctx.send(f"Rank: {arr[2]}")
@bot.command(name='item')
async def item(ctx):
array9 = leet_dict[user_id]
array = array9[3]
if leet_dict[user_id][1] >= 1000:
array2 = marketplace[1000]
array.append(array2[0])
elif leet_dict[user_id][1] >= 300:
array3 = marketplace[300]
array.append(array3[random.randint(0,len(array3[2]))])
elif leet_dict[user_id][1] >= 200:
array4 = marketplace[200]
array.append(array4[random.randint(0,len(array4[1]))])
elif leet_dict[user_id][1] >= 100:
array5 = marketplace[100]
array.append(array5[random.randint(0,len(array5[0]))])
await ctx.send(f"You recieved item: {array[0]}")
@bot.command(name='leetcode')
async def leetcode(ctx):
# Fetch a random LeetCode problem using LeetCode API or a web scraping library
leetcode_problem = get_random_leetcode_problem()
# Send the problem to the Discord channel
await ctx.send(f"**LeetCode Problem:**\n\n{leetcode_problem}")
@bot.command(name='profile')
async def profile(ctx):
arr = leet_dict[user_id]
await ctx.send(f"Tier: {arr[2]}")
await ctx.send(f"XP: {arr[1]} ")
def get_random_leetcode_problem():
# Implement logic to fetch a random LeetCode problem
# You can use the LeetCode API or scrape the LeetCode website
# Make sure to format the problem nicely
# Example using LeetCode API (replace with your own logic):
response = requests.get('https://leetcode.com/api/problems/algorithms/')
problem_data = response.json()
random_problem = problem_data['stat_status_pairs'][0]['stat']['question__title']
return random_problem
@bot.command(name='solve')
async def solve(ctx, solution):
# Validate the solution (replace with your own validation logic)
is_solution_correct = validate_solution(solution)
# Provide feedback to the user
if is_solution_correct:
await ctx.send("Congratulations! Your solution is correct.")
else:
await ctx.send("Oops! Your solution is incorrect. Try again!")
def validate_solution(solution):
# Implement logic to validate the user's solution
# You may compare it with the correct answer or use other methods
# Return True if the solution is correct, False otherwise
# Example (replace with your own validation logic):
correct_answer = "42"
return solution == correct_answer
@bot.command(name='LevelUp')
async def LevelUp(ctx):
array = leet_dict[user_id]
problemTracker = ProblemTracker(array[0])
level = array[2] + 1
if array[2]== problemTracker.calculate_user_tier():
await ctx.send("Step into the JavaScript Junction, where each line of code is a melody and every function is a dance.\n\n Explore the vibrant crossroads of web development, where promises and callbacks pave the way for your JavaScript adventure!")
await ctx.send(file=discord.File(image_path2))
array[1] = problemTracker.calculate_user_score()
array[2] = problemTracker.calculate_user_tier()
newDic = problemTracker.returnDic()
problemArray = newDic[level]
problem_links = ""
for i in problemArray:
problem_name=i
problem_link = f"https://leetcode.com/problems/{problem_name.lower().replace(' ', "-")}/description"
problem_links += f"[{problem_name}]({problem_link})\n"
await ctx.send(f"{problem_links}")
@bot.command(name='getProblem')
async def getProblem(ctx, nameProblem):
await ctx.send(file=discord.File(image_path3))
await ctx.send("WOAH what’s happening? \n\n *....teleporting to new dungeon…* …")
problem_links = ""
problem_name=nameProblem
problem_link = f"https://leetcode.com/problems/{problem_name.lower().replace(' ', "-")}/description"
problem_links += f"[{problem_name}]({problem_link})\n"
await ctx.send(f"{problem_links}")
@bot.command(name='suggest')
async def suggest(ctx):
array = leet_dict[user_id]
problemTracker = ProblemTracker(array[0])
for i in range(5):
difficulty = problemTracker.returndifficulty()
suggestion = problemTracker.suggest_problems(i,difficulty)
await ctx.send(f"{suggestion}")
bot.run('')