├── database.json ├── assets └── projglowbanner.png ├── requirements.txt ├── CLA.md ├── cogs ├── suggestion.py ├── override.py ├── rtfm.py ├── music.py ├── eval.py ├── extras │ └── fuzzy.py ├── util.py └── moderation.py ├── README.md ├── .gitignore ├── global_functions.py ├── LICENSE └── main.py /database.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | } -------------------------------------------------------------------------------- /assets/projglowbanner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apat7/projglow/HEAD/assets/projglowbanner.png -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | nextcord 2 | DiscordUtils[voice] 3 | psutil 4 | requests 5 | pymongo 6 | uvloop 7 | orjson>=3.5.4 8 | aiodns>=1.1 9 | cchardet 10 | Brotli 11 | -------------------------------------------------------------------------------- /CLA.md: -------------------------------------------------------------------------------- 1 | # Welcome 2 | Welcome To The CLA(Contributor License Agreement) Made By VincentRPS, This Agreement Is To Facilitate That You Know Our's And Your Rights With The Code Provided On The Home Page 3 | 4 | Project Glows Code Is Copyright(c)2021-present Glowstik 5 | 6 | # Definition 7 | 8 | Code - The Pythonic Pieces Of Code Or Any Other Language 9 | 10 | Copyright - An Owned Copyrighted Piece Of Software 11 | 12 | Discord - The Platform Of Which This Bot Is Hosted On 13 | 14 | # Summary 15 | You Have The Right To: 16 | 17 | Download The Code 18 | 19 | Use The Code With Credit 20 | 21 | Contribute To The Project 22 | 23 | Make Edits To The Code 24 | 25 | We Have The Right: 26 | 27 | Use Your Code(With Credit If You Add Them) 28 | 29 | Gain The Copyright To Said Code 30 | 31 | And Use Them For Anything In Discord 32 | 33 | # Chapter 1 - Copyright 34 | Once Your Code Has Been Contributed You Agree That We Now Withold The Rights To That Code And Keep Them For The Next indefinite Amount Of Time 35 | 36 | All Will Be Held Under The Same License That Is Showcased On The [LICENSE](/LICENSE) 37 | 38 | Copyright(c)2021-present Glowstik 39 | # Chapter 2 - In Case Of Death 40 | In Case Of Your Unfortunate Demise All Of Your Code Will Still Be In Our Copyright And We Will Retain The Full Rights To Use And Ditribute That Code Publicly Or Privatly 41 | 42 | Copyright(c)2021-present Glowstik 43 | # Chapter 3 - Rights To Pull Code 44 | You Don't Retain The Rights To Take Your Code Out, Once We Have Merged You Pull It Falls Under Our Terms(You Can Use The Code In Your Own Projects Without Credit Though) 45 | -------------------------------------------------------------------------------- /cogs/suggestion.py: -------------------------------------------------------------------------------- 1 | import nextcord 2 | from nextcord.ext import commands 3 | from global_functions import BOT_USER_ID 4 | 5 | 6 | class Suggestion(commands.Cog): 7 | def __init__(self, client): 8 | self.client = client 9 | 10 | @commands.Cog.listener() 11 | async def on_message(self, message): 12 | if str(message.author.id) != str(BOT_USER_ID): 13 | send = message.channel.send 14 | 15 | @commands.command(name="suggest", description="Creates a suggestion in #suggestion") 16 | @commands.cooldown(1, 30, commands.BucketType.user) 17 | async def suggest(self, ctx, *, suggestion): 18 | await ctx.channel.purge(limit = 1) 19 | channel = nextcord.utils.get(ctx.guild.text_channels, name = 'suggestion') 20 | suggest = nextcord.Embed(title=f"Suggestion", description=f"{ctx.message.author} suggests: **{suggestion}**") 21 | sugg = await channel.send(embed=suggest) 22 | await channel.send(f"^^ Suggestion ID: {sugg.id}") 23 | await suggest.add_reaction('✅') 24 | await suggest.add_reaction('❌') 25 | 26 | @commands.command(name="approve", description="Approves a user's suggestion") 27 | async def approve(self, ctx, id:int=None): 28 | if id == None: 29 | em = nextcord.Embed(title='Approve Error', description='Please specify message id') 30 | return await ctx.send(embed=em) 31 | channel = nextcord.utils.get(ctx.guild.text_channels, name = 'suggestion') 32 | if channel is None: 33 | embed = nextcord.Embed(title='Approve Error', description='Can not find suggestion channel') 34 | return await ctx.send(embed=embed) 35 | suggestionMsg = await channel.fetch_message(id) 36 | embed = nextcord.Embed(title=f'Suggestion Approved!', description=f'The suggestion id of `{suggestionMsg.id}` has been approved by {ctx.author.mention}') 37 | await channel.send(embed=embed) 38 | def setup(client): 39 | client.add_cog(Suggestion(client)) 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![](assets/projglowbanner.png) 2 | 3 | # Project Glow 4 | 5 | 6 | [![](https://discord.com/api/guilds/794739329956053063/embed.png)](https://discord.gg/bZJYdBXGjr) 7 | [![](https://custom-icon-badges.herokuapp.com/github/commit-activity/w/glowstik-yt/projglow?style=plastic&logo=github)](https://github.com/Glowstik-YT/projglow) 8 | [![](https://custom-icon-badges.herokuapp.com/github/last-commit/glowstik-yt/projglow?style=plastic&logo=github)](https://github.com/Glowstik-YT/projglow) 9 | [![Powered by Nextcord](https://img.shields.io/github/license/Glowstik-YT/projglow?style=plastic)](LICENSE) 10 | [![](https://custom-icon-badges.herokuapp.com/bitbucket/issues/Glowstik-YT/projglow?style=plastic&logo=github)](https://github.com/Glowstik-YT/projglow/issues) 11 | [![](https://img.shields.io/github/issues-pr-raw/Glowstik-YT/projglow?color=gree&label=Pull%20Requests&style=plastic)](https://github.com/Glowstik-YT/projglow/pulls) 12 | 13 | Greetings, I see you have stumbled upon project glow. Project glow is an open source bot worked on by many people to create a 14 | good and safe moderation bot for all. Adding to the bot is simple! 15 | 16 | First create a fork of the bot by clicking on the fork button in the top right coner. 17 | 18 | Then, create a clone by installing [git](https://git-scm.com/) into your pc. After this is done and setup, run 19 | ``` 20 | git clone https://github.com/Glowstik-YT/projglow 21 | ``` 22 | in whatever directory you wish to work on the bot. This will add all of the code into your pc. 23 | 24 | Make sure to hook up your own bot token to test out the bot... 25 | 26 | Once this is done and you have added changes you think can benifit the bot, go ahead and run 27 | ``` 28 | git add . 29 | ``` 30 | in the directory the bot is located in. 31 | 32 | After this run 33 | ``` 34 | git commit -m "put what ever work you did here" 35 | ``` 36 | once this is done you have on last step to do. 37 | 38 | Lastly, run 39 | ``` 40 | git push 41 | ``` 42 | and then go to the github fork you created and click on the contribute button to create a pull request where I will be able to accept or deny the changes! 43 | # CLA 44 | Remember That When You Contribute You Agree To The [License](/LICENSE) And [CLA](/CLA.md) 45 | 46 | # Communication 47 | 48 | If you need support for the bot please join the [Project Glow Support Server](https://discord.gg/bpvrRDWEQV) if you want to chat with other devs join [Glowstiks Git Repo](https://discord.gg/hJDsAVkkuU) 49 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /cogs/override.py: -------------------------------------------------------------------------------- 1 | import nextcord 2 | from nextcord.ext import commands 3 | from global_functions import BOT_USER_ID 4 | 5 | 6 | class BanConfirm(nextcord.ui.View): 7 | def __init__(self): 8 | super().__init__() 9 | self.value = None 10 | 11 | @nextcord.ui.button( 12 | label="Confirm", style=nextcord.ButtonStyle.green, custom_id="yes" 13 | ) 14 | async def confirm( 15 | self, button: nextcord.ui.Button, interaction: nextcord.Interaction 16 | ): 17 | self.value = True 18 | self.stop() 19 | 20 | @nextcord.ui.button(label="Cancel", style=nextcord.ButtonStyle.red, custom_id="no") 21 | async def cancel( 22 | self, button: nextcord.ui.Button, interaction: nextcord.Interaction 23 | ): 24 | self.value = False 25 | self.stop() 26 | 27 | 28 | class Override(commands.Cog): 29 | def __init__(self, client): 30 | self.client = client 31 | 32 | @commands.command() 33 | @commands.has_permissions(kick_members=True) 34 | async def modban(self, ctx, member: nextcord.Member = None, *, reason=None): 35 | if member == None: 36 | embed1 = nextcord.Embed( 37 | title="Ban Error", description="Member to ban - Not Found" 38 | ) 39 | return await ctx.send(embed=embed1) 40 | if member.id == ctx.author.id: 41 | embed69 = nextcord.Embed( 42 | title="Ban Error", 43 | description="Can not ban yourself, trust me I woulda ages ago <:hehe:796743161208504320>", 44 | ) 45 | return await ctx.send(embed=embed69) 46 | elif ctx.author.top_role.position < member.top_role.position: 47 | em3 = nextcord.Embed( 48 | title="Ban Error", 49 | description="Member **higher** than you in the role heirarchy - Invalid Permission", 50 | ) 51 | return await ctx.send(embed=em3) 52 | elif ctx.author.top_role.position == member.top_role.position: 53 | em3 = nextcord.Embed( 54 | title="Ban Error", 55 | description="Member has same role as you in the role heirarchy - Invalid Permission", 56 | ) 57 | return await ctx.send(embed=em3) 58 | em = nextcord.Embed( 59 | title="Are you sure?", 60 | description="This is a very risky command only to be used in important situations such as, `NSFW or NSFLPosting` or `Raid on the Server`. Only use this command if no admin is online or responding. **If this command is used for the wrong purpose you may risk getting demoted if not banned from the staff team.**", 61 | ) 62 | view = BanConfirm() 63 | ctx.author.send(embed=em, view=view) 64 | 65 | 66 | def setup(client): 67 | client.add_cog(Override(client)) 68 | -------------------------------------------------------------------------------- /global_functions.py: -------------------------------------------------------------------------------- 1 | #This Code Is Under The MPL-2.0 License 2 | import json 3 | 4 | # CONTANTS 5 | MAX_BEG_GAIN = 300 6 | DAILY_AMT = 2000 7 | PREFIX = ">" 8 | MAX_WORK_GAIN = 2000 9 | WEEKLY_AMT = 5000 10 | BOT_USER_ID = "832712190590844968" 11 | MEMBERCOUNT_CHANNEL = 864182952937127948 # membercount channel id here, default is the one in glow's server 12 | UPDATE_CHANNEL = "834579757320241163" 13 | ERROR_CHANNELS = ["897838814670778371"] 14 | GUILDS = [ 15 | {"server": 815976334907801601}, 16 | {"server": 803080452968808468}, 17 | {"server": 824640805884919849}, 18 | ] 19 | 20 | EMOJIS_TO_USE_FOR_CALCULATOR = {"1":"1️⃣", "2":"2️⃣", "3":"3️⃣", "4":"4️⃣", "5":"5️⃣", "6":"6️⃣", "7":"7️⃣", "8":"8️⃣", "9":"9️⃣", "0":"0️⃣", "+":"➕", "-":"➖","x":"✖️","÷":"➗",".":"<:dot:898959986024153088>"} #Make sure to change the point emoji, as this one is from glows server 21 | 22 | TOKEN = "" 23 | # make sure to remove it before you push 24 | 25 | 26 | hugs = [ 27 | "https://i.pinimg.com/originals/f2/80/5f/f2805f274471676c96aff2bc9fbedd70.gif", 28 | "https://i.pinimg.com/originals/85/72/a1/8572a1d1ebaa45fae290e6760b59caac.gif", 29 | "http://25.media.tumblr.com/tumblr_ma7l17EWnk1rq65rlo1_500.gif", 30 | "https://i.imgur.com/r9aU2xv.gif?noredirect", 31 | "https://i.gifer.com/2QEa.gif", 32 | "https://25.media.tumblr.com/2a3ec53a742008eb61979af6b7148e8d/tumblr_mt1cllxlBr1s2tbc6o1_500.gif", 33 | "https://media3.giphy.com/media/sUIZWMnfd4Mb6/200.gif", 34 | "https://i.pinimg.com/originals/f9/e9/34/f9e934cddfd6fefe0079ab559ef32ab4.gif", 35 | "https://media3.giphy.com/media/wnsgren9NtITS/giphy.gif", 36 | "https://38.media.tumblr.com/b22e5793e257faf94cec24ba034d46cd/tumblr_nldku9v7ar1ttpgxko1_500.gif", 37 | "https://i2.wp.com/nileease.com/wp-content/uploads/2020/09/38ff71787d331e2c8c7326846e718c4b.gif?fit=498%2C314&ssl=1", 38 | "https://i.pinimg.com/originals/0c/bc/37/0cbc377124f2f91d76277160b5803372.gif", 39 | "https://78.media.tumblr.com/88b9b721e47c33272a3cafd0fdb916b5/tumblr_oqkfe3BbYM1vb10byo1_500.gif", 40 | ] 41 | 42 | people_list = [ 43 | "Glowstikk", 44 | "Chill", 45 | "Vibe", 46 | "a fellow beggar", 47 | "drunk boi", 48 | "the big man", 49 | "You from a parallel universe", 50 | "Elon", 51 | "Siri", 52 | "Creepy dude with a knife who is now prolly watching you and is bout to eat you tmmr :)", 53 | "Dream", 54 | "¯\_(ツ)_/¯", 55 | "you?", 56 | "I", 57 | "Discord", 58 | "Your Dad", 59 | "Your Mom", 60 | "Your family who is really unhappy with you because your let everyone down by becoming a redditor", 61 | "Your imaginary gf :rofl:", 62 | "the street", 63 | ] 64 | 65 | ban_msg = [ 66 | "flew to close to the radar and got banned", 67 | "messed up bad and got banned", 68 | "has been struck by the BAN HAMMER", 69 | "annoyed some staff and got banned", 70 | "wanted to see what would happen if you broke rules and got banned", 71 | "tried to dodge the ban hammer :rofl:", 72 | "was blown up by Creeper", 73 | "was killed by [Intentional Game Design]", 74 | "tried to swim in lava", 75 | "experienced kinetic energy", 76 | "drowned", 77 | "hit the ground too hard", 78 | "was squashed by a falling anvil", 79 | "was squished too much", 80 | "fell out of the world", 81 | "went up in flames", 82 | "went off with a bang", 83 | "was struck by lightning", 84 | "discovered the floor was lava", 85 | ] 86 | 87 | 88 | kick_msg = [ 89 | "got booted and got kicked?", 90 | "got kicked, imagine getting kicked...", 91 | "got kicked... I ran out of jokes", 92 | ] 93 | 94 | work_list = ["Discord", "Microsoft", "Apple", "a Police Station", "Youtube", "Google"] 95 | 96 | options = [ 97 | "uber", 98 | "taxi", 99 | "doorstep", 100 | "locker", 101 | "grass", 102 | "couch", 103 | "house", 104 | "bush", 105 | "street", 106 | "lake", 107 | ] 108 | 109 | choices = ["get no", "gained"] 110 | # test 111 | 112 | bank_memberships = [ 113 | { 114 | "name": "Basic Membership - ``$100,000``", 115 | "description": "Store up to $100,000 in your bank", 116 | }, 117 | { 118 | "name": "Silver Membership - ``$500,000``", 119 | "description": "Store up to $250,000 in your bank", 120 | }, 121 | { 122 | "name": "Diamond Membership - ``$1,000,000``", 123 | "description": "Store up to $500,000 in your bank!", 124 | }, 125 | { 126 | "name": "Magical Membership - ``$1,500,000``", 127 | "description": "Store up to $1,000,000 in your bank!", 128 | }, 129 | { 130 | "name": "Epik Membership - ``$2,500,000``", 131 | "description": "Store up to $2,000,000 in your bank!", 132 | }, 133 | { 134 | "name": "Glow Membership - ``$5,000,000``", 135 | "description": "Store up to $10,000,000 in your bank!", 136 | }, 137 | ] 138 | 139 | bank_membership_conversions = [ 140 | { 141 | "name": "basic membership", 142 | "nickname": "basic", 143 | "price": 100_000, 144 | "amount": 100_000, 145 | }, 146 | { 147 | "name": "silver membership", 148 | "nickname": "epic", 149 | "price": 500_000, 150 | "amount": 250_000, 151 | }, 152 | { 153 | "name": "diamond membership", 154 | "nickname": "magical", 155 | "price": 1_000_000, 156 | "amount": 500_000, 157 | }, 158 | { 159 | "name": "magical membership", 160 | "nickname": "diamond", 161 | "price": 1_500_000, 162 | "amount": 1_000_000, 163 | }, 164 | { 165 | "name": "epik membership", 166 | "nickname": "silver", 167 | "price": 2_500_000, 168 | "amount": 2_000_000, 169 | }, 170 | { 171 | "name": "glow membership", 172 | "nickname": "exotic", 173 | "price": 5_000_000, 174 | "amount": 10_000_000, 175 | }, 176 | ] 177 | 178 | responses = [ 179 | "It is certain.", 180 | "It is decidedly so.", 181 | "Without a doubt.", 182 | "Yes - definitely.", 183 | "You may rely on it.", 184 | "As I see it, yes.", 185 | "Most likely.", 186 | "Outlook good.", 187 | "Yes.", 188 | "Signs point to yes.", 189 | "Reply hazy, try again.", 190 | "Ask again later.", 191 | "Better not tell you now.", 192 | "Cannot predict now.", 193 | "Concentrate and ask again.", 194 | "Don't count on it.", 195 | "My reply is no.", 196 | "My sources say no.", 197 | "Outlook not so good.", 198 | "Very doubtful.", 199 | ] 200 | 201 | 202 | shop_display = [ 203 | {"name": "Laptop", "price": "``$5,000``", "description": "Used for posting memes"}, 204 | {"name": "Phone", "price": "``$1,000``", "description": "Bored? Well look at some memes!"}, 205 | {"name": "Nothing", "price": "``$500,000``", "description": "It's literally nothing, why would you waste your money"}, 206 | {"name": "Glow", "price": "``$100,000``", "description": "FLEX"}, 207 | ] 208 | 209 | 210 | shop_buy = [ 211 | {"name": "laptop", "nickname": "lap", "price": 5_000, "sell": 2_500}, 212 | {"name": "phone", "nickname": "cell", "price": 1_000, "sell": 500}, 213 | {"name": "glow", "nickname": "glow", "price": 100_000, "sell": 10_000}, 214 | {"name": "nothing", "nickname": "air", "price": 500_000, "sell": 250_000} 215 | ] 216 | 217 | 218 | def fetch_data(fn): 219 | with open("json/" + str(fn), "r") as f: 220 | data = json.load(f) 221 | return data 222 | 223 | 224 | def write_data(fn, data): 225 | with open("json/" + str(fn), "w") as f: 226 | json.dump(data, f, indent=4) 227 | 228 | def read_database(): 229 | try: 230 | with open("database.json") as f: 231 | database=json.load(f) 232 | except: 233 | write_database(data={}) 234 | database={} 235 | return database 236 | 237 | def write_database(*, data): 238 | with open("database.json","w+") as f: 239 | json.dump(data, f, indent=4) 240 | -------------------------------------------------------------------------------- /cogs/rtfm.py: -------------------------------------------------------------------------------- 1 | #Script Inspired by https://github.com/nextcord/previous 2 | 3 | import io 4 | import os 5 | import re 6 | import zlib 7 | from typing import Dict 8 | import nextcord as discord 9 | from nextcord.ext import commands 10 | from .extras import fuzzy 11 | 12 | class MakeLinkBtn(discord.ui.View): 13 | def __init__(self, link: str, text: str): 14 | super().__init__() 15 | self.add_item(discord.ui.Button(label=text, url=link)) 16 | 17 | class SphinxObjectFileReader: 18 | # Inspired by Sphinx's InventoryFileReader 19 | BUFSIZE = 16 * 1024 20 | 21 | def __init__(self, buffer): 22 | self.stream = io.BytesIO(buffer) 23 | 24 | def readline(self): 25 | return self.stream.readline().decode("utf-8") 26 | 27 | def skipline(self): 28 | self.stream.readline() 29 | 30 | def read_compressed_chunks(self): 31 | decompressor = zlib.decompressobj() 32 | while True: 33 | chunk = self.stream.read(self.BUFSIZE) 34 | if len(chunk) == 0: 35 | break 36 | yield decompressor.decompress(chunk) 37 | yield decompressor.flush() 38 | 39 | def read_compressed_lines(self): 40 | buf = b"" 41 | for chunk in self.read_compressed_chunks(): 42 | buf += chunk 43 | pos = buf.find(b"\n") 44 | while pos != -1: 45 | yield buf[:pos].decode("utf-8") 46 | buf = buf[pos + 1 :] 47 | pos = buf.find(b"\n") 48 | 49 | 50 | class Rtfm(commands.Cog): 51 | # full credit to https://github.com/Rapptz/RoboDanny 52 | def __init__(self, client): 53 | self.client = client 54 | 55 | def parse_object_inv(self, stream: SphinxObjectFileReader, url: str) -> Dict: 56 | result = {} 57 | inv_version = stream.readline().rstrip() 58 | 59 | if inv_version != "# Sphinx inventory version 2": 60 | raise RuntimeError("Invalid objects.inv file version.") 61 | 62 | projname = stream.readline().rstrip()[11:] 63 | version = stream.readline().rstrip()[11:] # not needed 64 | 65 | line = stream.readline() 66 | if "zlib" not in line: 67 | raise RuntimeError("Invalid objects.inv file, not z-lib compatible.") 68 | 69 | entry_regex = re.compile(r"(?x)(.+?)\s+(\S*:\S*)\s+(-?\d+)\s+(\S+)\s+(.*)") 70 | for line in stream.read_compressed_lines(): 71 | match = entry_regex.match(line.rstrip()) 72 | if not match: 73 | continue 74 | 75 | name, directive, prio, location, dispname = match.groups() 76 | domain, _, subdirective = directive.partition(":") 77 | if directive == "py:module" and name in result: 78 | continue 79 | 80 | if directive == "std:doc": 81 | subdirective = "label" 82 | 83 | if location.endswith("$"): 84 | location = location[:-1] + name 85 | 86 | key = name if dispname == "-" else dispname 87 | prefix = f"{subdirective}:" if domain == "std" else "" 88 | 89 | if projname == "nextcord": 90 | key = key.replace("nextcord.ext.commands.", "").replace("nextcord.", "") 91 | if projname == "pycord": 92 | key = key.replace("discord.ext.commands.", "").replace("discord.", "") 93 | if projname == "disnake": 94 | key = key.replace("disnake.ext.commands.", "").replace("disnake.", "") 95 | if projname == "discord": 96 | key = key.replace("discord.ext.commands.", "").replace("discord.", "") 97 | result[f"{prefix}{key}"] = os.path.join(url, location) 98 | return result 99 | 100 | async def build_rtfm_lookup_table(self, page_types): 101 | cache = {} 102 | for key, page in page_types.items(): 103 | sub = cache[key] = {} 104 | async with self.client.session.get(page + "/objects.inv") as resp: 105 | if resp.status != 200: 106 | raise RuntimeError( 107 | "Cannot build rtfm lookup table, try again later." 108 | ) 109 | 110 | stream = SphinxObjectFileReader(await resp.read()) 111 | cache[key] = self.parse_object_inv(stream, page) 112 | 113 | self._rtfm_cache = cache 114 | 115 | async def do_rtfm(self, ctx, key, obj): 116 | page_types = { 117 | "python": "https://docs.python.org/3", 118 | "master": "https://docs.nextcord.dev/en/latest/", 119 | "disnake": "https://docs.disnake.dev/en/latest/", 120 | "pycord": "https://docs.pycord.dev/en/master/", 121 | "discord": "https://discordpy.readthedocs.io/en/stable/", 122 | 123 | } 124 | 125 | if obj is None: 126 | await ctx.send(page_types[key]) 127 | return 128 | 129 | if not hasattr(self, "_rtfm_cache"): 130 | await ctx.trigger_typing() 131 | await self.build_rtfm_lookup_table(page_types) 132 | 133 | obj = re.sub(r"^(?:discord\.(?:ext\.)?)?(?:commands\.)?(.+)", r"\1", obj) 134 | obj = re.sub(r"^(?:nextcord\.(?:ext\.)?)?(?:commands\.)?(.+)", r"\1", obj) 135 | obj = re.sub(r"^(?:disnake\.(?:ext\.)?)?(?:commands\.)?(.+)", r"\1", obj) 136 | 137 | if key.startswith("master"): 138 | # point the abc.Messageable types properly: 139 | q = obj.lower() 140 | for name in dir(discord.abc.Messageable): 141 | if name[0] == "_": 142 | continue 143 | if q == name: 144 | obj = f"abc.Messageable.{name}" 145 | break 146 | 147 | cache = list(self._rtfm_cache[key].items()) 148 | 149 | def transform(tup): 150 | return tup[0] 151 | 152 | matches = fuzzy.finder(obj, cache, key=lambda t: t[0], lazy=False)[:8] 153 | e = discord.Embed(title="RTFM") 154 | if len(matches) == 0: 155 | return await ctx.send("Could not find anything. Sorry.") 156 | linkView = MakeLinkBtn(text=matches[0][0], link=matches[0][1]) 157 | e.description = "\n".join(f"[`{key}`]({url})" for key, url in matches) 158 | ref = ctx.message.reference 159 | refer = None 160 | if ref and isinstance(ref.resolved, discord.Message): 161 | refer = ref.resolved.to_reference() 162 | await ctx.reply(embed=e, reference=refer, view=linkView) 163 | 164 | @commands.group(name="rtfm", help="python docs", aliases=["rtfd", "docs"], invoke_without_command=True) 165 | async def rtfm_group(self, ctx: commands.Context, *, obj: str = None): 166 | await self.do_rtfm(ctx, "master", obj) 167 | 168 | @rtfm_group.command(name="python", aliases=["py"]) 169 | async def rtfm_python_cmd(self, ctx: commands.Context, *, obj: str = None): 170 | await self.do_rtfm(ctx, "python", obj) 171 | 172 | @rtfm_group.command(name="pycord", aliases=["pyc"]) 173 | async def rtfm_pycord_cmd(self, ctx: commands.Context, *, obj: str = None): 174 | await self.do_rtfm(ctx, "pycord", obj) 175 | 176 | @rtfm_group.command(name="disnake", aliases=["dis"]) 177 | async def rtfm_disnake_cmd(self, ctx: commands.Context, *, obj: str = None): 178 | await self.do_rtfm(ctx, "disnake", obj) 179 | 180 | @rtfm_group.command(name="discord", aliases=["dpy"]) 181 | async def rtfm_discord_cmd(self, ctx: commands.Context, *, obj: str = None): 182 | await self.do_rtfm(ctx, "discord", obj) 183 | 184 | @commands.command( 185 | help="delete cache of rtfm (owner only)", aliases=["purge-rtfm", "delrtfm"] 186 | ) 187 | @commands.is_owner() 188 | async def rtfmcache(self, ctx: commands.Context): 189 | del self._rtfm_cache 190 | embed = discord.Embed(title="Purged rtfm cache.") 191 | await ctx.send(embed=embed) 192 | 193 | 194 | def setup(client): 195 | client.add_cog(Rtfm(client)) 196 | -------------------------------------------------------------------------------- /cogs/music.py: -------------------------------------------------------------------------------- 1 | #This Code Is Under The MPL-2.0 License 2 | 3 | import nextcord 4 | from nextcord.ext import commands 5 | import random 6 | import asyncio 7 | import DiscordUtils 8 | from difflib import get_close_matches 9 | from global_functions import * 10 | 11 | music = DiscordUtils.Music() 12 | 13 | 14 | class Music(commands.Cog): 15 | def __init__(self, client): 16 | self.client = client 17 | 18 | @commands.Cog.listener() 19 | async def on_message(self, message): 20 | if str(message.author.id) != str(BOT_USER_ID): 21 | send = message.channel.send 22 | 23 | @commands.Cog.listener() 24 | async def on_voice_state_update(self, member, before, after): 25 | if after.channel is not None: 26 | return 27 | elif self.client.user in before.channel.members and len(before.channel.members) == 1: 28 | voice_client = before.channel.guild.voice_client 29 | await voice_client.disconnect(force=True) 30 | 31 | @commands.command(description="Bot joins your voice channel.") 32 | async def join(self, ctx): 33 | voice_state = ctx.author.voice 34 | if voice_state is None: 35 | em1 = nextcord.Embed( 36 | title="Join Error", 37 | description="You must be in a voice channel to use this command", 38 | ) 39 | return await ctx.send(embed=em1) 40 | await ctx.author.voice.channel.connect() 41 | em1 = nextcord.Embed( 42 | title="Joined Voice!", description="Successfully joined your voice channel" 43 | ) 44 | return await ctx.send(embed=em1) 45 | 46 | @commands.command(description="Bot leaves your voice channel.") 47 | async def leave(self, ctx): 48 | voice_state = ctx.author.voice 49 | me_voice_state = ctx.guild.me.voice 50 | if voice_state is None: 51 | em1 = nextcord.Embed( 52 | title="Leave Error", 53 | description="You must be in a voice channel to use this command", 54 | ) 55 | return await ctx.send(embed=em1) 56 | if me_voice_state is None: 57 | em1 = nextcord.Embed( 58 | title="Leave Error", description="I am not currently in a voice channel" 59 | ) 60 | return await ctx.send(embed=em1) 61 | await ctx.voice_client.disconnect() 62 | player = music.get_player(guild_id=ctx.guild.id) 63 | try: 64 | await player.delete() 65 | except: 66 | ... 67 | em1 = nextcord.Embed( 68 | title="Left Voice!", description="Successfully left your voice channel" 69 | ) 70 | return await ctx.send(embed=em1) 71 | 72 | @commands.command(description="Plays or queues music to the player.") 73 | async def play(self, ctx, *, url): 74 | voice_state = ctx.guild.me.voice 75 | if voice_state is None: 76 | await ctx.author.voice.channel.connect() 77 | em1 = nextcord.Embed( 78 | title="Joined Voice!", 79 | description="Successfully joined your voice channel", 80 | ) 81 | await ctx.send(embed=em1) 82 | player = music.get_player(guild_id=ctx.guild.id) 83 | if not player: 84 | player = music.create_player(ctx, ffmpeg_error_betterfix=True) 85 | if not ctx.voice_client.is_playing(): 86 | await player.queue(url, search=True) 87 | song = await player.play() 88 | em1 = nextcord.Embed(title=f"Playing {song.name}") 89 | em1.add_field( 90 | name="Channel", value=f"[**{song.channel}**]({song.channel_url})" 91 | ) 92 | em1.add_field(name="Views", value=f"{song.views}") 93 | em1.set_thumbnail(url=song.thumbnail) 94 | em1.set_footer(text=f"Requested by: {ctx.author.name}") 95 | await ctx.send(embed=em1) 96 | else: 97 | song = await player.queue(url, search=True) 98 | em1 = nextcord.Embed(title=f"Queued {song.name}") 99 | em1.add_field( 100 | name="Channel", value=f"[**{song.channel}**]({song.channel_url})" 101 | ) 102 | em1.add_field(name="Views", value=f"{song.views}") 103 | em1.set_thumbnail(url=song.thumbnail) 104 | em1.set_footer(text=f"Requested by: {ctx.author.name}") 105 | await ctx.send(embed=em1) 106 | 107 | @commands.command(description="Pauses the music.") 108 | async def pause(self, ctx): 109 | player = music.get_player(guild_id=ctx.guild.id) 110 | song = await player.pause() 111 | e = nextcord.Embed(title=f"Paused {song.name}") 112 | await ctx.send(embed=e) 113 | 114 | @commands.command(description="Resumes the music.") 115 | async def resume(self, ctx): 116 | player = music.get_player(guild_id=ctx.guild.id) 117 | song = await player.resume() 118 | e = nextcord.Embed(title=f"Resumed {song.name}") 119 | await ctx.send(embed=e) 120 | 121 | @commands.command(description="Stops the music.") 122 | async def stop(self, ctx): 123 | player = music.get_player(guild_id=ctx.guild.id) 124 | await player.stop() 125 | e = nextcord.Embed(title="Stopped the player.") 126 | await ctx.send(embed=e) 127 | 128 | @commands.command(description="Loops the music.") 129 | async def loop(self, ctx): 130 | player = music.get_player(guild_id=ctx.guild.id) 131 | song = await player.toggle_song_loop() 132 | if song.is_looping: 133 | e = nextcord.Embed(title=f"Enabled loop for {song.name}") 134 | await ctx.send(embed=e) 135 | else: 136 | await ctx.send(f"Disabled loop for {song.name}") 137 | 138 | @commands.command(description="Sends the current music queue.") 139 | async def queue(self, ctx): 140 | player = music.get_player(guild_id=ctx.guild.id) 141 | e = nextcord.Embed( 142 | title=f"`{', '.join([song.name for song in player.current_queue()])}`" 143 | ) 144 | await ctx.send(embed=e) 145 | 146 | @commands.command(description="Shows the song now playing.") 147 | async def np(self, ctx): 148 | player = music.get_player(guild_id=ctx.guild.id) 149 | song = player.now_playing() 150 | e = nextcord.Embed(title=f"Now Playing : {song.name}") 151 | await ctx.send(embed=e) 152 | 153 | @commands.command(description="Skips the song") 154 | async def skip(self, ctx): 155 | player = music.get_player(guild_id=ctx.guild.id) 156 | data = await player.skip(force=True) 157 | if len(data) == 2: 158 | await ctx.send(f"Skipped from {data[0].name} to {data[1].name}") 159 | else: 160 | await ctx.send(f"Skipped {data[0].name}") 161 | 162 | @commands.command(description="Sets the volume Limit[1-100]") 163 | async def volume(self, ctx, vol: int): 164 | if vol > 100: 165 | em1 = nextcord.Embed( 166 | title="Volume Error", 167 | description="Stop trying to go deaf, the volume limit is 100", 168 | ) 169 | return await ctx.send(embed=em1) 170 | if vol < 1: 171 | em1 = nextcord.Embed( 172 | title="Volume Error", description="<:wtfboi:839156996221567027> wh- why" 173 | ) 174 | return await ctx.send(embed=em1) 175 | player = music.get_player(guild_id=ctx.guild.id) 176 | song, volume = await player.change_volume(vol) 177 | em1 = nextcord.Embed( 178 | title="Volume Success", 179 | description=f"Changed volume for **{song.name}** to **{volume}%**", 180 | ) 181 | await ctx.send(embed=em1) 182 | 183 | @commands.command(description="Removes a song from the queue") 184 | async def remove(self, ctx, index): 185 | player = music.get_player(guild_id=ctx.guild.id) 186 | song = await player.remove_from_queue(int(index)) 187 | e = nextcord.Embed(title="Removed {song.name} from queue") 188 | await ctx.reply(embed=e) 189 | 190 | 191 | def setup(client): 192 | client.add_cog(Music(client)) 193 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. 374 | -------------------------------------------------------------------------------- /cogs/eval.py: -------------------------------------------------------------------------------- 1 | """ Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. """ 374 | 375 | from time import time 376 | from nextcord.ext import commands 377 | from inspect import getsource 378 | import nextcord 379 | import sys 380 | import os 381 | 382 | 383 | class Eval(commands.Cog): 384 | def __init__(self, client): 385 | self.client = client 386 | 387 | def resolve_variable(self, variable): 388 | if hasattr(variable, "__iter__"): 389 | var_length = len(list(variable)) 390 | if (var_length > 100) and (not isinstance(variable, str)): 391 | return f"" 392 | elif not var_length: 393 | return f"" 394 | 395 | if (not variable) and (not isinstance(variable, bool)): 396 | return f"" 397 | return ( 398 | variable 399 | if (len(f"{variable}") <= 1000) 400 | else f"" 401 | ) 402 | 403 | def prepare(self, string): 404 | arr = ( 405 | string.strip("```").replace("py\n", "").replace("python\n", "").split("\n") 406 | ) 407 | if not arr[::-1][0].replace(" ", "").startswith("return"): 408 | arr[len(arr) - 1] = "return " + arr[::-1][0] 409 | return "".join(f"\n\t{i}" for i in arr) 410 | 411 | @commands.command( 412 | pass_context=True, 413 | aliases=["eval", "exec", "evaluate"], 414 | description="Evaluates given code", 415 | ) 416 | async def _eval(self, ctx, *, code: str): 417 | if not ctx.author.id == 744715959817994371: 418 | return 419 | silent = "-s" in code 420 | 421 | code = self.prepare(code.replace("-s", "")) 422 | args = { 423 | "nextcord": nextcord, 424 | "sauce": getsource, 425 | "sys": sys, 426 | "os": os, 427 | "imp": __import__, 428 | "this": self, 429 | "ctx": ctx, 430 | "member": ctx.author, 431 | "client": self.client, 432 | } 433 | 434 | try: 435 | exec(f"async def func():{code}", args) 436 | a = time() 437 | response = await eval("func()", args) 438 | if silent or (response is None) or isinstance(response, nextcord.Message): 439 | em = nextcord.Embed( 440 | title="Eval Success :D", 441 | description="```Code ran without any errors```", 442 | ) 443 | await ctx.send(embed=em) 444 | del args, code 445 | return 446 | em = nextcord.Embed( 447 | title="Eval Success :o", 448 | description=f"```py\n{self.resolve_variable(response)}```", 449 | ) 450 | em.set_footer( 451 | text=f"`{type(response).__name__} | {(time() - a) / 1000} ms`" 452 | ) 453 | await ctx.send(embed=em) 454 | except Exception as e: 455 | em = nextcord.Embed( 456 | title="Eval Error ._.", 457 | description=f"```{type(e).__name__}: {str(e)}```", 458 | ) 459 | await ctx.send(embed=em) 460 | 461 | del args, code, silent 462 | 463 | 464 | def setup(client): 465 | client.add_cog(Eval(client)) 466 | -------------------------------------------------------------------------------- /cogs/extras/fuzzy.py: -------------------------------------------------------------------------------- 1 | """ Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. """ 374 | 375 | import heapq 376 | import re 377 | from difflib import SequenceMatcher 378 | 379 | 380 | def ratio(a, b): 381 | m = SequenceMatcher(None, a, b) 382 | return int(round(100 * m.ratio())) 383 | 384 | 385 | def quick_ratio(a, b): 386 | m = SequenceMatcher(None, a, b) 387 | return int(round(100 * m.quick_ratio())) 388 | 389 | 390 | def partial_ratio(a, b): 391 | short, long = (a, b) if len(a) <= len(b) else (b, a) 392 | m = SequenceMatcher(None, short, long) 393 | 394 | blocks = m.get_matching_blocks() 395 | 396 | scores = [] 397 | for i, j, n in blocks: 398 | start = max(j - i, 0) 399 | end = start + len(short) 400 | o = SequenceMatcher(None, short, long[start:end]) 401 | r = o.ratio() 402 | 403 | if 100 * r > 99: 404 | return 100 405 | scores.append(r) 406 | 407 | return int(round(100 * max(scores))) 408 | 409 | 410 | _word_regex = re.compile(r'\W', re.IGNORECASE) 411 | 412 | 413 | def _sort_tokens(a): 414 | a = _word_regex.sub(' ', a).lower().strip() 415 | return ' '.join(sorted(a.split())) 416 | 417 | 418 | def token_sort_ratio(a, b): 419 | a = _sort_tokens(a) 420 | b = _sort_tokens(b) 421 | return ratio(a, b) 422 | 423 | 424 | def quick_token_sort_ratio(a, b): 425 | a = _sort_tokens(a) 426 | b = _sort_tokens(b) 427 | return quick_ratio(a, b) 428 | 429 | 430 | def partial_token_sort_ratio(a, b): 431 | a = _sort_tokens(a) 432 | b = _sort_tokens(b) 433 | return partial_ratio(a, b) 434 | 435 | 436 | def _extraction_generator(query, choices, scorer=quick_ratio, score_cutoff=0): 437 | try: 438 | for key, value in choices.items(): 439 | score = scorer(query, key) 440 | if score >= score_cutoff: 441 | yield key, score, value 442 | except AttributeError: 443 | for choice in choices: 444 | score = scorer(query, choice) 445 | if score >= score_cutoff: 446 | yield choice, score 447 | 448 | 449 | def extract(query, choices, *, scorer=quick_ratio, score_cutoff=0, limit=10): 450 | it = _extraction_generator(query, choices, scorer, score_cutoff) 451 | key = lambda t: t[1] 452 | if limit is not None: 453 | return heapq.nlargest(limit, it, key=key) 454 | return sorted(it, key=key, reverse=True) 455 | 456 | 457 | def extract_one(query, choices, *, scorer=quick_ratio, score_cutoff=0): 458 | it = _extraction_generator(query, choices, scorer, score_cutoff) 459 | key = lambda t: t[1] 460 | try: 461 | return max(it, key=key) 462 | except Exception: 463 | # iterator could return nothing 464 | return None 465 | 466 | 467 | def extract_or_exact(query, choices, *, limit=None, scorer=quick_ratio, score_cutoff=0): 468 | matches = extract(query, choices, scorer=scorer, score_cutoff=score_cutoff, limit=limit) 469 | if len(matches) == 0: 470 | return [] 471 | 472 | if len(matches) == 1: 473 | return matches 474 | 475 | top = matches[0][1] 476 | second = matches[1][1] 477 | 478 | # check if the top one is exact or more than 30% more correct than the top 479 | if top == 100 or top > (second + 30): 480 | return [matches[0]] 481 | 482 | return matches 483 | 484 | 485 | def extract_matches(query, choices, *, scorer=quick_ratio, score_cutoff=0): 486 | matches = extract(query, choices, scorer=scorer, score_cutoff=score_cutoff, limit=None) 487 | if len(matches) == 0: 488 | return [] 489 | 490 | top_score = matches[0][1] 491 | to_return = [] 492 | index = 0 493 | while True: 494 | try: 495 | match = matches[index] 496 | except IndexError: 497 | break 498 | else: 499 | index += 1 500 | 501 | if match[1] != top_score: 502 | break 503 | 504 | to_return.append(match) 505 | return to_return 506 | 507 | 508 | def finder(text, collection, *, key=None, lazy=True): 509 | suggestions = [] 510 | text = str(text) 511 | pat = '.*?'.join(map(re.escape, text)) 512 | regex = re.compile(pat, flags=re.IGNORECASE) 513 | for item in collection: 514 | to_search = key(item) if key else item 515 | r = regex.search(to_search) 516 | if r: 517 | suggestions.append((len(r.group()), r.start(), item)) 518 | 519 | def sort_key(tup): 520 | if key: 521 | return tup[0], tup[1], key(tup[2]) 522 | return tup 523 | 524 | if lazy: 525 | return (z for _, _, z in sorted(suggestions, key=sort_key)) 526 | else: 527 | return [z for _, _, z in sorted(suggestions, key=sort_key)] 528 | 529 | 530 | def find(text, collection, *, key=None): 531 | try: 532 | return finder(text, collection, key=key, lazy=False)[0] 533 | except IndexError: 534 | return None 535 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | #This Code Is Under The MPL-2.0 License 2 | 3 | from logging import exception 4 | import nextcord 5 | import traceback 6 | import datetime 7 | from nextcord.colour import Color 8 | from nextcord.embeds import Embed 9 | from nextcord.ext import commands, tasks 10 | from global_functions import ( 11 | PREFIX, 12 | responses, 13 | TOKEN, 14 | ERROR_CHANNELS, 15 | UPDATE_CHANNEL, 16 | MEMBERCOUNT_CHANNEL, 17 | read_database, 18 | write_database 19 | ) 20 | import random, json, os, sys 21 | from difflib import get_close_matches 22 | import asyncio 23 | import aiohttp 24 | from urllib.request import urlopen 25 | import json 26 | 27 | intents = nextcord.Intents().all() 28 | client = commands.Bot( 29 | command_prefix=str(PREFIX), intents=intents, case_insensitive=True 30 | ) 31 | client.remove_command("help") 32 | 33 | for fn in os.listdir("./cogs"): 34 | if fn.endswith(".py") and fn != "global_functions.py": 35 | client.load_extension(f"cogs.{fn[:-3]}") 36 | 37 | 38 | @tasks.loop(minutes=10) 39 | async def member_count(): 40 | try: 41 | member_count_channel = await client.fetch_channel(MEMBERCOUNT_CHANNEL) 42 | except: 43 | return print(f"Error!\nThe member count channel id is invalid!") 44 | if not isinstance(member_count_channel, nextcord.VoiceChannel): 45 | return print( 46 | f"Error!\nThe member count channel id that you gave is not a voice channel!" 47 | ) 48 | glowstiks_git_repo = client.get_guild(794739329956053063) 49 | 50 | for x in (member_count_channel_name := member_count_channel.name.split(" ")): 51 | if x.isdigit(): 52 | member_count_channel_name[member_count_channel_name.index(x)] = str( 53 | glowstiks_git_repo.member_count 54 | ) 55 | try: 56 | await member_count_channel.edit( 57 | name=" ".join(member_count_channel_name), 58 | reason="Automated Member Count Rename", 59 | ) 60 | except: 61 | return print("Error in renaming the member channel ;-;") 62 | 63 | 64 | async def startup(): 65 | client.session = aiohttp.ClientSession() 66 | 67 | 68 | client.loop.create_task(startup()) 69 | 70 | 71 | def apiReq(id, responseMSG): 72 | responseMSG = responseMSG.replace(" ", "-") 73 | 74 | url = f"http://api.brainshop.ai/get?bid=160228&key=nop&uid={id}&msg={responseMSG}" 75 | 76 | response = urlopen(url) 77 | data = json.loads(response.read()) 78 | 79 | return data 80 | 81 | 82 | @client.command() 83 | async def chat(ctx, *, responseMSG): 84 | data = apiReq(ctx.author.id, responseMSG) 85 | await ctx.send(data) 86 | 87 | 88 | @client.command() 89 | async def load(ctx, extension): 90 | if ctx.author.id == 744715959817994371: 91 | client.load_extension(f"cogs.{extension}") 92 | await ctx.send("Cog loaded") 93 | else: 94 | await ctx.send("Only bot devs can run this command") 95 | 96 | 97 | @client.command() 98 | async def reload(ctx, extension): 99 | if ctx.author.id == 744715959817994371: 100 | client.unload_extension(f"cogs.{extension}") 101 | await asyncio.sleep(1) 102 | client.load_extension(f"cogs.{extension}") 103 | await ctx.send("Cog reloaded") 104 | else: 105 | await ctx.send("Only bot devs can run this command") 106 | 107 | 108 | @client.command() 109 | async def unload(ctx, extension): 110 | if ctx.author.id == 744715959817994371: 111 | client.unload_extension(f"cogs.{extension}") 112 | await ctx.send("Cog unloaded") 113 | else: 114 | await ctx.send("Only bot devs can run this command") 115 | 116 | 117 | @client.command() 118 | async def check(ctx, cog_name): 119 | if ctx.author.id == 744715959817994371: 120 | try: 121 | client.load_extension(f"cogs.{cog_name}") 122 | except commands.ExtensionAlreadyLoaded: 123 | await ctx.send("Cog is loaded") 124 | except commands.ExtensionNotFound: 125 | await ctx.send("Cog not found") 126 | else: 127 | await ctx.send("Cog is unloaded") 128 | client.unload_extension(f"cogs.{cog_name}") 129 | else: 130 | await ctx.send("Only bot devs can run this command") 131 | 132 | 133 | @client.event 134 | async def on_ready(): 135 | member_count.start() 136 | print("Ready") 137 | try: 138 | update_channel = await client.fetch_channel(int(UPDATE_CHANNEL)) 139 | embed = nextcord.Embed( 140 | title="I am online!", 141 | description=f"I got online at {nextcord.utils.format_dt(nextcord.utils.utcnow(), 'F')}", 142 | ) 143 | await update_channel.send(embed=embed) 144 | except: 145 | print( 146 | f"Can't Fetch The Update Channel!\nMake Sure That You Kept The Right ID, If You Did Try And Contact ||Dank Lord||#9919" 147 | ) 148 | error_channels = [] 149 | error_in_loading_channel = [] 150 | for ERROR_CHANNEL in ERROR_CHANNELS: 151 | try: 152 | channel = await client.fetch_channel(int(ERROR_CHANNEL)) 153 | error_channels.append( 154 | f"https://discord.com/channels/{channel.guild.id}/{channel.id}" 155 | ) 156 | except: 157 | error_in_loading_channel.append(str(ERROR_CHANNEL)) 158 | error_channels = ", ".join(error_channels) 159 | print(f"My errors will be logged to {error_channels}") 160 | smthing = "\n".join(error_in_loading_channel) 161 | print( 162 | f"Can't fetch my error channel with id `{smthing}`, I can't log the errors ;-;" 163 | ) if len(error_in_loading_channel) > 0 else ... 164 | 165 | 166 | @client.event 167 | async def on_member_join(member): 168 | if member.guild.id != 794739329956053063: 169 | return 170 | channel = client.get_channel(794745011128369182) 171 | await channel.send(f"{member.name} has joined") 172 | 173 | 174 | 175 | @client.event 176 | async def on_raw_reaction_add(payload): 177 | if str(payload.emoji) != "⭐": 178 | return 179 | database = read_database() 180 | try: 181 | guild_starboard_settings = database[str(payload.guild_id)]['starboard'] 182 | guild_starboard_settings['on or off'] 183 | guild_starboard_settings['channel'] 184 | guild_starboard_settings['minimum stars'] 185 | except: 186 | return 187 | try: 188 | if not guild_starboard_settings["on or off"]: 189 | return 190 | except: 191 | return 192 | channel = client.get_channel(payload.channel_id) 193 | message = await channel.fetch_message(payload.message_id) 194 | for react in message.reactions: 195 | if str(react.emoji) == "⭐": 196 | react_count = react.count 197 | break 198 | if react_count >= 1: 199 | try: 200 | starboard_channel = client.get_channel( 201 | guild_starboard_settings["channel"]) 202 | try: 203 | sent_msg = await starboard_channel.fetch_message( 204 | guild_starboard_settings[str(message.id)] 205 | ) 206 | await sent_msg.edit( 207 | content=f":star2: {react_count} {channel.mention}" 208 | ) 209 | except: 210 | embed = nextcord.Embed( 211 | description=f"{message.content}\n**Source**\n[Jump!]({message.jump_url})" 212 | ) 213 | embed.set_author( 214 | name=message.author.display_name, 215 | icon_url=message.author.display_avatar, 216 | ) 217 | embed.set_footer(text=str(message.id)) 218 | sent_msg = await starboard_channel.send( 219 | f":star2: {react_count} {channel.mention}", embed=embed 220 | ) 221 | guild_starboard_settings[str(message.id)] = sent_msg.id 222 | write_database(data=database) 223 | 224 | except: 225 | ... 226 | 227 | 228 | 229 | @client.event 230 | async def on_message(message): 231 | mention = f"<@!{client.user.id}>" 232 | if message.content == mention: 233 | await message.channel.send( 234 | "Eyoo Nerds my prefix is `>` for help use the command `>help`" 235 | ) 236 | await client.process_commands(message) 237 | 238 | 239 | class UrlButton(nextcord.ui.Button): 240 | def __init__(self, *, label, url, emoji=None): 241 | super().__init__(label=label, url=url, emoji=emoji) 242 | 243 | 244 | class HelpDropdown(nextcord.ui.View): 245 | def __init__(self, user): 246 | self.user = user 247 | super().__init__() 248 | self.add_item( 249 | UrlButton(label="Support Server", url="https://discord.gg/xA3hBtujg7") 250 | ) 251 | # Set the options that will be presented inside the dropdown 252 | 253 | @nextcord.ui.select( 254 | placeholder="Choose your help page", 255 | min_values=1, 256 | max_values=1, 257 | options=[ 258 | nextcord.SelectOption( 259 | label="Moderation", description=f"`{PREFIX}help moderation`", emoji="⚒️" 260 | ), 261 | nextcord.SelectOption( 262 | label="Utility", description=f"`{PREFIX}help utility`", emoji="⚙️" 263 | ), 264 | nextcord.SelectOption( 265 | label="Music", description=f"`{PREFIX}help music`", emoji="🎵" 266 | ), 267 | ], 268 | ) 269 | async def help_callback(self, select, interaction: nextcord.Interaction): 270 | if interaction.user.id != self.user.id: 271 | em = nextcord.Embed( 272 | title="No U", 273 | description="This is not for you!", 274 | color=nextcord.Color.red(), 275 | ) 276 | return await interaction.response.send_message(embed=em, ephemeral=True) 277 | select.placeholder = f"{select.values[0]} Help Page" 278 | if select.values[0] == "Moderation": 279 | embed = nextcord.Embed( 280 | title=f"{client.user.name} Moderation Commands:", 281 | description=f"Support Server: [Click Here!](https://discord.gg/xA3hBtujg7) || `{PREFIX}help [category]` for other information.", 282 | ) 283 | for index, command in enumerate(client.get_cog("Moderation").get_commands()): 284 | description = command.description 285 | if not description or description is None or description == "": 286 | description = "No description" 287 | embed.add_field( 288 | name=f"`{PREFIX}{command.name}{command.signature if command.signature is not None else ''}`", 289 | value=description, 290 | ) 291 | await interaction.response.edit_message(embed=embed, view=self) 292 | elif select.values[0] == "Utility": 293 | embed = nextcord.Embed( 294 | title=f"{client.user.name} Utility Commands:", 295 | description=f"Support Server: [Click Here!](https://discord.gg/xA3hBtujg7) || `{PREFIX}help [category]` for other information.", 296 | ) 297 | for command in client.get_cog("util").walk_commands(): 298 | description = command.description 299 | if not description or description is None or description == "": 300 | description = "No description" 301 | embed.add_field( 302 | name=f"`{PREFIX}{command.name}{command.signature if command.signature is not None else ''}`", 303 | value=description, 304 | ) 305 | await interaction.response.edit_message(embed=embed, view=self) 306 | elif select.values[0] == "Music": 307 | embed = nextcord.Embed( 308 | title=f"{client.user.name} Music Commands:", 309 | description=f"Support Server: [Click Here!](https://discord.gg/xA3hBtujg7) || `{PREFIX}help [category]` for other information.", 310 | ) 311 | for command in client.get_cog("Music").walk_commands(): 312 | description = command.description 313 | if not description or description is None or description == "": 314 | description = "No description" 315 | embed.add_field( 316 | name=f"`{PREFIX}{command.name}{command.signature if command.signature is not None else ''}`", 317 | value=description, 318 | ) 319 | await interaction.response.edit_message(embed=embed, view=self) 320 | 321 | 322 | @client.group(invoke_without_command=True) 323 | async def help(ctx): 324 | view = HelpDropdown(ctx.author) 325 | embed = nextcord.Embed( 326 | title=f"{client.user.name} Help", 327 | description=f"Support Server: [Click Here!](https://discord.gg/xA3hBtujg7) || `{PREFIX}help [category]` for more information.", 328 | ) 329 | embed.set_thumbnail(url=f"{client.user.display_avatar}") 330 | embed.add_field( 331 | name="Moderation:", value=f"`{PREFIX}help moderation`", inline=False 332 | ) 333 | embed.add_field(name="Utility:", value=f"`{PREFIX}help utility`", inline=False) 334 | embed.add_field(name="Music:", value=f"`{PREFIX}help music`", inline=False) 335 | dank_lord = await client.fetch_user(758290177919156244) 336 | embed.set_footer( 337 | text=f"Requested by {ctx.author} | Created by: palp#9999 | Improved by: {dank_lord}", 338 | icon_url=f"{ctx.author.display_avatar}", 339 | ) 340 | await ctx.send(embed=embed, view=view) 341 | 342 | 343 | @help.command(aliases=['sb','starb']) 344 | async def starboard(ctx): 345 | embed=Embed(title="Help with Starboard", description=f""" 346 | `{PREFIX}starboard setup` 347 | Setup the starboard! 348 | 349 | `{PREFIX}starboard toggle [on/off]` 350 | Toggle the starboard 351 | 352 | `{PREFIX}starboard channel [channel]` 353 | Get/Change the starboard channel settings 354 | 355 | `{PREFIX}starboard minstars [number]` 356 | Get/Change the starboard minimum star settings""") 357 | await ctx.send(embed=embed) 358 | 359 | 360 | @help.command() 361 | async def moderation(ctx): 362 | view = HelpDropdown(ctx.author) 363 | embed = nextcord.Embed( 364 | title=f"{client.user.name} Moderation Commands:", 365 | description=f"Support Server: [Click Here!](https://discord.gg/xA3hBtujg7) || `{PREFIX}help [category]` for other information.", 366 | ) 367 | embed = nextcord.Embed( 368 | title=f"{client.user.name} Moderation Commands:", 369 | description=f"Support Server: [Click Here!](https://discord.gg/xA3hBtujg7) || `{PREFIX}help [category]` for other information.", 370 | ) 371 | for command in client.get_cog("Moderation").walk_commands(): 372 | description = command.description 373 | if not description or description is None or description == "": 374 | description = "No description" 375 | embed.add_field( 376 | name=f"`{PREFIX}{command.name}{command.signature if command.signature is not None else ''}`", 377 | value=description, 378 | ) 379 | await ctx.send(embed=embed, view=view) 380 | 381 | 382 | @help.command() 383 | async def utility(ctx): 384 | view = HelpDropdown(ctx.author) 385 | embed = nextcord.Embed( 386 | title=f"{client.user.name} Utility Commands:", 387 | description=f"Support Server: [Click Here!](https://discord.gg/xA3hBtujg7) || `{PREFIX}help [category]` for other information.", 388 | ) 389 | for command in client.get_cog("util").walk_commands(): 390 | description = command.description 391 | if not description or description is None or description == "": 392 | description = "No description" 393 | embed.add_field( 394 | name=f"`{PREFIX}{command.name}{command.signature if command.signature is not None else ''}`", 395 | value=description, 396 | ) 397 | await ctx.send(embed=embed, view=view) 398 | 399 | 400 | @help.command() 401 | async def music(ctx): 402 | view = HelpDropdown(ctx.author) 403 | embed = nextcord.Embed( 404 | title=f"{client.user.name} Music Commands:", 405 | description=f"Support Server: [Click Here!](https://discord.gg/xA3hBtujg7) || `{PREFIX}help [category]` for other information.", 406 | ) 407 | for command in client.get_cog("Music").walk_commands(): 408 | description = command.description 409 | if not description or description is None or description == "": 410 | description = "No description" 411 | embed.add_field( 412 | name=f"`{PREFIX}{command.name}{command.signature if command.signature is not None else ''}`", 413 | value=description, 414 | ) 415 | await ctx.send(embed=embed, view=view) 416 | 417 | 418 | @client.event 419 | async def on_error(error, *args, **kwargs): 420 | try: 421 | formatted_args = '\n'.join([f'{args.index(arg)+1}) {str(arg)} ({type(arg)})' for arg in args]) 422 | formatted_args = f"```py\n{formatted_args}```" 423 | for ERROR_CHANNEL in ERROR_CHANNELS: 424 | try: 425 | error_channel = await client.fetch_channel(int(ERROR_CHANNEL)) 426 | except: 427 | print(f"Can't log errors to the channel with id `{ERROR_CHANNEL}`") 428 | continue 429 | exception = sys.exc_info() 430 | exc = "\n".join( 431 | traceback.format_exception(exception[0], exception[1], exception[2]) 432 | ) 433 | error_em = nextcord.Embed( 434 | title=exception[0].__name__, 435 | color=nextcord.Color.red(), 436 | description=f"**Error in**: `{error}`\n```py\n{exc}```\n{f'Args: {formatted_args}' if len(args) > 0 else ''}\n{f'Kwargs: {kwargs}' if len(kwargs) > 0 else ''}", 437 | ) 438 | try: 439 | await error_channel.send(embed=error_em) 440 | except: 441 | ... 442 | print(exc) 443 | except: 444 | exception = sys.exc_info() 445 | exc = "\n".join( 446 | traceback.format_exception(exception[0], exception[1], exception[2]) 447 | ) 448 | formatted_args = '\n'.join([f'{args.index(arg)+1}) {str(arg)} ({type(arg)})' for arg in args]) 449 | print(exc, "Args: \n"+formatted_args) 450 | 451 | 452 | @client.event 453 | async def on_command_error(ctx, error): 454 | if isinstance(error, commands.CommandNotFound): 455 | cmd = ctx.invoked_with 456 | cmds = [cmd.name for cmd in client.commands] 457 | matches = get_close_matches(cmd, cmds) 458 | if len(matches) > 0: 459 | embed = nextcord.Embed( 460 | title="Invalid Command!", 461 | description=f"Command `{str(PREFIX)}{cmd}` not found, maybe you meant `{str(PREFIX)}{matches[0]}`?", 462 | ) 463 | await ctx.send(embed=embed) 464 | else: 465 | embed = nextcord.Embed( 466 | title="Invalid Command!", 467 | description=f"Please type `{str(PREFIX)}help` to see all commands", 468 | ) 469 | await ctx.send(embed=embed) 470 | return 471 | if isinstance(error, commands.CommandOnCooldown): 472 | m, s = divmod(error.retry_after, 60) 473 | h, m = divmod(m, 60) 474 | if int(h) == 0 and int(m) == 0: 475 | em = nextcord.Embed( 476 | title="**Command on cooldown**", 477 | description=f"You must wait `{int(s)}` seconds to use this command!", 478 | ) 479 | await ctx.send(embed=em) 480 | elif int(h) == 0 and int(m) != 0: 481 | em = nextcord.Embed( 482 | title="**Command on cooldown**", 483 | description=f" You must wait `{int(m)}` minutes and `{int(s)}` seconds to use this command!", 484 | ) 485 | await ctx.send(embed=em) 486 | else: 487 | em = nextcord.Embed( 488 | title="**Command on cooldown**", 489 | description=f" You must wait `{int(h)}` hours, `{int(m)}` minutes and `{int(s)}` seconds to use this command!", 490 | ) 491 | await ctx.send(embed=em) 492 | return 493 | if isinstance(error, commands.DisabledCommand): 494 | em = nextcord.Embed( 495 | title="Command Disabled", 496 | description="It seems the command you are trying to use has been disabled", 497 | ) 498 | await ctx.send(embed=em) 499 | return 500 | if isinstance(error, commands.MissingPermissions): 501 | missing = [ 502 | perm.replace("_", " ").replace("guild", "server").title() 503 | for perm in error.missing_perms 504 | ] 505 | if len(missing) > 2: 506 | fmt = "{}, and {}".format("**, **".join(missing[:-1]), missing[-1]) 507 | else: 508 | fmt = " and ".join(missing) 509 | _message = "You require the `{}` permission to use this command.".format(fmt) 510 | em = nextcord.Embed(title="Invalid Permissions", description=_message) 511 | await ctx.send(embed=em) 512 | return 513 | if isinstance(error, commands.MissingRequiredArgument): 514 | embed=Embed(title="Missing Required Arguments!", description=error, color=Color.red()) 515 | await ctx.send(embed=embed) 516 | if isinstance(error, commands.BotMissingPermissions): 517 | missing = [ 518 | perm.replace("_", " ").replace("guild", "server").title() 519 | for perm in error.missing_perms 520 | ] 521 | if len(missing) > 2: 522 | fmt = "{}, and {}".format("**, **".join(missing[:-1]), missing[-1]) 523 | else: 524 | fmt = " and ".join(missing) 525 | _message = "I require the `{}` permission to use this command.".format(fmt) 526 | em = nextcord.Embed(title="Invalid Permissions", description=_message) 527 | await ctx.send(embed=em) 528 | return 529 | if isinstance(error, commands.BadArgument): 530 | em = nextcord.Embed( 531 | title="Bad Argument", 532 | description="The library ran into an error attempting to parse your argument.", 533 | ) 534 | await ctx.send(embed=em) 535 | return 536 | if isinstance(error, nextcord.NotFound) and "Unknown interaction" in str(error): 537 | return 538 | exception = "\n".join( 539 | traceback.format_exception(type(error), error, error.__traceback__) 540 | ) 541 | for ERROR_CHANNEL in ERROR_CHANNELS: 542 | try: 543 | error_channel = await client.fetch_channel(int(ERROR_CHANNEL)) 544 | except: 545 | print(f"Can't Fetch The Error Channel With ID: `{ERROR_CHANNEL}`") 546 | return print(exception) 547 | error_em = nextcord.Embed( 548 | title=error.__class__.__name__, 549 | description=f""" 550 | Message: ```txt\n{ctx.message.content}``` 551 | Command: {ctx.command} 552 | Error Treaceback: ```py\n{exception}```""", 553 | color=nextcord.Color.red(), 554 | ) 555 | try: 556 | await error_channel.send(embed=error_em) 557 | except: 558 | print( 559 | f"Was Not Able To Send The Error In The Channel With ID: `{error_channel.id}`" 560 | ) 561 | em = nextcord.Embed( 562 | title="Error ;-;", 563 | description=f"There was an error in the command `{ctx.command}`\nThe developers have been informed about the error, please refrain from using this command again!", 564 | ) 565 | await ctx.channel.send( 566 | embed=em 567 | ) # Doing this so even when slash commands are implemented, the error handler still works just fine. 568 | print(exception) 569 | 570 | 571 | client.run(TOKEN) 572 | -------------------------------------------------------------------------------- /cogs/util.py: -------------------------------------------------------------------------------- 1 | """ Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. """ 374 | 375 | import time 376 | import nextcord 377 | import os 378 | import psutil 379 | import random 380 | from datetime import datetime 381 | from nextcord.ext import commands, tasks 382 | from global_functions import ban_msg, kick_msg, BOT_USER_ID, EMOJIS_TO_USE_FOR_CALCULATOR as etufc 383 | import aiohttp 384 | from io import BytesIO 385 | import requests 386 | from nextcord import ButtonStyle 387 | from nextcord.ui import button, View, Button 388 | 389 | green_button_style = ButtonStyle.success 390 | grey_button_style = ButtonStyle.secondary 391 | blue_button_style = ButtonStyle.primary 392 | red_button_style = ButtonStyle.danger 393 | 394 | 395 | class CalculatorButtons(View): 396 | def __init__(self, owner, embed, message): 397 | self.embed = embed 398 | self.owner = owner 399 | self.message = message 400 | self.expression = "" 401 | super().__init__(timeout=300.0) 402 | 403 | @button(emoji=etufc['1'], style=grey_button_style, row=1) 404 | async def one_callback(self, button, interaction: nextcord.Interaction): 405 | if interaction.user.id != self.owner.id: 406 | return 407 | self.expression += "1" 408 | self.embed.description = self.expression 409 | await interaction.response.edit_message(embed=self.embed) 410 | 411 | @button(emoji=etufc['2'], style=grey_button_style, row=1) 412 | async def two_callback(self, button, interaction: nextcord.Interaction): 413 | if interaction.user.id != self.owner.id: 414 | return 415 | self.expression += "2" 416 | self.embed.description = self.expression 417 | await interaction.response.edit_message(embed=self.embed) 418 | 419 | @button(emoji=etufc['3'], style=grey_button_style, row=1) 420 | async def three_callback(self, button, interaction: nextcord.Interaction): 421 | if interaction.user.id != self.owner.id: 422 | return 423 | self.expression += "3" 424 | self.embed.description = self.expression 425 | await interaction.response.edit_message(embed=self.embed) 426 | 427 | @button(emoji=etufc['4'], style=grey_button_style, row=2) 428 | async def four_callback(self, button, interaction: nextcord.Interaction): 429 | if interaction.user.id != self.owner.id: 430 | return 431 | self.expression += "4" 432 | self.embed.description = self.expression 433 | await interaction.response.edit_message(embed=self.embed) 434 | 435 | @button(emoji=etufc['5'], style=grey_button_style, row=2) 436 | async def five_callback(self, button, interaction: nextcord.Interaction): 437 | if interaction.user.id != self.owner.id: 438 | return 439 | self.expression += "5" 440 | self.embed.description = self.expression 441 | await interaction.response.edit_message(embed=self.embed) 442 | 443 | @button(emoji=etufc['6'], style=grey_button_style, row=2) 444 | async def six_callback(self, button, interaction: nextcord.Interaction): 445 | if interaction.user.id != self.owner.id: 446 | return 447 | self.expression += "6" 448 | self.embed.description = self.expression 449 | await interaction.response.edit_message(embed=self.embed) 450 | 451 | @button(emoji=etufc['7'], style=grey_button_style, row=3) 452 | async def seven_callback(self, button, interaction: nextcord.Interaction): 453 | if interaction.user.id != self.owner.id: 454 | return 455 | self.expression += "7" 456 | self.embed.description = self.expression 457 | await interaction.response.edit_message(embed=self.embed) 458 | 459 | @button(emoji=etufc['8'], style=grey_button_style, row=3) 460 | async def eight_callback(self, button, interaction: nextcord.Interaction): 461 | if interaction.user.id != self.owner.id: 462 | return 463 | self.expression += "8" 464 | self.embed.description = self.expression 465 | await interaction.response.edit_message(embed=self.embed) 466 | 467 | @button(emoji=etufc['9'], style=grey_button_style, row=3) 468 | async def nine_callback(self, button, interaction: nextcord.Interaction): 469 | if interaction.user.id != self.owner.id: 470 | return 471 | self.expression += "9" 472 | self.embed.description = self.expression 473 | await interaction.response.edit_message(embed=self.embed) 474 | 475 | @button(emoji=etufc['0'], style=grey_button_style, row=4) 476 | async def zero_callback(self, button, interaction: nextcord.Interaction): 477 | if interaction.user.id != self.owner.id: 478 | return 479 | self.expression += "0" 480 | self.embed.description = self.expression 481 | await interaction.response.edit_message(embed=self.embed) 482 | 483 | @button(label="00 ", style=grey_button_style, row=4) 484 | async def double_zero_callback(self, button, interaction: nextcord.Interaction): 485 | if interaction.user.id != self.owner.id: 486 | return 487 | self.expression += "00" 488 | self.embed.description = self.expression 489 | await interaction.response.edit_message(embed=self.embed) 490 | 491 | @button(emoji=etufc['.'], style=grey_button_style, row=4) 492 | async def dot_callback(self, button, interaction: nextcord.Interaction): 493 | if interaction.user.id != self.owner.id: 494 | return 495 | self.expression += "." 496 | self.embed.description = self.expression 497 | await interaction.response.edit_message(embed=self.embed) 498 | 499 | @button(emoji=etufc['x'], style=blue_button_style, row=1, custom_id="*") 500 | async def multiplication_callback(self, button, interaction: nextcord.Interaction): 501 | if interaction.user.id != self.owner.id: 502 | return 503 | self.expression += "x" 504 | self.embed.description = self.expression 505 | await interaction.response.edit_message(embed=self.embed) 506 | 507 | @button(emoji=etufc['÷'], style=blue_button_style, row=2, custom_id="/") 508 | async def division_callback(self, button, interaction: nextcord.Interaction): 509 | if interaction.user.id != self.owner.id: 510 | return 511 | self.expression += "÷" 512 | self.embed.description = self.expression 513 | await interaction.response.edit_message(embed=self.embed) 514 | 515 | @button(emoji=etufc['+'], style=blue_button_style, row=3) 516 | async def addition_callback(self, button, interaction: nextcord.Interaction): 517 | if interaction.user.id != self.owner.id: 518 | return 519 | self.expression += "+" 520 | self.embed.description = self.expression 521 | await interaction.response.edit_message(embed=self.embed) 522 | 523 | @button(emoji=etufc['-'], style=blue_button_style, row=4) 524 | async def subtraction_callback(self, button, interaction: nextcord.Interaction): 525 | if interaction.user.id != self.owner.id: 526 | return 527 | self.expression += "-" 528 | self.embed.description = self.expression 529 | await interaction.response.edit_message(embed=self.embed) 530 | 531 | @button(label="←", style=red_button_style, row=1) 532 | async def back_space_callback(self, button, interaction: nextcord.Interaction): 533 | if interaction.user.id != self.owner.id: 534 | return 535 | self.expression = self.expression[:-1] 536 | self.embed.description = self.expression 537 | await interaction.response.edit_message(embed=self.embed) 538 | 539 | @button(label="Clear", style=red_button_style, row=2) 540 | async def clear_callback(self, button, interaction: nextcord.Interaction): 541 | if interaction.user.id != self.owner.id: 542 | return 543 | self.expression = "" 544 | self.embed.description = "Cleared Calculator" 545 | await interaction.response.edit_message(embed=self.embed) 546 | 547 | @button(label="Exit", style=red_button_style, row=3) 548 | async def exit_callback(self, button, interaction: nextcord.Interaction): 549 | if interaction.user.id != self.owner.id: 550 | return 551 | for child in self.children: 552 | child.disabled = True 553 | embed = nextcord.Embed(title="Abandoned Calculator", color=nextcord.Color.red()) 554 | await interaction.response.edit_message(embed=embed, view=self) 555 | 556 | @button(label="=", style=green_button_style, row=4) 557 | async def equal_to_callback(self, button, interaction: nextcord.Interaction): 558 | if interaction.user.id != self.owner.id: 559 | return 560 | expression = self.expression 561 | expression = expression.replace("÷", "/").replace("x", "*") 562 | try: 563 | result = str(eval(expression)) 564 | self.expression = result 565 | except: 566 | result = "An Error Occured ;-;" 567 | self.embed.description = result 568 | await interaction.response.edit_message(embed=self.embed) 569 | 570 | async def on_timeout(self): 571 | for child in self.children: 572 | child.disabled = True 573 | embed = nextcord.Embed(title="Time Up", color=nextcord.Color.red()) 574 | await self.message.edit(embed=embed, view=self) 575 | 576 | 577 | us = 0 578 | um = 0 579 | uh = 0 580 | ud = 0 581 | 582 | 583 | class util(commands.Cog): 584 | def __init__(self, client): 585 | self.client = client 586 | self.clientuptime.start() 587 | 588 | @commands.command(description="A handy Calculator!", aliases=["calc"]) 589 | async def calculator(self, ctx): 590 | message = await ctx.send("Loading Calculator....") 591 | embed = nextcord.Embed( 592 | title=f"{ctx.author}'s Calculator", 593 | color=nextcord.Color.green(), 594 | description="This is the start of the calculator!", 595 | ) 596 | view = CalculatorButtons(ctx.author, embed, message) 597 | await message.edit(content=None, embed=embed, view=view) 598 | 599 | @commands.command(description="Shows the user's info.") 600 | async def userinfo(self, ctx, *, user: nextcord.Member = None): # b'\xfc' 601 | if user is None: 602 | user = ctx.author 603 | date_format = "%a, %d %b %Y %I:%M %p" 604 | embed = nextcord.Embed(color=0xDFA3FF, description=user.mention) 605 | embed.set_author(name=str(user.name), icon_url=user.display_avatar) 606 | embed.set_thumbnail(url=user.display_avatar) 607 | embed.add_field(name="Joined", value=user.joined_at.strftime(date_format)) 608 | members = sorted(ctx.guild.members, key=lambda m: m.joined_at) 609 | embed.add_field(name="Join position", value=str(members.index(user) + 1)) 610 | embed.add_field(name="Registered", value=user.created_at.strftime(date_format)) 611 | if len(user.roles) > 1: 612 | role_string = " ".join([r.mention for r in user.roles][1:]) 613 | embed.add_field( 614 | name="Roles [{}]".format(len(user.roles) - 1), 615 | value=role_string, 616 | inline=False, 617 | ) 618 | perm_paginator = commands.Paginator(prefix="```diff", max_size=1000) 619 | for p in user.guild_permissions: 620 | perm_paginator.add_line( 621 | f"{'+' if p[1] else '-'} {str(p[0]).replace('_', ' ').title()}" 622 | ) 623 | embed.add_field( 624 | name="Guild permissions", value=f"{perm_paginator.pages[0]}", inline=False 625 | ) 626 | embed.set_footer( 627 | text=self.client.user.name, icon_url=self.client.user.display_avatar 628 | ) 629 | return await ctx.send(embed=embed) 630 | 631 | @commands.command(description="Shows the server's description.") 632 | async def serverinfo(self, ctx): 633 | role_count = len(ctx.guild.roles) 634 | list_of_bots = [bot.mention for bot in ctx.guild.members if bot.bot] 635 | 636 | embed2 = nextcord.Embed( 637 | timestamp=ctx.message.created_at, color=ctx.author.color 638 | ) 639 | embed2.add_field(name="Name", value=f"{ctx.guild.name}", inline=False) 640 | embed2.add_field( 641 | name="Verification Level", 642 | value=str(ctx.guild.verification_level), 643 | inline=True, 644 | ) 645 | embed2.add_field(name="Highest role", value=ctx.guild.roles[-1], inline=True) 646 | embed2.add_field(name="Number of roles", value=str(role_count), inline=True) 647 | embed2.add_field( 648 | name="Number Of Members", value=ctx.guild.member_count, inline=True 649 | ) 650 | embed2.add_field( 651 | name="Created At", 652 | value=ctx.guild.created_at.__format__("%A, %d. %B %Y @ %H:%M:%S"), 653 | inline=True, 654 | ) 655 | embed2.add_field(name="Bots:", value=(", ".join(list_of_bots)), inline=False) 656 | embed2.set_thumbnail(url=ctx.guild.icon.url) 657 | embed2.set_author(name=ctx.author.name, icon_url=ctx.author.display_avatar) 658 | embed2.set_footer( 659 | text=self.client.user.name, icon_url=self.client.user.display_avatar 660 | ) 661 | await ctx.send(embed=embed2) 662 | 663 | @commands.command( 664 | aliases=["cs", "ci", "channelinfo"], description="Shows the channel's stats." 665 | ) 666 | async def channelstats(self, ctx, channel: nextcord.TextChannel = None): 667 | if channel == None: 668 | channel = ctx.channel 669 | 670 | embed = nextcord.Embed( 671 | title=f"{channel.name}", 672 | description=f"{'Category - `{}`'.format(channel.category.name) if channel.category else '`This channel is not in a category`'}", 673 | ) 674 | embed.add_field(name="Guild", value=ctx.guild.name, inline=True) 675 | embed.add_field(name="Channel Id", value=channel.id, inline=True) 676 | embed.add_field( 677 | name="Channel Topic", 678 | value=f"{channel.topic if channel.topic else 'No topic'}", 679 | inline=False, 680 | ) 681 | embed.add_field(name="Channel Position", value=channel.position, inline=True) 682 | embed.add_field(name="Slowmode", value=channel.slowmode_delay, inline=True) 683 | embed.add_field(name="NSFW", value=channel.is_nsfw(), inline=True) 684 | embed.add_field(name="Annoucement", value=channel.is_news(), inline=True) 685 | embed.add_field( 686 | name="Channel Permissions", value=channel.permissions_synced, inline=True 687 | ) 688 | embed.add_field(name="Channel Hash", value=hash(channel), inline=False) 689 | embed.set_thumbnail(url=ctx.guild.icon.url) 690 | embed.set_author(name=ctx.author.name, icon_url=ctx.author.display_avatar) 691 | embed.set_footer( 692 | text=self.client.user.name, icon_url=self.client.user.display_avatar 693 | ) 694 | await ctx.send(embed=embed) 695 | 696 | @commands.command(alisas=["adde"], description="Adds an emoji to the server.") 697 | async def emojiadd(self, ctx, url: str, *, name): 698 | guild = ctx.guild 699 | if ctx.author.guild_permissions.manage_emojis: 700 | async with aiohttp.ClientSession() as ses: 701 | async with ses.get(url) as r: 702 | 703 | try: 704 | img_or_gif = BytesIO(await r.read()) 705 | b_value = img_or_gif.getvalue() 706 | if r.status in range(200, 299): 707 | emoji = await guild.create_custom_emoji( 708 | image=b_value, name=name 709 | ) 710 | em = nextcord.Embed( 711 | title="Emoji Success", 712 | description=f"Successfully created emoji: <:{name}:{emoji.id}>", 713 | ) 714 | await ctx.send(embed=em) 715 | await ses.close() 716 | else: 717 | em = nextcord.Embed( 718 | title="Emoji Error", 719 | description=f"Error when making request | {r.status} response.", 720 | ) 721 | await ctx.send(embed=em) 722 | await ses.close() 723 | 724 | except nextcord.HTTPException: 725 | em = nextcord.Embed( 726 | title="Emoji Error", description="File size is too big!" 727 | ) 728 | await ctx.send(embed=em) 729 | 730 | @commands.command( 731 | alisas=["removee"], description="Removes the specified emoji from the server." 732 | ) 733 | async def emojiremove(self, ctx, emoji: nextcord.Emoji): 734 | guild = ctx.guild 735 | if ctx.author.guild_permissions.manage_emojis: 736 | em = nextcord.Embed( 737 | title="Emoji Success", 738 | description=f"Successfully deleted (or not :P) {emoji}", 739 | ) 740 | await ctx.send(embed=em) 741 | await emoji.delete() 742 | 743 | @commands.command(name="toggle", description="Enable or disable a command!") 744 | @commands.is_owner() 745 | async def toggle(self, ctx, *, command): 746 | command = self.client.get_command(command) 747 | 748 | if command is None: 749 | embed = nextcord.Embed( 750 | title="ERROR", description="I can't find a command with that name" 751 | ) 752 | await ctx.send(embed=embed) 753 | 754 | elif ctx.command == command: 755 | embed = nextcord.Embed( 756 | title="ERROR", description="You cannot disable this command " 757 | ) 758 | await ctx.send(embed=embed) 759 | 760 | else: 761 | command.enabled = not command.enabled 762 | ternary = "enabled" if command.enabled else "disabled" 763 | embed = nextcord.Embed(title="Toggle", description=ternary) 764 | await ctx.send(embed=embed) 765 | 766 | @commands.command(name="steal", description="Steals an emoji form a server") 767 | async def steal(self, ctx, emoji: nextcord.PartialEmoji, *, text=None): 768 | 769 | if ctx.author.guild_permissions.manage_emojis: 770 | 771 | if text == None: 772 | text = emoji.name 773 | else: 774 | text = text.replace(" ", "_") 775 | 776 | r = requests.get(emoji.url, allow_redirects=True) 777 | 778 | if emoji.animated == True: 779 | open("emoji.gif", "wb").write(r.content) 780 | with open("emoji.gif", "rb") as f: 781 | z = await ctx.guild.create_custom_emoji(name=text, image=f.read()) 782 | os.remove("emoji.gif") 783 | 784 | else: 785 | open("emoji.png", "wb").write(r.content) 786 | with open("emoji.png", "rb") as f: 787 | z = await ctx.guild.create_custom_emoji(name=text, image=f.read()) 788 | os.remove("emoji.png") 789 | 790 | embed = nextcord.Embed( 791 | title="Success", 792 | description=f"Succesfully Cloned {z}", 793 | color=nextcord.Color.green(), 794 | ) 795 | await ctx.send(embed=embed) 796 | 797 | @commands.command(description="Shows the ping of the bot") 798 | @commands.cooldown(1, 15, commands.BucketType.user) 799 | async def ping(self, ctx): 800 | em = nextcord.Embed(title="Pong!🏓", colour=nextcord.Colour.random()) 801 | em.add_field( 802 | name="My API Latency is:", value=f"{round(self.client.latency*1000)} ms!" 803 | ) 804 | em.set_footer( 805 | text=f"Ping requested by {ctx.author}", icon_url=ctx.author.display_avatar 806 | ) 807 | await ctx.send(embed=em) 808 | 809 | 810 | 811 | @tasks.loop(seconds=2.0) 812 | async def clientuptime(self): 813 | global uh, us, um, ud 814 | us += 2 815 | if us == 60: 816 | us = 0 817 | um += 1 818 | if um == 60: 819 | um = 0 820 | uh += 1 821 | if uh == 24: 822 | uh = 0 823 | ud += 1 824 | 825 | @clientuptime.before_loop 826 | async def before_clientuptime(self): 827 | print("waiting...") 828 | await self.client.wait_until_ready() 829 | 830 | @commands.command( 831 | aliases=["statistics", "stat", "statistic"], 832 | description="Shows the bot's statistics", 833 | ) 834 | @commands.cooldown(1, 15, commands.BucketType.user) 835 | async def stats(self, ctx): 836 | global ud, um, uh, us 837 | em = nextcord.Embed(title="How long have I been up?") 838 | em.add_field(name="Days:", value=ud, inline=False) 839 | em.add_field(name="Hours:", value=uh, inline=False) 840 | em.add_field(name="Minutes:", value=um, inline=False) 841 | em.add_field(name="Seconds:", value=us, inline=False) 842 | em.add_field(name="CPU usage:", value=f"{psutil.cpu_percent()}%", inline=False) 843 | em.add_field( 844 | name="RAM usage:", value=f"{psutil.virtual_memory()[2]}%", inline=False 845 | ) 846 | em.set_footer( 847 | text=f"Stats requested by: {ctx.author}", icon_url=ctx.author.display_avatar 848 | ) 849 | await ctx.send(embed=em) 850 | 851 | 852 | def setup(client): 853 | client.add_cog(util(client)) 854 | -------------------------------------------------------------------------------- /cogs/moderation.py: -------------------------------------------------------------------------------- 1 | #This Code Is Under The MPL-2.0 License 2 | 3 | import nextcord 4 | from nextcord.ext import commands 5 | import json 6 | from global_functions import ban_msg, kick_msg, BOT_USER_ID, read_database, write_database, PREFIX 7 | import random 8 | import asyncio 9 | from difflib import get_close_matches 10 | 11 | 12 | class BanConfirm(nextcord.ui.View): 13 | async def interaction_check(self,interaction): 14 | if self.ctx.author != interaction.user: 15 | await interaction.response.send_message('Not your message', ephemeral=True) 16 | return False 17 | return True 18 | async def on_timeout(self): 19 | for child in self.children: 20 | child.disabled = True 21 | await self.message.edit(view=self) 22 | def __init__(self,ctx,**kwargs): 23 | super().__init__(timeout=60,**kwargs) 24 | self.value = None 25 | self.ctx = ctx 26 | 27 | @nextcord.ui.button( 28 | label="Confirm", style=nextcord.ButtonStyle.green, custom_id="yes" 29 | ) 30 | async def confirm( 31 | self, button: nextcord.ui.Button, interaction: nextcord.Interaction 32 | ): 33 | self.value = True 34 | self.stop() 35 | 36 | @nextcord.ui.button(label="Cancel", style=nextcord.ButtonStyle.red, custom_id="no") 37 | async def cancel( 38 | self, button: nextcord.ui.Button, interaction: nextcord.Interaction 39 | ): 40 | self.value = False 41 | self.stop() 42 | 43 | class LockConfirm(nextcord.ui.View): 44 | async def interaction_check(self,interaction): 45 | if self.ctx.author != interaction.user: 46 | await interaction.response.send_message('Not your message', ephemeral=True) 47 | return False 48 | return True 49 | async def on_timeout(self): 50 | for child in self.children: 51 | child.disabled = True 52 | await self.message.edit(view=self) 53 | def __init__(self,ctx,**kwargs): 54 | super().__init__(timeout=60,**kwargs) 55 | self.value = None 56 | self.ctx = ctx 57 | 58 | @nextcord.ui.button( 59 | label="Confirm", style=nextcord.ButtonStyle.green, custom_id="yes" 60 | ) 61 | async def confirm( 62 | self, button: nextcord.ui.Button, interaction: nextcord.Interaction 63 | ): 64 | self.value = True 65 | self.stop() 66 | 67 | @nextcord.ui.button(label="Cancel", style=nextcord.ButtonStyle.red, custom_id="no") 68 | async def cancel( 69 | self, button: nextcord.ui.Button, interaction: nextcord.Interaction 70 | ): 71 | self.value = False 72 | self.stop() 73 | 74 | class Moderation(commands.Cog): 75 | def __init__(self, client): 76 | self.client = client 77 | 78 | @commands.Cog.listener() 79 | async def on_message(self, message): 80 | if str(message.author.id) != str(BOT_USER_ID): 81 | send = message.channel.send 82 | 83 | @commands.command(name="ban", description="Bans the member from your server.") 84 | @commands.has_permissions(ban_members=True) 85 | async def ban(self, ctx, member: nextcord.Member = None, *, reason=None): 86 | if member == None: 87 | embed1 = nextcord.Embed( 88 | title="Ban Error", description="Member to ban - Not Found" 89 | ) 90 | return await ctx.send(embed=embed1) 91 | if member.id == ctx.author.id: 92 | embed69 = nextcord.Embed( 93 | title="Ban Error", 94 | description="Can not ban yourself, trust me I woulda ages ago <:hehe:796743161208504320>", 95 | ) 96 | return await ctx.send(embed=embed69) 97 | elif ctx.author.top_role.position < member.top_role.position: 98 | em3 = nextcord.Embed( 99 | title="Ban Error", 100 | description="Member **higher** than you in the role heirarchy - Invalid Permission", 101 | ) 102 | return await ctx.send(embed=em3) 103 | elif ctx.author.top_role.position == member.top_role.position: 104 | em3 = nextcord.Embed( 105 | title="Ban Error", 106 | description="Member has same role as you in the role heirarchy - Invalid Permission", 107 | ) 108 | return await ctx.send(embed=em3) 109 | guild = ctx.guild 110 | banMsg = random.choice(ban_msg) 111 | banEmbed = nextcord.Embed( 112 | title="Ban Success", description=f"{member.mention} {banMsg}" 113 | ) 114 | banEmbed.add_field(name="Reason", value=reason) 115 | await ctx.send(embed=banEmbed) 116 | await member.send(f"You got banned in **{guild}** | Reason: **{reason}**") 117 | await member.ban(reason=reason) 118 | 119 | @commands.command(description="Unbans a member from your server by ID") 120 | @commands.has_permissions(ban_members=True) 121 | async def unban(self, ctx, id: int): 122 | user = await self.client.fetch_user(id) 123 | await ctx.guild.unban(user) 124 | em = nextcord.Embed(title="Unban Success", description="Unbanned user :D") 125 | await ctx.send(embed=em) 126 | 127 | @commands.command(name="kick", description="Kicks the member from your server.") 128 | @commands.has_permissions(kick_members=True) 129 | async def kick(self, ctx, member: nextcord.Member = None, *, reason=None): 130 | if member == None: 131 | embed1 = nextcord.Embed( 132 | title="Kick Error", description="Member to kick - Not Found" 133 | ) 134 | return await ctx.send(embed=embed1) 135 | if not (ctx.guild.me.guild_permissions.kick_members): 136 | embed2 = nextcord.Embed( 137 | title="Kick Error", 138 | description="I require the ``Kick Members`` permisson to run this command - Missing Permission", 139 | ) 140 | return await ctx.send(embed=embed2) 141 | if member.id == ctx.author.id: 142 | embed69 = nextcord.Embed( 143 | title="Kick Error", 144 | description="You sadly can not kick your self ", 145 | ) 146 | return await ctx.send(embed=embed69) 147 | elif ctx.author.top_role.position < member.top_role.position: 148 | em3 = nextcord.Embed( 149 | title="Kick Error", 150 | description="Member **higher** than you in the role heirarchy - Invalid Permission", 151 | ) 152 | return await ctx.send(embed=em3) 153 | elif ctx.author.top_role.position == member.top_role.position: 154 | em3 = nextcord.Embed( 155 | title="Kick Error", 156 | description="Member has same role as you in the role heirarchy - Invalid Permission", 157 | ) 158 | return await ctx.send(embed=em3) 159 | guild = ctx.guild 160 | kickMsg = random.choice(kick_msg) 161 | kickEmbed = nextcord.Embed( 162 | title="Kick Success", description=f"{member.mention} {kickMsg}" 163 | ) 164 | kickEmbed.add_field(name="Reason", value=reason) 165 | await ctx.send(embed=kickEmbed) 166 | await member.send(f"You got kicked in **{guild}** | Reason: **{reason}**") 167 | await member.kick(reason=reason) 168 | 169 | @commands.command(name="tempmute", description="Mutes a member indefinitely.") 170 | @commands.has_permissions(manage_messages=True) 171 | async def tempmute( 172 | self, ctx, member: nextcord.Member = None, time=None, *, reason=None 173 | ): 174 | guild = ctx.guild 175 | if member == None: 176 | em1 = nextcord.Embed( 177 | title="Tempmute Error", description="Member to mute - Not Found" 178 | ) 179 | return await ctx.send(embed=em1) 180 | elif member.id == ctx.author.id: 181 | em5 = nextcord.Embed( 182 | title="Tempmute Error", description="Don't bother, ive tried" 183 | ) 184 | return await ctx.send(embed=em5) 185 | if time == None: 186 | em2 = nextcord.Embed( 187 | title="Tempmute Error", description="Time to mute - Not Found" 188 | ) 189 | return await ctx.send(embed=em2) 190 | elif ctx.author.top_role.position < member.top_role.position: 191 | em3 = nextcord.Embed( 192 | title="Tempmute Error", 193 | description="Member **higher** than you in the role heirarchy - Invalid Permission", 194 | ) 195 | return await ctx.send(embed=em3) 196 | if not (ctx.guild.me.guild_permissions.manage_roles): 197 | embed2 = nextcord.Embed( 198 | title="Tempmute Error", 199 | description="I require the ``Manage Roles`` permisson to run this command - Missing Permission", 200 | ) 201 | return await ctx.send(embed=embed2) 202 | elif ctx.author.top_role.position == member.top_role.position: 203 | em4 = nextcord.Embed( 204 | title="Tempmute Error", 205 | description="Member has same role as you in the role heirarchy - Invalid Permission", 206 | ) 207 | return await ctx.send(embed=em4) 208 | mutedRole = nextcord.utils.get(guild.roles, name="Muted") 209 | if ctx.guild.me.top_role.position < mutedRole.position: 210 | em3 = nextcord.Embed( 211 | title="Tempmute Error", 212 | description="Muted role too high to give to a member", 213 | ) 214 | return await ctx.send(embed=em3) 215 | if not mutedRole: 216 | mutedRole = await guild.create_role(name="Muted") 217 | await ctx.send("No mute role found. Creating mute role...") 218 | for channel in guild.channels: 219 | await channel.set_permissions( 220 | mutedRole, 221 | speak=False, 222 | send_messages=False, 223 | read_message_history=True, 224 | ) 225 | 226 | if not time == None: 227 | time_convert = {"s": 1, "m": 60, "h": 3600, "d": 86400} 228 | tempmute = int(time[0]) * time_convert[time[-1]] 229 | embed = nextcord.Embed( 230 | title="Tempmute Success", 231 | description=f"{member.mention} was muted ", 232 | colour=nextcord.Colour.blue(), 233 | ) 234 | embed.add_field(name="Reason:", value=reason, inline=False) 235 | embed.add_field(name="Duration", value=time) 236 | await ctx.send(embed=embed) 237 | await member.add_roles(mutedRole, reason=reason) 238 | await member.send( 239 | f"You have been muted from: **{guild.name}** | Reason: **{reason}** | Time: **{time}**" 240 | ) 241 | if not time == None: 242 | await asyncio.sleep(tempmute) 243 | await member.remove_roles(mutedRole) 244 | await member.send(f"You have been unmuted from **{guild}**") 245 | return 246 | 247 | @commands.command( 248 | name="mute", description="Mutes a member for a specific amount of time." 249 | ) 250 | @commands.has_permissions(manage_messages=True) 251 | async def mute(self, ctx, member: nextcord.Member = None, *, reason=None): 252 | guild = ctx.guild 253 | if member == None: 254 | em1 = nextcord.Embed( 255 | title="Mute Error", description="Member to mute - Not Found" 256 | ) 257 | return await ctx.send(embed=em1) 258 | elif member.id == ctx.author.id: 259 | em5 = nextcord.Embed( 260 | title="Mute Error", description="Don't bother, ive tried" 261 | ) 262 | return await ctx.send(embed=em5) 263 | elif ctx.author.top_role.position < member.top_role.position: 264 | em3 = nextcord.Embed( 265 | title="Mute Error", 266 | description="Member **higher** than you in the role heirarchy - Invalid Permission", 267 | ) 268 | return await ctx.send(embed=em3) 269 | elif ctx.author.top_role.position == member.top_role.position: 270 | em4 = nextcord.Embed( 271 | title="Mute Error", 272 | description="Member has same role as you in the role heirarchy - Invalid Permission", 273 | ) 274 | return await ctx.send(embed=em4) 275 | if not (ctx.guild.me.guild_permissions.manage_roles): 276 | embed2 = nextcord.Embed( 277 | title="Mute Error", 278 | description="I require the ``Manage Roles`` permisson to run this command - Missing Permission", 279 | ) 280 | return await ctx.send(embed=embed2) 281 | mutedRole = nextcord.utils.get(guild.roles, name="Muted") 282 | if ctx.guild.me.top_role.position < mutedRole.position: 283 | em3 = nextcord.Embed( 284 | title="Mute Error", 285 | description="Muted role too high to give to a member", 286 | ) 287 | return await ctx.send(embed=em3) 288 | if not mutedRole: 289 | mutedRole = await guild.create_role(name="Muted") 290 | await ctx.send("No mute role found. Creating mute role...") 291 | for channel in guild.channels: 292 | await channel.set_permissions( 293 | mutedRole, 294 | speak=False, 295 | send_messages=False, 296 | read_message_history=True, 297 | ) 298 | 299 | embed = nextcord.Embed( 300 | title="Mute Success", 301 | description=f"{member.mention} was muted ", 302 | colour=nextcord.Colour.blue(), 303 | ) 304 | embed.add_field(name="Reason:", value=reason, inline=False) 305 | await ctx.send(embed=embed) 306 | await member.add_roles(mutedRole, reason=reason) 307 | await member.send( 308 | f"You have been muted from: **{guild.name}** | Reason: **{reason}**" 309 | ) 310 | return 311 | 312 | @commands.command(name="unmute", description="Unmutes a muted member.") 313 | @commands.has_permissions(manage_messages=True) 314 | async def unmute(self, ctx, member: nextcord.Member = None, *, reason=None): 315 | guild = ctx.guild 316 | if member == None: 317 | em1 = nextcord.Embed( 318 | title="Unmute Error", description="Member to unmute - Not Found" 319 | ) 320 | return await ctx.send(embed=em1) 321 | elif member.id == ctx.author.id: 322 | em5 = nextcord.Embed( 323 | title="Unmute Error", description="wHat? <:WHA:815331017854025790>" 324 | ) 325 | return await ctx.send(embed=em5) 326 | elif ctx.author.top_role.position < member.top_role.position: 327 | em3 = nextcord.Embed( 328 | title="Unmute Error", 329 | description="Member **higher** than you in the role heirarchy - Invalid Permission", 330 | ) 331 | return await ctx.send(embed=em3) 332 | elif ctx.author.top_role.position == member.top_role.position: 333 | em4 = nextcord.Embed( 334 | title="Unmute Error", 335 | description="Member has same role as you in the role heirarchy - Invalid Permission", 336 | ) 337 | return await ctx.send(embed=em4) 338 | if not (ctx.guild.me.guild_permissions.manage_roles): 339 | embed2 = nextcord.Embed( 340 | title="Unmute Error", 341 | description="I require the ``Manage Roles`` permisson to run this command - Missing Permission", 342 | ) 343 | return await ctx.send(embed=embed2) 344 | mutedRole = nextcord.utils.get(guild.roles, name="Muted") 345 | if ctx.guild.me.top_role.position < mutedRole.position: 346 | em3 = nextcord.Embed( 347 | title="Unmute Error", 348 | description="Muted role too high to remove from a member", 349 | ) 350 | return await ctx.send(embed=em3) 351 | if not mutedRole: 352 | mutedRole = await guild.create_role(name="Muted") 353 | await ctx.send("No mute role found. Creating mute role...") 354 | for channel in guild.channels: 355 | await channel.set_permissions( 356 | mutedRole, 357 | speak=False, 358 | send_messages=False, 359 | read_message_history=True, 360 | ) 361 | 362 | embed = nextcord.Embed( 363 | title="Unmute Success", 364 | description=f"{member.mention} was unmuted ", 365 | colour=nextcord.Colour.blue(), 366 | ) 367 | embed.add_field(name="Reason:", value=reason, inline=False) 368 | await ctx.send(embed=embed) 369 | await member.remove_roles(mutedRole, reason=reason) 370 | await member.send( 371 | f"You have been unmuted from: **{guild.name}** | Reason: **{reason}**" 372 | ) 373 | return 374 | 375 | @commands.command(description="Clears a bundle of messages.") 376 | @commands.has_permissions(manage_messages=True) 377 | async def clear(self, ctx, amount=10): 378 | amount = amount + 1 379 | if amount > 101: 380 | em1 = nextcord.Embed( 381 | title="Clear Error", 382 | description="Purge limit exedeed - Greater than 100", 383 | ) 384 | return await ctx.send(embed=em1) 385 | else: 386 | await ctx.channel.purge(limit=amount) 387 | msg = await ctx.send("Cleared Messages") 388 | asyncio.sleep(10) 389 | await msg.delete() 390 | 391 | @commands.command(description="Change the channels slowmode.") 392 | @commands.has_permissions(manage_channels=True) 393 | async def slowmode(self, ctx, time: int): 394 | try: 395 | if time == 0: 396 | em1 = nextcord.Embed( 397 | title="Slowmode Success", description="Slowmode turned off" 398 | ) 399 | await ctx.send(embed=em1) 400 | await ctx.channel.edit(slowmode_delay=0) 401 | elif time > 21600: 402 | em2 = nextcord.Embed( 403 | title="Slowmode Error", description="Slowmode over 6 hours" 404 | ) 405 | await ctx.send(embed=em2) 406 | else: 407 | await ctx.channel.edit(slowmode_delay=time) 408 | em3 = nextcord.Embed( 409 | title="Slowmode Success", 410 | description=f"Slowmode set to {time} seconds", 411 | ) 412 | await ctx.send(embed=em3) 413 | except Exception: 414 | await ctx.send("Error has occoured, notifying dev team") 415 | print(Exception) 416 | 417 | @commands.command( 418 | aliases=["giverole", "addr"], description="Gives a member a certain role." 419 | ) 420 | @commands.has_permissions(manage_roles=True) 421 | async def addrole( 422 | self, ctx, member: nextcord.Member = None, *, role: nextcord.Role = None 423 | ): 424 | if member is None: 425 | embed = nextcord.Embed( 426 | title="Add Role Error", 427 | description="Please ping a user to give them a role!", 428 | ) 429 | await ctx.send(embed=embed) 430 | return 431 | if role is None: 432 | embed = nextcord.Embed( 433 | title="Add Role Error", 434 | description="Please ping a role to give {} that role!".format( 435 | member.mention 436 | ), 437 | ) 438 | await ctx.send(embed=embed) 439 | return 440 | if ctx.author.top_role.position < role.position: 441 | em = nextcord.Embed( 442 | title="Add Role Error", 443 | description="You do not have enough permissions to give this role", 444 | ) 445 | return await ctx.send(embed=em) 446 | if ctx.guild.me.top_role.position < role.position: 447 | embed = nextcord.Embed( 448 | title="Add Role Error", 449 | description="That role is too high for me to perform this action", 450 | ) 451 | return await ctx.send(embed=embed) 452 | try: 453 | addRole = True 454 | for role_ in member.roles: 455 | if role_ == role: 456 | addRole = False 457 | break 458 | if not addRole: 459 | embed = nextcord.Embed( 460 | title="Add Role Error", 461 | description=f"{member.mention} already has the role you are trying to give", 462 | ) 463 | await ctx.send(embed=embed) 464 | return 465 | else: 466 | em = nextcord.Embed( 467 | title="Add Role Success", 468 | description=f"{role.mention} has been assigned to {member.mention}", 469 | ) 470 | await ctx.send(embed=em) 471 | await member.add_roles(role) 472 | return 473 | except Exception: 474 | print(Exception) 475 | 476 | @commands.command( 477 | aliases=["takerole", "remover"], 478 | description="Removes a certain role from a member.", 479 | ) 480 | @commands.has_permissions(manage_roles=True) 481 | async def removerole( 482 | self, 483 | ctx, 484 | member: nextcord.Member = None, 485 | role: nextcord.Role = None, 486 | *, 487 | reason=None, 488 | ): 489 | if member is None: 490 | embed = nextcord.Embed( 491 | title="Remove Role Error", 492 | description="Please ping a user to remove a role from them!", 493 | ) 494 | await ctx.send(embed=embed) 495 | return 496 | if role is None: 497 | embed = nextcord.Embed( 498 | title="Remove Role Error", 499 | description="Please ping a role to remove the role from {}!".format( 500 | member.mention 501 | ), 502 | ) 503 | await ctx.send(embed=embed) 504 | return 505 | if ctx.author.top_role.position < role.position: 506 | em = nextcord.Embed( 507 | title="Remove Role Error", 508 | description="You do not have enough permissions to remove this role", 509 | ) 510 | return await ctx.send(embed=em) 511 | if ctx.guild.me.top_role.position < role.position: 512 | embed = nextcord.Embed( 513 | title="Remove Role Error", 514 | description="That role is too high for me to perform this action", 515 | ) 516 | return await ctx.send(embed=embed) 517 | try: 518 | roleRemoved = False 519 | for role_ in member.roles: 520 | if role_ == role: 521 | await member.remove_roles(role) 522 | roleRemoved = True 523 | break 524 | if not roleRemoved: 525 | embed = nextcord.Embed( 526 | title="Remove Role Error", 527 | description=f"{member.mention} already has the role you are trying to give", 528 | ) 529 | await ctx.send(embed=embed) 530 | return 531 | else: 532 | em = nextcord.Embed( 533 | title="Remove Role Success!", 534 | description=f"{role.mention} has been removed from {member.mention}", 535 | ) 536 | await ctx.send(embed=em) 537 | return 538 | except Exception: 539 | print(Exception) 540 | 541 | @commands.command(description="Locks the channel.") 542 | @commands.has_permissions(kick_members=True) 543 | async def lock(self, ctx, channel: nextcord.TextChannel = None, setting = None): 544 | if setting == '--server': 545 | view = LockConfirm() 546 | em = nextcord.Embed( 547 | title="Are you sure?", 548 | description="This is a very risky command only to be used in important situations such as, `Raid on the Server`. **If this command is used for the wrong purpose you may risk getting demoted if not banned from the staff team.**", 549 | ) 550 | await ctx.author.send(embed = em, view=view) 551 | await view.wait() 552 | if view.value is None: 553 | await ctx.author.send("Command has been Timed Out, please try again.") 554 | elif view.value: 555 | for channel in ctx.guild.channels: 556 | await channel.set_permissions( 557 | ctx.guild.default_role, 558 | reason=f"{ctx.author.name} locked {channel.name} using --server override", 559 | send_messages=False, 560 | ) 561 | embed = nextcord.Embed( 562 | title="Lockdown Success", 563 | description=f"Locked entire server <:saluteboi:897263732948885574>", 564 | ) 565 | await ctx.send(embed=embed) 566 | else: 567 | lockEmbed = nextcord.Embed( 568 | title="Lock Cancelled", 569 | description="Lets pretend like this never happened them :I", 570 | ) 571 | await ctx.author.send(embed=lockEmbed) 572 | return 573 | if channel is None: 574 | channel = ctx.message.channel 575 | await channel.set_permissions( 576 | ctx.guild.default_role, 577 | reason=f"{ctx.author.name} locked {channel.name}", 578 | send_messages=False, # 579 | ) 580 | embed = nextcord.Embed( 581 | title="Lockdown Success", 582 | description=f"Locked {channel.mention} <:saluteboi:897263732948885574>", 583 | ) 584 | await ctx.send(embed=embed) 585 | 586 | @commands.command(description="Unlocks the channel.") 587 | @commands.has_permissions(kick_members=True) 588 | async def unlock(self, ctx, channel: nextcord.TextChannel = None, setting=None): 589 | if setting == '--server': 590 | for channel in ctx.guild.channels: 591 | await channel.set_permissions( 592 | ctx.guild.default_role, 593 | reason=f"{ctx.author.name} unlocked {channel.name} using --server override", 594 | send_messages=None, 595 | ) 596 | embed = nextcord.Embed( 597 | title="Unlock Success", 598 | description=f"Unlocked entire server (you might have to manualy relock servers that shouldnt have been unlocked)", 599 | ) 600 | await ctx.send(embed=embed) 601 | return 602 | if channel is None: 603 | channel = ctx.channel 604 | await channel.set_permissions( 605 | ctx.guild.default_role, 606 | reason=f"{ctx.author.name} unlocked {channel.name}", 607 | send_messages=True, 608 | ) 609 | embed = nextcord.Embed( 610 | title="Unlock Success", 611 | description=f"Unlocked {channel.mention} <:happyboi:804920510508433428>", 612 | ) 613 | await ctx.send(embed=embed) 614 | 615 | @commands.command(description="Modbans the member.") 616 | @commands.has_permissions(kick_members=True) 617 | @commands.cooldown(1, 21600, commands.BucketType.user) 618 | async def modban(self, ctx, member, *, reason=None): 619 | if reason is None: 620 | reason = f"{ctx.author.name} modbanned {member.name}" 621 | else: 622 | reason = ( 623 | f"{ctx.author.name} modbanned {member.name} for the reason of {reason}" 624 | ) 625 | if member == None: 626 | embed1 = nextcord.Embed( 627 | title="Ban Error", description="Member to ban - Not Found" 628 | ) 629 | return await ctx.send(embed=embed1) 630 | if member.id == ctx.author.id: 631 | embed69 = nextcord.Embed( 632 | title="Ban Error", 633 | description="Can not ban yourself, trust me I woulda ages ago <:hehe:796743161208504320>", 634 | ) 635 | return await ctx.send(embed=embed69) 636 | em = nextcord.Embed( 637 | title="Are you sure?", 638 | description="This is a very risky command only to be used in important situations such as, `NSFW or NSFLPosting` or `Raid on the Server`. Only use this command if no admin is online or responding. **If this command is used for the wrong purpose you may risk getting demoted if not banned from the staff team.**", 639 | ) 640 | view = BanConfirm() 641 | await ctx.author.send(embed=em, view=view) 642 | await view.wait() 643 | if view.value is None: 644 | await ctx.author.send("Command has been Timed Out, please try again.") 645 | elif view.value: 646 | guild = ctx.guild 647 | banMsg = random.choice(ban_msg) 648 | banEmbed = nextcord.Embed( 649 | title="Ban Success", description=f"{member.mention} {banMsg}" 650 | ) 651 | banEmbed.add_field(name="Reason", value=reason) 652 | await ctx.author.send(embed=banEmbed) 653 | await member.ban(reason=reason) 654 | await member.send(f"You got banned in **{guild}** | Reason: **{reason}**") 655 | else: 656 | banEmbed = nextcord.Embed( 657 | title="Ban Cancelled", 658 | description="Lets pretend like this never happened them :I", 659 | ) 660 | await ctx.author.send(embed=banEmbed) 661 | 662 | @commands.group(invoke_without_command = True, aliases=['sb', 'starb'], description="A starboard") 663 | @commands.has_permissions(manage_guild = True) 664 | @commands.cooldown(1, 10, commands.BucketType.user) 665 | async def starboard(self, ctx): 666 | try: 667 | guild_starboard_settings = read_database()[str(ctx.guild.id)]['starboard'] 668 | guild_starboard_settings['on or off'] 669 | guild_starboard_settings['channel'] 670 | guild_starboard_settings['minimum stars'] 671 | except: 672 | embed = Embed(title="Starboard Error!", color=Color.red(), description=f"You don't have your starboard setup!, use `{PREFIX}starboard setup` to set it up!") 673 | embed.set_footer(text="P.S. Use `>help starboard` for more info!") 674 | return await ctx.send(embed=embed) 675 | embed = Embed(title=f"{ctx.guild.name}'s Starboard Settings") 676 | embed.add_field(name="Status", value="Enabled" if guild_starboard_settings['on or off'] == True else "Disabled") 677 | embed.add_field(name="Channel", value=f"<#{guild_starboard_settings['channel']}>") 678 | embed.add_field(name="Number Of Stars Before Announcing", value=str(guild_starboard_settings['minimum stars'])) 679 | embed.set_footer(text="P.S. Use `>help starboard` for more info!") 680 | await ctx.send(embed=embed) 681 | 682 | @starboard.command(description="Set up the starboard!") 683 | @commands.has_permissions(manage_guild=True) 684 | @commands.cooldown(1, 10, commands.BucketType.user) 685 | async def setup(self, ctx): 686 | database = read_database() 687 | try: 688 | guild_starboard_settings = database[str(ctx.guild.id)]['starboard'] 689 | guild_starboard_settings = read_database()[str(ctx.guild.id)]['starboard'] 690 | guild_starboard_settings['on or off'] 691 | guild_starboard_settings['channel'] 692 | guild_starboard_settings['minimum stars'] 693 | except: 694 | ... 695 | else: 696 | embed = Embed(title="Starboard Error!", color=Color.red(), description=f"The starboard is already setup for this server!\nUse `{PREFIX}starboard` to view the settings!\nDo you want to wipe all the data and start again?") 697 | view=View() 698 | view.add_item(nextcord.ui.Button(style=nextcord.ButtonStyle.red, label="Yes", custom_id="True", emoji="✔️")) 699 | view.add_item(nextcord.ui.Button(style=nextcord.ButtonStyle.green, label="No", custom_id="False", emoji="✖️")) 700 | await ctx.send(embed=embed, view=view) 701 | def check(i): 702 | return i.user.id == ctx.author.id 703 | r=True 704 | while r: 705 | try: 706 | res = await self.client.wait_for('interaction', check=check, timeout=60.0) 707 | if res.data['component_type'] != 2: 708 | ... 709 | elif res.data['custom_id'] == "True": 710 | embed=Embed(title="Success!", color=Color.green(), description="Let's start the setup!") 711 | await ctx.send(embed=embed) 712 | r=False 713 | ... 714 | elif res.data['custom_id'] == "False": 715 | embed=Embed(title="Cancelled!", description="**Nothing Happened**", color=Color.red()) 716 | await ctx.send(embed=embed) 717 | r=False 718 | return 719 | except asyncio.TimeoutError: 720 | return 721 | embed = Embed(title="Let's start the Starboard setup!", description="Where should I post the starboard?") 722 | embed.set_footer(text="Send `cancel` to cancel!") 723 | await ctx.send(embed=embed) 724 | retry=True 725 | def check(m): 726 | return m.author.id == ctx.author.id 727 | while retry: 728 | try: 729 | response = await self.client.wait_for('message', check=check, timeout=60.0) 730 | if response.content == "cancel": 731 | retry=False 732 | await ctx.send(embed=Embed(color=Color.red(), description="Cancelling...")) 733 | else: 734 | try: 735 | channel_to_post_in = await commands.TextChannelConverter().convert(ctx, response.content) 736 | try: 737 | database[str(ctx.guild.id)] 738 | except: 739 | database[str(ctx.guild.id)] = {} 740 | database[str(ctx.guild.id)]['starboard'] = {} 741 | database[str(ctx.guild.id)]['starboard']['channel'] = channel_to_post_in.id 742 | database[str(ctx.guild.id)]['starboard']['on or off'] = True 743 | embed=Embed(title="Success!", color=Color.green(), description=f"The starboard will be sent to {channel_to_post_in.mention}") 744 | await ctx.send(embed=embed) 745 | embed=Embed(description="What should be the minimum star amount?") 746 | await ctx.send(embed=embed) 747 | re=True 748 | while re: 749 | try: 750 | response = await self.client.wait_for("message", check=check, timeout=60.0) 751 | if response.content == "cancel": 752 | re=False 753 | await ctx.send(embed=Embed(description="Cancelling....", color=Color.red())) 754 | else: 755 | try: 756 | int(response.content) 757 | database[str(ctx.guild.id)]['starboard']['minimum stars'] = response.content 758 | await ctx.send(embed=Embed(title="Success!",color=Color.green(), description=f"Successfully set the minimum amount of stars to `{response.content}`")) 759 | re=False 760 | view = nextcord.ui.View() 761 | view.add_item(nextcord.ui.Button(style=nextcord.ButtonStyle.green, label="Save", custom_id='True', emoji="✔️")) 762 | view.add_item(nextcord.ui.Button(label="Cancel", style=nextcord.ButtonStyle.danger, emoji="✖️", custom_id='False')) 763 | def check(i): 764 | return i.user.id == ctx.author.id 765 | embed=Embed(title="Do you want to save the changes?") 766 | await ctx.send(embed=embed, view=view) 767 | r=True 768 | while r: 769 | try: 770 | res = await self.client.wait_for('interaction', check=check, timeout=60.0) 771 | if res.data['component_type'] != 2: 772 | ... 773 | elif res.data['custom_id'] == "True": 774 | write_database(data=database) 775 | embed=Embed(title="Success!", color=Color.green(), description="The changes were successfully saved!") 776 | await ctx.send(embed=embed) 777 | r=False 778 | elif res.data['custom_id'] == "False": 779 | embed=Embed(title="Cancelled!", description="The changes were not saved!", color=Color.red()) 780 | await ctx.send(embed=embed) 781 | r=False 782 | except asyncio.TimeoutError: 783 | embed=Embed(description="Let's pretend that never happened!") 784 | return await ctx.send(embed=embed) 785 | except commands.BadArgument: 786 | embed=Embed(title="Error!", description=f"Can't convert `{response.content}` to a number, try again.", color=Color.red()) 787 | await ctx.send(embed=embed) 788 | except asyncio.TimeoutError: 789 | embed=Embed(description="Let's pretend that never happened!") 790 | return await ctx.send(embed=embed) 791 | re=False 792 | retry=False 793 | except commands.BadArgument: 794 | embed=Embed(title="Error!", color=Color.red(), description="I can't find that channel ;-;") 795 | await ctx.send(embed=embed) 796 | except asyncio.TimeoutError: 797 | embed=Embed(description="Let's pretend that never happened!") 798 | return await ctx.send(embed=embed) 799 | retry=False 800 | 801 | @starboard.group(invoke_without_command=True, description="Toggle the starboard!") 802 | @commands.has_permissions(manage_guild=True) 803 | async def toggle(self, ctx): 804 | database = read_database() 805 | try: 806 | guild_starboard_settings = database[str(ctx.guild.id)]['starboard'] 807 | guild_starboard_settings['on or off'] 808 | guild_starboard_settings['channel'] 809 | guild_starboard_settings['minimum stars'] 810 | except: 811 | embed = Embed(title="Starboard Error!", color=Color.red(), description=f"You don't have your starboard setup!, use `{PREFIX}starboard setup` to set it up!") 812 | return await ctx.send(embed=embed) 813 | embed=Embed(title=f"My Starboard Settings For {ctx.guild.name}", color=Color.green() if guild_starboard_settings['on or off'] else Color.red(), description=f"The starboard is `{'Enabled' if guild_starboard_settings['on or off'] else 'Disabled'}` for this server.") 814 | await ctx.send(embed=embed) 815 | 816 | @toggle.command(aliases=['enable','true','enabled','+'], description="Toggle the starboard!") 817 | @commands.has_permissions(manage_guild=True) 818 | async def on(self, ctx): 819 | database = read_database() 820 | try: 821 | guild_starboard_settings = database[str(ctx.guild.id)]['starboard'] 822 | guild_starboard_settings['on or off'] 823 | guild_starboard_settings['channel'] 824 | guild_starboard_settings['minimum stars'] 825 | except: 826 | embed = Embed(title="Starboard Error!", color=Color.red(), description=f"You don't have your starboard setup!, use `{PREFIX}starboard setup` to set it up!") 827 | return await ctx.send(embed=embed) 828 | if guild_starboard_settings['on or off']: 829 | return await ctx.send(embed=Embed(title="Error!", description="The starboard for this server is already enabled!", color=Color.red())) 830 | guild_starboard_settings['on or off'] = True 831 | write_database(data=database) 832 | await ctx.send(embed=Embed(title="Success!", color=Color.green(), description="The starboard has been `enabled` for this server!")) 833 | 834 | @toggle.command(aliases=['disable','false','disabled','-'], description="Toggle the starboard!") 835 | @commands.has_permissions(manage_guild=True) 836 | async def off(self, ctx): 837 | database = read_database() 838 | try: 839 | guild_starboard_settings = database[str(ctx.guild.id)]['starboard'] 840 | guild_starboard_settings['on or off'] 841 | guild_starboard_settings['channel'] 842 | guild_starboard_settings['minimum stars'] 843 | except: 844 | embed = Embed(title="Starboard Error!", color=Color.red(), description=f"You don't have your starboard setup!, use `{PREFIX}starboard setup` to set it up!") 845 | return await ctx.send(embed=embed) 846 | if not guild_starboard_settings['on or off']: 847 | return await ctx.send(embed=Embed(title="Error!", description="The starboard for this server is already disabled!", color=Color.red())) 848 | guild_starboard_settings['on or off'] = False 849 | write_database(data=database) 850 | await ctx.send(embed=Embed(title="Success!", color=Color.red(), description="The starboard has been `disabled` for this server!")) 851 | 852 | @starboard.group(aliases=['ch'], invoke_without_command=True, description="Get the current starboard channel setting") 853 | @commands.has_permissions(manage_guild=True) 854 | async def channel(self, ctx): 855 | database = read_database() 856 | try: 857 | guild_starboard_settings = database[str(ctx.guild.id)]['starboard'] 858 | guild_starboard_settings['on or off'] 859 | guild_starboard_settings['channel'] 860 | guild_starboard_settings['minimum stars'] 861 | except: 862 | embed = Embed(title="Starboard Error!", color=Color.red(), description=f"You don't have your starboard setup!, use `{PREFIX}starboard setup` to set it up!") 863 | return await ctx.send(embed=embed) 864 | 865 | await ctx.send(embed=Embed(title=f"My Starboard Channel Settings For {ctx.guild.name}", color=Color.green(), description=f"I post the starboard in <#{guild_starboard_settings['channel']}>")) 866 | 867 | @channel.command(aliases=['set'], description="Change the current starboard channel setting") 868 | @commands.has_permissions(manage_guild=True) 869 | async def change(ctx,*, channel=None): 870 | database = read_database() 871 | try: 872 | guild_starboard_settings = database[str(ctx.guild.id)]['starboard'] 873 | guild_starboard_settings['on or off'] 874 | guild_starboard_settings['channel'] 875 | guild_starboard_settings['minimum stars'] 876 | except: 877 | embed = Embed(title="Starboard Error!", color=Color.red(), description=f"You don't have your starboard setup!, use `{PREFIX}starboard setup` to set it up!") 878 | return await ctx.send(embed=embed) 879 | try: 880 | channel_to_post_in = await commands.TextChannelConverter().convert(ctx, channel) 881 | guild_starboard_settings['channel'] = channel_to_post_in.id 882 | write_database(data=database) 883 | await ctx.send(embed=Embed(title="Success!", color=Color.green(), description=f"Successfully set the starboard channel to {channel_to_post_in.mention}(#{channel_to_post_in.name})")) 884 | except: 885 | await ctx.send(embed=Embed(title="Error!", color=Color.red(), description="I wasn't able to find that channel ;-;")) 886 | 887 | @starboard.group(invoke_without_command=True, aliases = ['minstars','min-stars','mins','ms'], description="Get the current starboard minimum star setting") 888 | async def minimum_stars(self, ctx): 889 | database = read_database() 890 | try: 891 | guild_starboard_settings = database[str(ctx.guild.id)]['starboard'] 892 | guild_starboard_settings['on or off'] 893 | guild_starboard_settings['channel'] 894 | guild_starboard_settings['minimum stars'] 895 | except: 896 | embed = Embed(title="Starboard Error!", color=Color.red(), description=f"You don't have your starboard setup!, use `{PREFIX}starboard setup` to set it up!") 897 | return await ctx.send(embed=embed) 898 | await ctx.send(embed=Embed(title=f"My Starboard Minimum Stars Settings For {ctx.guild.name}", color=Color.green())) 899 | 900 | @minimum_stars.command(aliases=['set'], description="Change the current starboard minimum star setting") 901 | @commands.has_permissions(manage_guild=True) 902 | async def change(ctx, *, number): 903 | database = read_database() 904 | try: 905 | guild_starboard_settings = database[str(ctx.guild.id)]['starboard'] 906 | guild_starboard_settings['on or off'] 907 | guild_starboard_settings['channel'] 908 | guild_starboard_settings['minimum stars'] 909 | except: 910 | embed = Embed(title="Starboard Error!", color=Color.red(), description=f"You don't have your starboard setup!, use `{PREFIX}starboard setup` to set it up!") 911 | return await ctx.send(embed=embed) 912 | try: 913 | number = int(number) 914 | guild_starboard_settings['minimum stars'] = number 915 | write_database(data=database) 916 | await ctx.send(embed=Embed(title="Success!", color=Color.green(), description=f"Successfully set the starboard minimum stars requirement to {number}")) 917 | except: 918 | await ctx.send(embed=Embed(title="Error!", color=Color.red(), description="I wasn't able to convert the number to an integer ;-;")) 919 | 920 | 921 | def setup(client): 922 | client.add_cog(Moderation(client)) 923 | --------------------------------------------------------------------------------