Skip to content

Commit 0ab11f3

Browse files
committed
add generic checks for every command
1 parent bc36d4c commit 0ab11f3

13 files changed

Lines changed: 145 additions & 236 deletions

File tree

cogs/database.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ async def on_message(self, message: discord.Message):
207207
@commands.hybrid_command()
208208
@commands.cooldown(1, 5, commands.BucketType.user)
209209
@commands.max_concurrency(1, commands.BucketType.user)
210+
@mf.generic_checks()
210211
async def rmessage(self, ctx):
211212
"""Send a random message."""
212213
async with self.client.session as session:
@@ -249,6 +250,7 @@ async def rmessage(self, ctx):
249250

250251
@commands.hybrid_command()
251252
@commands.cooldown(1, 10, commands.BucketType.user)
253+
@mf.generic_checks()
252254
async def conversation(self, ctx, number: int = 5):
253255
"""Generate a whole conversation between random users."""
254256
if number > 10:

cogs/economy.py

Lines changed: 51 additions & 225 deletions
Large diffs are not rendered by default.

cogs/example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ async def bot(self, ctx):
5050
await ctx.send(",human")
5151

5252
@commands.command(hidden=True)
53+
@mf.generic_checks(max_check=False)
5354
async def checkcommit(self, ctx):
5455
try:
5556
remote_url = (

cogs/fire.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from sqlalchemy import delete, select, update
99

1010
import models
11+
from utils.miscfuncs import generic_checks
1112

1213
bank = "./data/database.sqlite"
1314

@@ -153,6 +154,7 @@ async def on_ready(self):
153154
print("Fire ready")
154155

155156
@commands.hybrid_command()
157+
@generic_checks(max_check=False)
156158
async def howtofire(self, ctx):
157159
await ctx.send(
158160
"Create a channel named #fireboard, give me permission to talk there, and then I will automatically post messages with 5 :fire: reactions. Also, once a week I'll list the most fired messages."
@@ -308,6 +310,7 @@ async def on_raw_reaction_remove(self, payload):
308310
)
309311

310312
@commands.command(hidden=True)
313+
@generic_checks(max_check=False)
311314
async def unix(self, ctx):
312315
await ctx.send("The current unix time is `" + (str(int(t.time()))) + "`")
313316

@@ -398,6 +401,7 @@ async def getmessages(unix):
398401
await setfuckingdata(old)
399402

400403
@commands.hybrid_command()
404+
@generic_checks(max_check=False)
401405
async def highestfire(self, ctx, channel: discord.TextChannel = None):
402406
if not channel:
403407
async with self.client.session as session:
@@ -443,6 +447,7 @@ async def highestfire(self, ctx, channel: discord.TextChannel = None):
443447
)
444448

445449
@commands.hybrid_command()
450+
@generic_checks(max_check=False)
446451
async def highestunfire(self, ctx, channel: discord.TextChannel = None):
447452
if not channel:
448453
async with self.client.session as session:
@@ -488,6 +493,7 @@ async def highestunfire(self, ctx, channel: discord.TextChannel = None):
488493
)
489494

490495
@commands.hybrid_command()
496+
@generic_checks(max_check=False)
491497
async def fireleaderboard(self, ctx, fire: str | None = None):
492498
# get users, count fire for each, display on leaderboard
493499
if not fire:

cogs/fun.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ async def on_message(self, message):
4444
# commands
4545

4646
@commands.hybrid_command()
47+
@mf.generic_checks(max_check=False)
4748
async def ip(self, ctx, user: discord.Member = None):
4849
ip1 = random.randint(1, 255)
4950
ip2 = random.randint(0, 255)
@@ -58,6 +59,7 @@ async def ip(self, ctx, user: discord.Member = None):
5859
await ctx.send(f"{ip1}.{ip2}.{ip3}.{ip4}")
5960

6061
@commands.command(aliases=["8ball", "ask"], hidden=True)
62+
@mf.generic_checks(max_check=False)
6163
async def _8ball(self, ctx, *, question):
6264
if not question:
6365
return await ctx.send("Please ask a question.")
@@ -106,6 +108,7 @@ async def dm(self, ctx, user: discord.Member, *, message: str):
106108

107109
@commands.command()
108110
@commands.cooldown(1, 5, commands.BucketType.user)
111+
@mf.generic_checks(max_check=False)
109112
async def createpoll(self, ctx, amount: int = 0):
110113
"""Make a poll"""
111114
if amount > 10 or amount < 1:

cogs/image.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import aiohttp
44
from discord.ext import commands
55

6+
from utils.miscfuncs import generic_checks
7+
68

79
class Image(commands.Cog):
810
"""Commands that send images."""
@@ -14,6 +16,7 @@ def __init__(self, client):
1416
@commands.has_permissions(attach_files=True)
1517
@commands.cooldown(1, 1, commands.BucketType.default)
1618
@commands.max_concurrency(1, commands.BucketType.user, wait=True)
19+
@generic_checks(max_check=False)
1720
async def sans(self, ctx):
1821
"""The best command."""
1922
if rd.randint(1, 100) == 1:

cogs/moderation.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ async def on_guild_join(self, guild):
6666

