1
1
import asyncio
2
2
import datetime
3
- import sys
4
- import traceback
5
- import typing
6
3
7
4
import disnake
8
5
import humanfriendly
9
6
import pymongo
10
- import topgg
7
+ # import topgg
11
8
from async_timeout import timeout
12
9
from disnake .ext import commands , tasks
13
10
from dotenv import dotenv_values
14
- from statcord import StatcordClient
11
+ # from statcord import StatcordClient
15
12
16
13
token = dotenv_values (".env" )["DISCORD" ]
17
14
upsince = datetime .datetime .now ()
35
32
role_menus = db .role_menus
36
33
polls = db .polls
37
34
38
- def create_role_menu (guild_id : int , channel_id : int , message_id : int , roles : list ):
39
- data = {
40
- "guild_id" : guild_id ,
41
- "channel_id" : channel_id ,
42
- "message_id" : message_id ,
43
- "roles" : roles
44
- }
45
- if role_menus .find_one ({"message_id" : message_id }) != None :
46
- return False
47
- role_menus .insert_one (data )
48
- return True
49
-
50
- def create_poll (guild_id : int , message_id : int , options : list ):
51
- data = {
52
- "guild_id" : guild_id ,
53
- "channel_id" : channel_id ,
54
- "message_id" : message_id ,
55
- "votes" : []
56
- }
57
- if polls .find_one ({"message_id" : message_id }) != None :
58
- return False
59
- polls .insert_one (data )
60
- return True
35
+ bot .load_extension ("extesions/polls" )
36
+ bot .load_extension ("extesions/rolemenus" )
37
+ # bot.load_extension("extesions/lno")
61
38
62
39
class Tasks (commands .Cog ):
63
40
@@ -173,92 +150,11 @@ async def info(inter: disnake.ApplicationCommandInteraction):
173
150
)
174
151
await inter .send (content = None , embed = embed , view = InfoButtons ())
175
152
176
- class PollDropdown (disnake .ui .Select ):
177
- def __init__ (self , poll_options , title , min_choices , max_choices ):
178
- self .options = []
179
- self .votes = polls .find_one () #TODO
180
- self .total_votes = []
181
- for count , i in enumerate (poll_options ):
182
- vote_count = votes [count ]
183
- self .options .append (disnake .SelectOption (
184
- label = i ,
185
- description = f"{ votes } vote{ '' if len (vote_count ) == 1 else 's' } "
186
- ))
187
- super ().__init__ (
188
- placeholder = title ,
189
- min_values = min_choices ,
190
- max_values = max_choices ,
191
- options = self .options ,
192
- )
193
- async def callback (inter : disnake .MessageInteraction ):
194
- for i in self .values :
195
- self .votes [i ] += 1
196
- embed = discord .Embed (title = title , description = f"Total votes: { self .total_votes } " )
197
- for count , i in enumerate (self .options ):
198
- blocks_filled = "🟦" * int ((self .votes [count ]/ self .total_votes )* 10 )
199
- blocks_empty = "⬜" * int ((10 - (self .votes [count ]/ self .total_votes ))* 10 )
200
- embed .add_field (
201
- name = i ,
202
- value = f"{ blocks_filled } { blocks_empty } ({ self .votes [count ]} )"
203
- )
204
- await inter .response .edit_message (embed = embed )
205
-
206
- class PollView (disnake .ui .View ):
207
- def __init__ (self , poll_options , title , min_choices , max_choices ):
208
- super ().__init__ ()
209
- self .add_item (SinglePollDropdown (poll_options , title , min_choices , max_choices ))
210
-
211
- @bot .slash_command (description = "Make a poll. Seperate each option with a comma." )
212
- async def poll (
213
- inter : disnake .ApplicationCommandInteraction ,
214
- title : str ,
215
- options : str ,
216
- min_choices = commands .Param (default = 1 , ge = 1 , le = 24 ),
217
- max_choices = commands .Param (default = 1 , ge = 1 , le = 25 )):
218
- poll_options = options .split ("," )[:25 ]
219
- [i .strip () for i in poll_options ]
220
- [i [:25 ] for i in poll_options ]
221
- create_poll (inter .guild .id , inter .channel .id , inter .id )
222
- embed = discord .Embed (title = title )
223
- for i in options :
224
- embed .add_field (
225
- name = i ,
226
- value = "⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜ (0)"
227
- )
228
- await inter .send (content = None , embed = embed , view = SinglePollView (poll_options , title , min_choices , max_choices ))
229
-
230
- ###
231
-
232
- def has_role_permissions ():
233
- pass
234
-
235
- @bot .slash_command (description = "Make a role menu. Use /add_role_to_menu to add more roles." )
236
- async def role_menu (inter : disnake .ApplicationCommandInteraction , title : str , description : str = None ):
237
- pass
238
-
239
- @bot .slash_command (description = "Adds a role to a role menu." )
240
- async def add_role_to_menu (inter : disnake .ApplicationCommandInteraction , message_id : int , role : disnake .Role , emoji : disnake .Emoji = None ):
241
- pass
242
-
243
- @bot .slash_command (description = "Removes a role to a role menu." )
244
- async def remove_role_from_menu (inter : disnake .ApplicationCommandInteraction , message_id : int , position : int = commands .Param (ge = 1 , le = 25 )):
245
- pass
246
-
247
- @bot .slash_command (description = "Makes a role button message." )
248
- async def role_button (
249
- inter : disnake .ApplicationCommandInteraction ,
250
- role : disnake .Role ,
251
- message_title : str ,
252
- button_color : str = commands .Param (choices = ["Blurple" , "Gray" , "Green" , "Red" ]),
253
- message_description : str = None ,
254
- button_emoji : disnake .Emoji = None ):
255
- pass
256
-
257
153
bot .remove_command ("help" )
258
154
bot .add_cog (Tasks (bot ))
259
155
260
156
@bot .event
261
157
async def on_ready ():
262
158
print ("-----\n Ready\n -----\n " )
263
159
264
- bot .run (token )
160
+ bot .run (token )
0 commit comments