├── README.md ├── config.json ├── data.json ├── main.py └── pingcount.json /README.md: -------------------------------------------------------------------------------- 1 | # Slot-Bot 2 | Discord Slot Bot 3 | 4 | 5 | ![image](https://github.com/mafiayt69/Slot-Bot/assets/91059034/e50b613c-e99b-4e82-bb59-451b1a4be168) 6 | 7 | ![image](https://github.com/mafiayt69/Slot-Bot/assets/91059034/461ef36c-8f01-4d3a-b528-dbfd7070f346) 8 | 9 | 10 | -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "staffrole": 123, 3 | "premiumeroleid": 123, 4 | "guildid": 123, 5 | "categoryid": 123 6 | } 7 | -------------------------------------------------------------------------------- /data.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import discord 2 | from discord.ext import commands , tasks 3 | import datetime 4 | import json 5 | import os 6 | from colorama import Fore 7 | intents = discord.Intents().all() 8 | bot = commands.Bot(command_prefix=',', intents = intents) 9 | bot.remove_command("help") 10 | 11 | 12 | @bot.event 13 | async def on_ready(): 14 | print(f"{bot.user.name} is Ready") 15 | await expire() 16 | 17 | with open("config.json", "r") as file: 18 | hmm = json.load(file) 19 | 20 | rid = hmm["premiumeroleid"] 21 | cid = hmm["categoryid"] 22 | staff = hmm["staffrole"] 23 | print(rid) 24 | @tasks.loop(hours=1) 25 | async def expire(): 26 | try: 27 | with open("data.json", "r") as file: 28 | data = json.load(file) 29 | except FileNotFoundError: 30 | data = [] 31 | 32 | nowtime = datetime.datetime.now() 33 | nt = nowtime.strftime("%Y%m%d") 34 | remove = [] 35 | 36 | for xd in data: 37 | for item in xd: 38 | slottime = item["endtime"] 39 | st = datetime.datetime.fromtimestamp(int(slottime)) 40 | print(st.strftime("%Y%m%d")) 41 | finalse = st.strftime("%Y%m%d") 42 | print(f"Slot end {finalse}") 43 | print(f"now time {nt}") 44 | print(nt >= finalse) 45 | 46 | if nt >= finalse: 47 | 48 | with open("data.json", "w") as file: 49 | json.dump(data, file, indent=4) 50 | 51 | channel = bot.get_channel(item["channelid"]) 52 | guild = bot.get_guild(int(hmm["guildid"])) 53 | member = guild.get_member(item["userid"]) 54 | 55 | 56 | 57 | if member and channel: 58 | print(member.id) 59 | await channel.send(f"Slot expired") 60 | role = discord.utils.get(guild.roles, id=rid) 61 | print(role) 62 | await member.remove_roles(role) 63 | await channel.set_permissions(member, send_messages=False) 64 | print(xd) 65 | data.remove(xd) 66 | with open("./data.json","w") as nice: 67 | json.dump(data, nice,indent=4) 68 | 69 | 70 | 71 | @bot.event 72 | async def on_message(message): 73 | await bot.process_commands(message) 74 | category = discord.utils.get(message.guild.categories, id=int(cid)) 75 | if category: 76 | if "@here" in message.content: 77 | try: 78 | with open("pingcount.json", "r") as file: 79 | data = json.load(file) 80 | except FileNotFoundError: 81 | data = [] 82 | 83 | print(message.channel.id) 84 | print(data) 85 | nice = False 86 | if not data: 87 | dataz = { 88 | "channelid": message.channel.id, 89 | "time": datetime.datetime.now().timestamp(), 90 | "count": 2 91 | } 92 | data.append(dataz) 93 | with open("pingcount.json", "w") as file: 94 | json.dump(data, file, indent=4) 95 | await message.channel.send("1/2") 96 | return 97 | for c in data: 98 | print(c) 99 | if message.channel.id == c["channelid"]: 100 | nice = True 101 | print(c["time"]) 102 | print(datetime.datetime.now().timestamp()) 103 | nowt = datetime.datetime.now().timestamp() 104 | slotdata = int(c["time"]) 105 | print(slotdata) 106 | sl = datetime.datetime.fromtimestamp(slotdata) 107 | slot = sl.strftime("%Y%m%d") 108 | cx = datetime.datetime.now() 109 | print(cx.timestamp()) 110 | nowtime = cx.strftime("%Y%m%d") 111 | 112 | 113 | if slot == nowtime: 114 | xxx = c["count"] 115 | if c["count"] >= 3: 116 | channel = bot.get_channel(c["channelid"]) 117 | await channel.set_permissions(message.author, send_messages=False) 118 | await message.channel.send("3/2 Slot Revoked <@&your staff role id>\n**Reason:** 3 here ping") 119 | return 120 | c["count"] = c["count"] + 1 121 | await message.channel.send(f"{xxx}/{xxx}") 122 | with open("pingcount.json", "w") as file: 123 | json.dump(data, file, indent=4) 124 | return 125 | else: 126 | c["time"] = datetime.datetime.now().timestamp() 127 | c["count"] = 2 128 | with open("pingcount.json", "w") as file: 129 | json.dump(data, file, indent=4) 130 | await message.channel.send("1/2") 131 | if not nice: 132 | datazx = { 133 | "channelid": message.channel.id, 134 | "time": datetime.datetime.now().timestamp(), 135 | "count": 2 136 | } 137 | data.append(datazx) 138 | with open("pingcount.json", "w") as file: 139 | json.dump(data, file, indent=4) 140 | await message.channel.send("1/2") 141 | 142 | 143 | 144 | 145 | 146 | 147 | @bot.command() 148 | async def help(ctx): 149 | embed = discord.Embed(description="**,create** - Use To Create Slot\n**,add** - Use To Add User In Slot\n**,remove** - Use To Remove User In SLot\n**,renew** - Use To Renew Slot",color=0xFFFF00) 150 | embed.set_thumbnail(url=ctx.guild.icon) 151 | embed.set_author(name="Slot Bot Help Menu") 152 | await ctx.send(embed=embed,delete_after=30) 153 | 154 | @bot.command() 155 | @commands.has_role(int(staff)) 156 | async def add(ctx,member: discord.Member=None, channel: discord.TextChannel = None): 157 | 158 | rr = [] 159 | 160 | with open("./data.json","r") as rr: 161 | rr = json.load(rr) 162 | 163 | ftf = False 164 | 165 | for x in rr: 166 | for xx in x: 167 | if (xx["channelid"] == channel.id): 168 | ftf = True 169 | 170 | if (ftf == False): 171 | await ctx.send("Slot Not In DataBase") 172 | return 173 | 174 | 175 | 176 | 177 | 178 | 179 | if (member == False): 180 | await ctx.reply("Member Not Found") 181 | 182 | if (channel == False): 183 | await ctx.reply("Channel Not Found") 184 | 185 | await channel.set_permissions(member,view_channel=True, send_messages=True,mention_everyone=True) 186 | await ctx.reply("successfully Added") 187 | 188 | @bot.command() 189 | @commands.has_role(int(staff)) 190 | async def renew(ctx,member: discord.Member = None,channel: discord.TextChannel=None,yoyo: int = None,cx=None): 191 | 192 | 193 | rr = [] 194 | 195 | with open("./data.json","r") as rr: 196 | rr = json.load(rr) 197 | 198 | ftf = False 199 | 200 | for x in rr: 201 | for xx in x: 202 | if (xx["channelid"] == channel.id): 203 | ftf = True 204 | 205 | if (ftf == False): 206 | await ctx.send("Slot Not In DataBase") 207 | return 208 | 209 | print("ru") 210 | if (member == None): 211 | await ctx.reply("Member Not Found") 212 | return 213 | 214 | if (channel == None): 215 | await ctx.reply("Channel Not Found") 216 | return 217 | 218 | if (cx.lower() == "d"): 219 | yoyo = (yoyo * 24 * 60 * 60) + datetime.datetime.now().timestamp() 220 | elif (cx.lower() == "m"): 221 | yoyo = (yoyo * 30 * 24 * 60 * 60) + datetime.datetime.now().timestamp() 222 | else: 223 | await ctx.reply("Use valid Formate: ,add @user 1 m his Slot") 224 | 225 | await channel.set_permissions(member,view_channel=True,send_messages=True,mention_everyone=True) 226 | role = discord.utils.get(ctx.guild.roles, id=int(rid)) 227 | await member.add_roles(role) 228 | print("ruw") 229 | async for message in channel.history(limit=1000): 230 | await message.delete() 231 | dataz = { 232 | "endtime": yoyo, 233 | "userid": member.id, 234 | "channelid": channel.id 235 | }, 236 | try: 237 | with open("data.json", "r") as file: 238 | data = json.load(file) 239 | except FileNotFoundError: 240 | data = [] 241 | data.append(dataz) 242 | with open("data.json", "w") as file: 243 | json.dump(data, file,indent=4) 244 | 245 | embed = discord.Embed(description="""Your Slot Rules""",color=0xFFFF00) 246 | 247 | embed.set_author(name="Slot Rules") 248 | embed.set_thumbnail(url=f"{ctx.guild.icon}") 249 | 250 | await channel.send(embed=embed) 251 | embed = discord.Embed(description=f'**Slot Owner:** {member.mention}\n**End:** ',color=0xFFFF00) 252 | embed.set_footer(text=ctx.guild.name) 253 | embed.set_author(name=member) 254 | await channel.send(embed=embed) 255 | await ctx.reply(f"successfully renew Slot {channel.mention}") 256 | 257 | 258 | @bot.command() 259 | @commands.has_role(int(staff)) 260 | async def remove(ctx,member: discord.Member=None, channel: discord.TextChannel = None): 261 | 262 | rr = [] 263 | 264 | with open("./data.json","r") as rr: 265 | rr = json.load(rr) 266 | 267 | ftf = False 268 | 269 | for x in rr: 270 | for xx in x: 271 | if (xx["channelid"] == channel.id): 272 | ftf = True 273 | 274 | if (ftf == False): 275 | await ctx.send("Slot Not In DataBase") 276 | return 277 | 278 | if (member == False): 279 | await ctx.reply("Member Not Found") 280 | 281 | if (channel == False): 282 | await ctx.reply("Channel Not Found") 283 | 284 | await channel.set_permissions(member, send_messages=True,mention_everyone=False) 285 | await ctx.reply("successfully removed") 286 | 287 | 288 | @bot.command() 289 | @commands.has_role(int(staff)) 290 | async def revoke(ctx,member: discord.Member=None, channel: discord.TextChannel = None): 291 | 292 | rr = [] 293 | 294 | with open("./data.json","r") as rr: 295 | rr = json.load(rr) 296 | 297 | ftf = False 298 | 299 | for x in rr: 300 | for xx in x: 301 | if (xx["channelid"] == channel.id): 302 | ftf = True 303 | 304 | if (ftf == False): 305 | await ctx.send("Slot Not In DataBase") 306 | return 307 | 308 | if (member == False): 309 | await ctx.reply("Member Not Found") 310 | 311 | if (channel == False): 312 | await ctx.reply("Channel Not Found") 313 | 314 | await channel.set_permissions(member, send_messages=True,mention_everyone=False) 315 | await ctx.reply("successfully removed") 316 | 317 | 318 | 319 | @bot.command() 320 | @commands.has_role(int(staff)) 321 | async def create(ctx,member: discord.Member=None,yoyo: int = None,cx=None,*,x=None): 322 | 323 | if member == None: 324 | await ctx.reply("User Not Found") 325 | return 326 | 327 | if yoyo == None: 328 | await ctx.reply("Use valid Formate: ,add @user 1 m his Slot") 329 | return 330 | 331 | if cx == None: 332 | await ctx.reply("Use valid Formate: ,add @user 1 m his Slot") 333 | return 334 | 335 | 336 | if (x == None): 337 | x = member.display_name 338 | 339 | overwrites = { 340 | ctx.guild.default_role: discord.PermissionOverwrite(view_channel=True,send_messages=False), 341 | member: discord.PermissionOverwrite(view_channel=True,send_messages=True,mention_everyone=True) 342 | } 343 | 344 | 345 | 346 | category = discord.utils.get(ctx.guild.categories, id=int(cid)) 347 | 348 | a = await ctx.guild.create_text_channel(x,category=category,overwrites=overwrites) 349 | 350 | await a.set_permissions(ctx.guild.default_role, send_messages=False) 351 | role = discord.utils.get(ctx.author.guild.roles, id=int(rid)) 352 | await member.add_roles(role) 353 | 354 | embed = discord.Embed(description="""Your Slot Rules *""",color=0xFFFF00) 355 | 356 | embed.set_author(name="Slot Rules") 357 | embed.set_thumbnail(url=ctx.guild.icon) 358 | 359 | await a.send(embed=embed) 360 | 361 | if (cx.lower() == "d"): 362 | yoyo = (yoyo * 24 * 60 * 60) + datetime.datetime.now().timestamp() 363 | elif (cx.lower() == "m"): 364 | yoyo = (yoyo * 30 * 24 * 60 * 60) + datetime.datetime.now().timestamp() 365 | else: 366 | await ctx.reply("Use valid Formate: ,add @user 1 m his Slot") 367 | 368 | embed = discord.Embed(description=f'**Slot Owner:** {member.mention}\n**End:** ',color=0xFFFF00) 369 | embed.set_footer(text=ctx.guild.name) 370 | embed.set_author(name=member) 371 | await a.send(embed=embed) 372 | await ctx.reply(f"successfully Create Slot {a.mention}") 373 | dataz = { 374 | "endtime": yoyo, 375 | "userid": member.id, 376 | "channelid": a.id 377 | }, 378 | try: 379 | with open("data.json", "r") as file: 380 | data = json.load(file) 381 | except FileNotFoundError: 382 | data = [] 383 | data.append(dataz) 384 | 385 | with open("data.json", "w") as file: 386 | json.dump(data, file,indent=4) 387 | 388 | bot.run("Your bot Token") 389 | -------------------------------------------------------------------------------- /pingcount.json: -------------------------------------------------------------------------------- 1 | [] 2 | --------------------------------------------------------------------------------