6767
@commands.hybrid_command()
6868
@commands.has_permissions(moderate_members=True)
69+
@mf.generic_checks(max_check=False)
6970
async def timeout(self, ctx, member: discord.Member, length: int = 5):
7071
"""Timeout someone."""
7172
max_time = 2419200
@@ -81,6 +82,7 @@ async def timeout(self, ctx, member: discord.Member, length: int = 5):
8182
# commands
8283
@commands.hybrid_command()
8384
@commands.has_permissions(manage_messages=True)
85+
@mf.generic_checks(max_check=False)
8486
async def clear(self, ctx, amount=5 + 1):
8587
"""Clean messages."""
8688
await ctx.channel.purge(limit=amount)
@@ -117,6 +119,7 @@ async def messageban(self, ctx, member: discord.Member):
117119
await ctx.send("Done!")
118120

119121
@commands.hybrid_command()
122+
@mf.generic_checks(max_check=False)
120123
async def blacklistme(self, ctx, length: int = 0):
121124
if length < 0:
122125
await ctx.send(
@@ -167,13 +170,15 @@ async def blacklist(self, ctx, member: discord.Member, length: int = 0):
167170

168171
@commands.hybrid_command()
169172
@commands.has_permissions(ban_members=True)
173+
@mf.generic_checks(max_check=False)
170174
async def ban(self, ctx, member: discord.Member, *, reason=None):
171175
"""Ban someone."""
172176
await member.ban(reason=reason)
173177
await ctx.send("User has been banned")
174178

175179
@commands.hybrid_command()
176180
@commands.has_permissions(kick_members=True)
181+
@mf.generic_checks(max_check=False)
177182
async def kick(self, ctx, member: discord.Member, *, reason=None):
178183
"""Kick someone."""
179184
await member.kick(reason=reason)

cogs/osu.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ async def getrank(self, ctx, id):
188188

189189
@commands.hybrid_command()
190190
@commands.cooldown(1, 5, commands.BucketType.user)
191+
@mf.generic_checks()
191192
async def invest(self, ctx, osu_id: int = 0, amount: str | None = None):
192193
"""Invest in an osu player."""
193194
if osu_id == 0:
@@ -243,6 +244,7 @@ async def invest(self, ctx, osu_id: int = 0, amount: str | None = None):
243244

244245
@commands.hybrid_command()
245246
@commands.cooldown(1, 5, commands.BucketType.user)
247+
@mf.generic_checks()
246248
async def sell(self, ctx, id):
247249
"""Sell your investment on an osu player."""
248250
async with self.client.session as session:
@@ -275,6 +277,7 @@ async def sell(self, ctx, id):
275277

276278
@commands.hybrid_command(aliases=["investments", "checkinvestment"])
277279
@commands.cooldown(1, 5, commands.BucketType.user)
280+
@mf.generic_checks(max_check=False)
278281
async def checkinvestments(self, ctx, user: discord.User = None):
279282
"""Check your investments on osu players."""
280283
if not user:

cogs/stocks.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,10 @@ async def verify_stock_ticker(self, stock_ticker):
100100

101101
@commands.hybrid_command(aliases=["buystocks"])
102102
@commands.cooldown(5, 60, commands.BucketType.user)
103+
@mf.generic_checks()
103104
async def buystock(self, ctx, stock: str | None = None, amount: str | None = None):
104105
"""Purchase stocks from the REAL LIFE stock market"""
105106
open_market = await self.is_market_open()
106-
if await econ.checkmax(ctx.author):
107-
return await ctx.send(
108-
"You attempt to buy stocks but you can't. Maybe you should attempt to `,enterthecave`."
109-
)
110107
if not stock:
111108
return await ctx.send("Please provide a stock ticker")
112109
if not open_market:
@@ -142,13 +139,10 @@ async def buystock(self, ctx, stock: str | None = None, amount: str | None = Non
142139

143140
@commands.hybrid_command(aliases=["sellstocks"])
144141
@commands.cooldown(5, 60, commands.BucketType.user)
142+
@mf.generic_checks()
145143
async def sellstock(self, ctx, stock: str | None = None, amount: str | None = None):
146144
"""Sell stocks from the REAL LIFE stock market"""
147145
open_market = await self.is_market_open()
148-
if await econ.checkmax(ctx.author):
149-
return await ctx.send(
150-
"You attempt to sell stocks but you can't. Maybe you should attempt to `,enterthecave`."
151-
)
152146
if not stock:
153147
return await ctx.send("Please provide a stock ticker")
154148
if not open_market:
@@ -195,6 +189,7 @@ async def sellstock(self, ctx, stock: str | None = None, amount: str | None = No
195189

196190
@commands.hybrid_command()
197191
@commands.cooldown(5, 60, commands.BucketType.user)
192+
@mf.generic_checks()
198193
async def stockprice(self, ctx, stock: str | None = None):
199194
"""Find the price of a REAL LIFE stock"""
200195
if not stock:
@@ -215,6 +210,7 @@ async def stockprice(self, ctx, stock: str | None = None):
215210

216211
@commands.hybrid_command()
217212
@commands.cooldown(1, 60, commands.BucketType.user)
213+
@mf.generic_checks(max_check=False)
218214
async def portfolio(self, ctx, user: discord.Member = None):
219215
"""List all currently owned stocks"""
220216
if user is None:

cogs/theory.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
import anyio
44
from discord.ext import commands
55

6+
from utils.miscfuncs import generic_checks
7+
68

79
class theory(commands.Cog):
810
def __init__(self, client):
911
self.client = client
1012

1113
@commands.command(hidden=True)
14+
@generic_checks(max_check=False)
1215
async def theory(self, ctx, word=None):
1316
theories = ["Theory", "Theorem", "Method"]
1417
if not word:

0 commit comments

Comments
 (0)