This repository has been archived by the owner on Jul 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flag.py
70 lines (59 loc) · 1.92 KB
/
flag.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
import discord
from discord.ext import commands, tasks
import string
import json
import requests
import sys
import time
import help_info
def in_dms():
async def tocheck(ctx):
# A check for ctf context specific commands
if str(ctx.channel.type) == "private":
return True
else:
await ctx.send("This command is only available over DM!")
return False
return commands.check(tocheck)
def in_channel():
async def tocheck(ctx):
# A check for ctf context specific commands
if not str(ctx.channel.type) == "private":
return True
else:
await ctx.send("This command is not available over DM!")
return False
return commands.check(tocheck)
class Flag(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.group()
async def flag(self, ctx):
if ctx.invoked_subcommand is None:
await ctx.channel.send("Invalid command. Run `>help flag` for information on **flag** commands.")
@flag.command()
@in_channel()
async def printflag(self, ctx):
await ctx.channel.send("chungus is dissapointed")
@flag.command()
@in_channel()
async def rr(self, ctx):
await ctx.channel.send("<https://bit.ly/1NbiVPe>")
@flag.command()
@in_dms()
async def yeeee(self, ctx):
tic = time.perf_counter()
try:
f = open(f'userfiles/{ctx.author.name}_time', 'r')
stuff = f.read()
count = len(stuff.split('\n'))
if count == 2:
f = open(f'userfiles/{ctx.author.name}_time', 'a')
f.write(f'{tic}\n')
else:
await ctx.channel.send("Uh ohhh (count not 2)")
except:
await ctx.channel.send("Uh ohhh (no file)")
#################################### SETUP #####################################
def setup(bot):
bot.add_cog(Flag(bot))