33Description:
44This is a template to create your own discord bot in python.
55
6- Version: 3.0
6+ Version: 3.1
77"""
88
99import json
1818from discord_slash import cog_ext , SlashContext
1919from discord_slash .utils .manage_commands import create_option
2020
21+ from helpers import checks
22+
2123if not os .path .isfile ("config.json" ):
2224 sys .exit ("'config.json' not found! Please add it and try again." )
2325else :
2426 with open ("config.json" ) as file :
2527 config = json .load (file )
2628
2729
28- class general (commands .Cog , name = "general" ):
30+ class General (commands .Cog , name = "general" ):
2931 def __init__ (self , bot ):
3032 self .bot = bot
3133
3234 @cog_ext .cog_slash (
3335 name = "botinfo" ,
3436 description = "Get some useful (or not) information about the bot." ,
3537 )
38+ @checks .not_blacklisted ()
3639 async def botinfo (self , context : SlashContext ):
3740 """
3841 Get some useful (or not) information about the bot.
3942 """
40-
41- # This is, for now, only temporary
42- with open ("blacklist.json" ) as file :
43- blacklist = json .load (file )
44- if context .author .id in blacklist ["ids" ]:
45- return
46-
4743 embed = discord .Embed (
48- description = "Used Krypton's template" ,
44+ description = "Used [ Krypton's](https://krypt0n.co.uk) template" ,
4945 color = 0x42F56C
5046 )
5147 embed .set_author (
@@ -63,7 +59,7 @@ async def botinfo(self, context: SlashContext):
6359 )
6460 embed .add_field (
6561 name = "Prefix:" ,
66- value = f"{ config [ 'bot_prefix' ] } " ,
62+ value = f"/ (Slash Commands) " ,
6763 inline = False
6864 )
6965 embed .set_footer (
@@ -75,17 +71,11 @@ async def botinfo(self, context: SlashContext):
7571 name = "serverinfo" ,
7672 description = "Get some useful (or not) information about the server." ,
7773 )
74+ @checks .not_blacklisted ()
7875 async def serverinfo (self , context : SlashContext ):
7976 """
8077 Get some useful (or not) information about the server.
8178 """
82-
83- # This is, for now, only temporary
84- with open ("blacklist.json" ) as file :
85- blacklist = json .load (file )
86- if context .author .id in blacklist ["ids" ]:
87- return
88-
8979 server = context .guild
9080 roles = [x .name for x in server .roles ]
9181 role_length = len (roles )
@@ -130,18 +120,13 @@ async def serverinfo(self, context: SlashContext):
130120 @cog_ext .cog_slash (
131121 name = "ping" ,
132122 description = "Check if the bot is alive." ,
123+ guild_ids = [909709618681364531 ]
133124 )
125+ @checks .not_blacklisted ()
134126 async def ping (self , context : SlashContext ):
135127 """
136128 Check if the bot is alive.
137129 """
138-
139- # This is, for now, only temporary
140- with open ("blacklist.json" ) as file :
141- blacklist = json .load (file )
142- if context .author .id in blacklist ["ids" ]:
143- return
144-
145130 embed = discord .Embed (
146131 title = "🏓 Pong!" ,
147132 description = f"The bot latency is { round (self .bot .latency * 1000 )} ms." ,
@@ -153,17 +138,11 @@ async def ping(self, context: SlashContext):
153138 name = "invite" ,
154139 description = "Get the invite link of the bot to be able to invite it." ,
155140 )
141+ @checks .not_blacklisted ()
156142 async def invite (self , context : SlashContext ):
157143 """
158144 Get the invite link of the bot to be able to invite it.
159145 """
160-
161- # This is, for now, only temporary
162- with open ("blacklist.json" ) as file :
163- blacklist = json .load (file )
164- if context .author .id in blacklist ["ids" ]:
165- return
166-
167146 embed = discord .Embed (
168147 description = f"Invite me by clicking [here](https://discordapp.com/oauth2/authorize?&client_id={ config ['application_id' ]} &scope=bot&permissions=470150263)." ,
169148 color = 0xD75BF4
@@ -179,17 +158,11 @@ async def invite(self, context: SlashContext):
179158 name = "server" ,
180159 description = "Get the invite link of the discord server of the bot for some support." ,
181160 )
161+ @checks .not_blacklisted ()
182162 async def server (self , context : SlashContext ):
183163 """
184164 Get the invite link of the discord server of the bot for some support.
185165 """
186-
187- # This is, for now, only temporary
188- with open ("blacklist.json" ) as file :
189- blacklist = json .load (file )
190- if context .author .id in blacklist ["ids" ]:
191- return
192-
193166 embed = discord .Embed (
194167 description = f"Join the support server for the bot by clicking [here](https://discord.gg/mTBrXyWxAF)." ,
195168 color = 0xD75BF4
@@ -212,17 +185,11 @@ async def server(self, context: SlashContext):
212185 )
213186 ],
214187 )
188+ @checks .not_blacklisted ()
215189 async def poll (self , context : SlashContext , title : str ):
216190 """
217191 Create a poll where members can vote.
218192 """
219-
220- # This is, for now, only temporary
221- with open ("blacklist.json" ) as file :
222- blacklist = json .load (file )
223- if context .author .id in blacklist ["ids" ]:
224- return
225-
226193 embed = discord .Embed (
227194 title = "A new poll has been created!" ,
228195 description = f"{ title } " ,
@@ -248,17 +215,11 @@ async def poll(self, context: SlashContext, title: str):
248215 )
249216 ],
250217 )
218+ @checks .not_blacklisted ()
251219 async def eight_ball (self , context : SlashContext , question : str ):
252220 """
253221 Ask any question to the bot.
254222 """
255-
256- # This is, for now, only temporary
257- with open ("blacklist.json" ) as file :
258- blacklist = json .load (file )
259- if context .author .id in blacklist ["ids" ]:
260- return
261-
262223 answers = ['It is certain.' , 'It is decidedly so.' , 'You may rely on it.' , 'Without a doubt.' ,
263224 'Yes - definitely.' , 'As I see, yes.' , 'Most likely.' , 'Outlook good.' , 'Yes.' ,
264225 'Signs point to yes.' , 'Reply hazy, try again.' , 'Ask again later.' , 'Better not tell you now.' ,
@@ -278,17 +239,11 @@ async def eight_ball(self, context: SlashContext, question: str):
278239 name = "bitcoin" ,
279240 description = "Get the current price of bitcoin." ,
280241 )
242+ @checks .not_blacklisted ()
281243 async def bitcoin (self , context ):
282244 """
283245 Get the current price of bitcoin.
284246 """
285-
286- # This is, for now, only temporary
287- with open ("blacklist.json" ) as file :
288- blacklist = json .load (file )
289- if context .author .id in blacklist ["ids" ]:
290- return
291-
292247 url = "https://api.coindesk.com/v1/bpi/currentprice/BTC.json"
293248 # Async HTTP request
294249 async with aiohttp .ClientSession () as session :
@@ -304,4 +259,4 @@ async def bitcoin(self, context):
304259
305260
306261def setup (bot ):
307- bot .add_cog (general (bot ))
262+ bot .add_cog (General (bot ))
0 commit comments