/ OldVersions / Automatisierung 1.2.0.py
Automatisierung 1.2.0.py
1 #!/usr/bin/python3 2 import discord,random 3 from discord.ext import commands, tasks 4 from discord.utils import get 5 6 TOKEN = "Token lol" 7 GUILD = "The New Server Server" 8 9 #Enable events: 10 intents = discord.Intents.all() 11 #Create a function to do things: 12 bot = commands.Bot(command_prefix = "Fish ", intents = intents) 13 global MessageListImportant, ThroneRoomActive 14 MessageListImportant = [] 15 RoleHeigherarchy = ["Citizenry","Good Lad","Count","Duke","Regent","Head Regent","King"] 16 RoleHeigherarchy2 = ["Citizenry","Good Lady","Countess","Duchess","Regent","Head Regent","King"] 17 ThroneRoomActive = False 18 19 async def RoleGetter(Member,RoleNeeded): 20 Cleared = False 21 for role in Member.roles: 22 if role.name != RoleNeeded: 23 Cleared = False 24 else: 25 Cleared = True 26 break 27 return Cleared 28 29 @bot.event 30 async def on_ready(): 31 global Guild, ThroneRoom, Announcements, AdminBotChannel 32 Guild = get(bot.guilds, name = GUILD) 33 Channels = await Guild.fetch_channels() 34 35 for channel in Channels: 36 if channel.name == "throne-room": 37 ThroneRoom = channel 38 elif channel.name == "announcements": 39 Announcements = channel 40 elif channel.name == "admin-bots": 41 AdminBotChannel = channel 42 43 StatusChangeLoop.start() 44 45 @tasks.loop(hours = 196) 46 async def ThroneRoomLoop(): 47 Active = True 48 if ThroneRoomLoop.current_loop == 0: 49 Active = True 50 elif (ThroneRoomLoop.current_loop % 2) == 0: 51 Active = True 52 else: 53 Active = False 54 55 for Role in Guild.roles: 56 if Role.name == RoleHeigherarchy[0]: 57 Citizenry = Role 58 59 if Active: 60 await ThroneRoom.purge() 61 #await ThroneRoom.set_permissions(Citizenry, view_channel = True) 62 #await ThroneRoom.send("Use the command `Fish Title` to automatically request the rank higher than you are currently at. You must have the Good Lad/Lady rank to request higher ranks. You can use `Fish Title help` to get more help.") 63 #MessageToDelete = await Announcements.send(ThroneRoom.mention + " is now open all yall!") 64 else: 65 #await ThroneRoom.set_permissions(Citizenry, view_channel = False) 66 #MessageToDelete = await Announcements.send(ThroneRoom.mention + " has closed. Voting will be held and results will be announced soon.") 67 68 for member in Guild.members: 69 Cleared = False 70 for role in member.roles: 71 if role.name == RoleHeigherarchy[0]: 72 Cleared = True 73 elif role.name == RoleHeigherarchy[1] or role.name == RoleHeigherarchy2[1]: 74 Cleared = False 75 76 if Cleared: 77 Message = await ThroneRoom.send("Grant " + member.mention + " the Good Lad/Lady role?") 78 Data = {"Message":Message,"Role":Citizenry} 79 MessageListImportant.append(Data) 80 81 for message in MessageListImportant: 82 await message["Message"].add_reaction("👍") 83 await message["Message"].add_reaction("👎") 84 85 #await MessageToDelete.delete(delay = 345600) 86 ThroneRoomActive = Active 87 88 @tasks.loop(hours = 24) 89 async def StatusChangeLoop(): 90 Options = ["I spent way too much time on this","I should get a life","Why do I do all the grunt work?","Pedro for president 2024!",\ 91 "Minecraft","Can I earn money doing this?","Earth is fine, people are dumb",\ 92 "Everyone should be able to do one card trick, tell two jokes, and recite three poems, in case they are ever trapped in an elevator",\ 93 "Bruh","When a bird hits your window have you ever wondered if God is playing angry birds with you?",\ 94 "When I’m on my death bed, I want my final words to be “I left one million dollars in the…",\ 95 "My study period = 15 minutes. My break time = 3 hours","Never make eye contact while eating a banana",\ 96 "C.L.A.S.S- come late and start sleeping","My biggest concern in life is actually how my online friends can be informed of my death!",\ 97 "How do you know what it’s like to be stupid if you’ve never been smart?","I hate fake people. You know what I’m talking about. Mannequins."\ 98 "Everything is 10x funnier when you are not supposed to laugh.","It may look like I’m deep in thought, but 99% of the time I’m just thinking about what food to eat later.",\ 99 "\"Focusing\" on school work","That awkward moment when you realize that dora, who is 5, has more freedom than you.",\ 100 "That awkward when your eyes assumed “moment” was written after \"awkward\"","Never gonna let you down","Never gonna run around",\ 101 "https://www.youtube.com/watch?v=dQw4w9WgXcQ","I lost the game","Dont forget to like and subscribe!","Imagine putting in effort",\ 102 "I put the most effort into these quotes","If you have more status ideas, DM helaugheth#5815","Epsilon SMP!","Psst, is anyone watching these?",\ 103 "There are 10 types of people, those who understand binary and those who dont","I should focus on college homework","There are 13 lines of quotes for me to choose from.",\ 104 "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn","#SupportC'thulu","#LearnParsletoung","I'm adding these during class","lol",\ 105 "XD","Bro this releaves so much boredom","Shoot, I should do homework","College classes are BORING","All around me are familiar faces...",\ 106 "What is this...\"Fish Commands\" thing?","Yar dar dar and a hody hody do","https://www.youtube.com/watch?v=Q04Lkw91Gts"] 107 108 Status = random.choice(Options) 109 await bot.change_presence(activity = discord.Game(name = Status)) 110 111 @bot.command(help = "Request 1 title higher than you currently have.") 112 async def Title(ctx): 113 Message = ctx.message 114 115 if ctx.channel == ThroneRoom and ThroneRoomActive: 116 User = Message.author 117 RoleChosen = False 118 Cleared = False 119 TitleList = Guild.roles 120 RequestedTitle = "TEST" 121 122 for role in User.roles: 123 if role.name == RoleHeigherarchy[1]: 124 CurrentTitle = {"Role":role,"Rank":1,"H":1} 125 Cleared = True 126 elif role.name == RoleHeigherarchy2[1]: 127 CurrentTitle = {"Role":role,"Rank":1,"H":2} 128 Cleared = True 129 130 elif role.name == RoleHeigherarchy[2]: 131 CurrentTitle = {"Role":role,"Rank":2,"H":1} 132 elif role.name == RoleHeigherarchy2[2]: 133 CurrentTitle = {"Role":role,"Rank":2,"H":2} 134 135 elif role.name == RoleHeigherarchy[3]: 136 CurrentTitle = {"Role":role,"Rank":3,"H":1} 137 elif role.name == RoleHeigherarchy2[3]: 138 CurrentTitle = {"Role":role,"Rank":3,"H":2} 139 140 elif role.name == RoleHeigherarchy[4] or role.name == RoleHeigherarchy2[4]: 141 CurrentTitle = {"Role":role,"Rank":4,"H":1} 142 elif role.name == RoleHeigherarchy[5] or role.name == RoleHeigherarchy2[5]: 143 CurrentTitle = {"Role":role,"Rank":5,"H":1} 144 elif role.name == RoleHeigherarchy[6] or role.name == RoleHeigherarchy2[6]: 145 CurrentTitle = {"Role":role,"Rank":6,"H":1} 146 147 if not Cleared: 148 await ctx.send("You need a higher rank to be able to request titles.") 149 else: 150 for Title in TitleList[1:]: 151 if Title == CurrentTitle["Role"]: 152 if CurrentTitle["Rank"] < 4: 153 if CurrentTitle["H"] == 1: 154 RequestedTitle = RoleHeigherarchy[CurrentTitle["Rank"] + 1] 155 RoleChosen = True 156 else: 157 RequestedTitle = RoleHeigherarchy2[CurrentTitle["Rank"] + 1] 158 RoleChosen = True 159 160 elif CurrentTitle["Rank"] == 4: 161 await ctx.send("That title is granted by the King, you cannot request it") 162 RoleChosen = False 163 164 elif CurrentTitle["Rank"] == 5: 165 await ctx.send("When the King ~~dies~~ leaves you are given his title. Otherwise you cant request the King title") 166 RoleChosen = False 167 168 elif CurrentTitle["Rank"] == 6: 169 await ctx.send("You're already top of the ship mate. You cant request any higher") 170 RoleChosen = False 171 172 if RoleChosen: 173 if Title.name == RequestedTitle: 174 NewMessage = await ctx.send(User.mention + " Requests the title of: " + str(Title.name)) 175 176 await discord.Message.delete(Message) 177 NewData = {"Message": NewMessage,"Role":Title} 178 MessageListImportant.append(NewData) 179 else: 180 await discord.Message.delete(Message) 181 Message = await ctx.send("Incorrect channel. Message has been deleted. Please only use this command in #throne-room and only when it's open.") 182 await Message.delete(delay=10) 183 184 @bot.command(help = "Admin level command") 185 async def LoopSettings(ctx, arg): 186 Member = ctx.message.author 187 Cleared = await RoleGetter(Member,"Regent") 188 189 for Role in Guild.roles: 190 if Role.name == RoleHeigherarchy[0]: 191 Citizenry = Role 192 193 if not Cleared: 194 await ctx.send("You do not have permission to access this command.") 195 196 else: 197 if arg == "Restart": 198 ThroneRoomLoop() 199 await AdminBotChannel.send("The #throne-room open/close cycle has been restarted. The current loop time is: " + str(ThroneRoomLoop.next_iteration)) 200 await ThroneRoomLoop.restart() 201 202 elif arg == "Start": 203 if ThroneRoomLoop.is_running(): 204 if ThroneRoomActive: 205 await AdminBotChannel.send("The #throne-room loop is already running. #throne-room is currently open and will close on: " + str(ThroneRoomLoop.next_iteration)) 206 else: 207 await AdminBotChannel.send("The #throne-room loop is already running. #throne-room is currently closed and will open on: " + str(ThroneRoomLoop.next_iteration)) 208 else: 209 await AdminBotChannel.send("The #throne-room loop has been started") 210 await ThroneRoomLoop.start() 211 212 elif arg == "Stop": 213 if not ThroneRoomLoop.is_running(): 214 await AdminBotChannel.send("The #throne-room loop is not running.") 215 else: 216 await AdminBotChannel.send("The #throne-room loop has been stopped.") 217 await Announcements.send(ThroneRoom.mention + " has closed. Voting will be held and results will be announced soon.") 218 ThroneRoomLoop.cancel() 219 220 elif arg == "QuietStart": 221 #await ThroneRoom.set_permissions(Citizenry, view_channel = True) 222 await AdminBotChannel.send("Citizenry has been given access. No announcements made.") 223 ThroneRoomActive = True 224 225 elif arg == "QuietStop": 226 #await ThroneRoom.set_permissions(Citizenry, view_channel = False) 227 await AdminBotChannel.send("Citizenry access has been removed. No announcements made.") 228 ThroneRoomActive = False 229 230 elif arg == "help": 231 Help = discord.Embed() 232 Help.add_field(name = "BOT PREFIX", value = "Fish") 233 Help.add_field(name = "LoopSettings Commands", value = "`Start` | `Stop` | `Restart` | `QuietStart` | ` QuietStop`") 234 Help.add_field(name = "Start", value = "Starts the throne room loop EX: `Fish LoopSettings Start`") 235 Help.add_field(name = "Stop", value = "Stops the throne room loop EX: `Fish LoopSettings Stop`") 236 Help.add_field(name = "Restart", value = "Restarts the throne room loop EX: `Fish LoopSettings Restart`") 237 Help.add_field(name = "QuietStart", value = "Start the throne room loop without public announcements made. EX: `Fish LoopSettings QuietStart`") 238 Help.add_field(name = "QuietStop", value = "Close the throne room without public announcements made. EX: `Fish LoopSettings QuietStop`") 239 await ctx.send(embed = Help) 240 241 @bot.command(help = "Shows available commands") 242 async def Commands(ctx): 243 Help = discord.Embed() 244 Help.add_field(name = "BOT PREFIX", value = "Fish") 245 Help.add_field(name = "COMMANDS", value = "`Title`") 246 Help.add_field(name = "Title:", value = "Only available when the Throne Room is available and if you have the Good Lad/Lady Title. EX: Fish Title") 247 await ctx.send(embed = Help) 248 249 @bot.command(help = "Admin level command") 250 async def AdminHelp(ctx): 251 Member = ctx.message.author 252 Cleared = False 253 Cleared = await RoleGetter(Member,"Regent") 254 if not Cleared: 255 await ctx.send("You do not have permission to access this command.") 256 else: 257 Help = discord.Embed() 258 Help.add_field(name = "BOT PREFIX", value = "Fish") 259 Help.add_field(name = "HIDDEN COMMANDS", value = "`LoopSettings`, `Clear`") 260 Help.add_field(name = "HELP", value = "Run the command with `help` after to get help. EX: `Fish Clear help`") 261 #Help.add_field(name = "LoopSettings", value = "Has 3 sub-commands: Restart, Start and Stop. They will each do that to the Throne Room loop. EX: Fish LoopSettings Start/Stop/Restart") 262 await AdminBotChannel.send(embed = Help) 263 264 @bot.command(help = "None") 265 async def Clear(ctx,arg): 266 Cleared = await RoleGetter(ctx.message.author,"Duke") 267 Cleared2 = await RoleGetter(ctx.message.author,"Duchess") 268 269 if not Cleared and not Cleared2: 270 await ctx.send("You do not have permission to access this command.") 271 else: 272 if arg == "help": 273 await ctx.message.delete(delay = 20) 274 await ctx.send("Clear an amount of messages from a channel. `EX: Fish Clear 6`") 275 else: 276 await ctx.channel.purge(limit=int(arg)) 277 278 @bot.event 279 async def on_raw_reaction_add(payload): 280 User = Guild.get_member(payload.member.id) 281 if (payload.channel_id == ThroneRoom.id): 282 for message in MessageListImportant: 283 for role in User.roles: 284 if role.name != message["Role"].name and User != bot.user: 285 Cleared = False 286 else: 287 Cleared = True 288 break 289 if not Cleared: 290 await message["Message"].remove_reaction(payload.emoji,payload.member) 291 292 @bot.listen("on_message") 293 async def Responder(message): 294 if message.content == "E": 295 Message2 = await message.channel.send("Oh?").delte(delay = 5) 296 #await message.delete(delay = 5) 297 #await Message2.delete(delay = 5) 298 299 bot.run(TOKEN)