From edd8fcc9ada21cf844577f4abcdc9b859040f901 Mon Sep 17 00:00:00 2001 From: juicy Date: Tue, 5 May 2020 13:06:53 +0200 Subject: [PATCH] Uploading JuicyBot Base v0.0.1 --- .idea/.gitignore | 3 + .idea/dictionaries/cekey.xml | 19 +++++ .idea/discordbotto.iml | 10 +++ .../inspectionProfiles/profiles_settings.xml | 6 ++ .idea/misc.xml | 4 ++ .idea/modules.xml | 8 +++ __pycache__/configloader.cpython-37.pyc | Bin 0 -> 545 bytes __pycache__/index.cpython-37.pyc | Bin 0 -> 2800 bytes commands/__pycache__/admin.cpython-37.pyc | Bin 0 -> 2446 bytes commands/__pycache__/help.cpython-37.pyc | Bin 0 -> 643 bytes commands/admin.py | 65 ++++++++++++++++++ commands/help.py | 12 ++++ config/__pycache__/cogs.cpython-37.pyc | Bin 0 -> 225 bytes config/__pycache__/config.cpython-37.pyc | Bin 0 -> 311 bytes config/cogs.py | 5 ++ config/config.py | 4 ++ configloader.py | 11 +++ db/db.db | Bin 0 -> 12288 bytes .../__pycache__/errorHandling.cpython-37.pyc | Bin 0 -> 1584 bytes handlers/errorHandling.py | 41 +++++++++++ index.py | 60 ++++++++++++++++ logs/bot.log | 10 +++ requirements.txt | 3 + utils/__pycache__/embed.cpython-37.pyc | Bin 0 -> 512 bytes utils/embed.py | 9 +++ 25 files changed, 270 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/dictionaries/cekey.xml create mode 100644 .idea/discordbotto.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 __pycache__/configloader.cpython-37.pyc create mode 100644 __pycache__/index.cpython-37.pyc create mode 100644 commands/__pycache__/admin.cpython-37.pyc create mode 100644 commands/__pycache__/help.cpython-37.pyc create mode 100644 commands/admin.py create mode 100644 commands/help.py create mode 100644 config/__pycache__/cogs.cpython-37.pyc create mode 100644 config/__pycache__/config.cpython-37.pyc create mode 100644 config/cogs.py create mode 100644 config/config.py create mode 100644 configloader.py create mode 100644 db/db.db create mode 100644 handlers/__pycache__/errorHandling.cpython-37.pyc create mode 100644 handlers/errorHandling.py create mode 100644 index.py create mode 100644 logs/bot.log create mode 100644 requirements.txt create mode 100644 utils/__pycache__/embed.cpython-37.pyc create mode 100644 utils/embed.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/dictionaries/cekey.xml b/.idea/dictionaries/cekey.xml new file mode 100644 index 0000000..373a768 --- /dev/null +++ b/.idea/dictionaries/cekey.xml @@ -0,0 +1,19 @@ + + + + cooldown + couldn + dataframe + emoji + gamertag + platformid + playerdata + playerid + psyonix + qqfcwij + racker + rlstats + xbox + + + \ No newline at end of file diff --git a/.idea/discordbotto.iml b/.idea/discordbotto.iml new file mode 100644 index 0000000..c17db0d --- /dev/null +++ b/.idea/discordbotto.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..8038df2 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..b67b725 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/__pycache__/configloader.cpython-37.pyc b/__pycache__/configloader.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9a262478a9900c8a77f0fba81216138a3f7124a3 GIT binary patch literal 545 zcmX|;&u$Yj5XSBOpG~$1ByN3yT%xEF91sGUWP#8stx8sB2zfstd4aN?7p?z>Fo6>Dl;XK7sR-qjbjhcJ_3hzMfvN$2#K4(u&pTvJ2n2gEi0{DWS0EjwMELqobs&% zRzeihor*@PHdRV0<4A2nUf+~T*2Z1(_B&CDEw%FJ<@j0lUUQ|hoZ~yP3D>JuHrcy% znQun2h0#KD7(N-`JQyAfvwyc&a#3(KXf`H#E@ZK;_zV1aq9393XwPxzKHZ}cMaK9G D06LIF literal 0 HcmV?d00001 diff --git a/__pycache__/index.cpython-37.pyc b/__pycache__/index.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..10ddf29b41cc09ec2d713014dec3b39b2b855d7e GIT binary patch literal 2800 zcma)8O>^7E8O8!22=Pml?8xy)8njck;*7;OO=ps-NvEm|K59Z$0!s?6s#{dd$J6KD(rCInzUd*{>J-@$UOP@B89* zwOTUpeDjyT|KVR{!}zxvynKr2{2C>Hfr=WGBt}QIWmE-{!hU844kbV{r=Ei)&s%m}0|El`IRsY{n==~%8 zTVESbN$08_tqW+8!}!+3`f*_>x*H!!@}yai zZWoKvpwFb+56*6n1j}XlCHEphFAq!dq>2x#R4+QQV2-fY3ap6|$R_lG3r?xPaKj5qzorOf%5RZkj zgtCp2e~d~PQ!+7T`W_$d} z_QRd6y&Z3F>-Oh6-tJwmeSgo}dA$2*?~!*n%o)!Qz4b$7qQjeq5k0)=9S)K}D8&z( zzic|Pn17W-f_)&1VV0&W6w(QYJkNk8J7eKcFbIHqBxE5>vYa(7Y0@KUVY(#YHwM3o zYrOdR_U6Iw)NuzPJ7J@P2cz&f;Qa?Yi?L^ZuwVvwA+m!grR=OV7)kd|AcCVHXKIgJ z`y#0jmy}TWb;v>#{V2o1Lydo;%{*#pPO>bPforw)aYxG^!-@Sug6+Q0@;1p#khD9&Q0?O$4 z5*#m~=}(0gcwyF4%jnU2^r%IT#w(ut=rqa-S)MqG`#Sy~SToL{ug!-iKLs!Et^M!t#Md?SFm)B7#084<&AvaL!gl|C>s-&eJ zMIZ&52J8TxHvltLI1pBBKQ;LSQHY&sQ9(F$0mIUaOw70hFwD5D!B8MpCKk0`gOR$T zI?(|~ySd#S-`YElayXz)wH~@0$t8&pfEm5%4HAZM=?Omaf?g1%UX+fDf81>Stb2~M ztnb~dUBIXm32Yl3dxI?|eVq&a#BU6*X#eiz%D%s+v~j3}^U3SHR8+2ClLd z|3p=a`b`@dK%Bw)oM&?+{-@FFF#5|}sHfh+;=G1RnSCDX>*TV@KZQg&dLNha{pP!K z&n++VMhh;l_2&w)xyHXxD~ibQJ@undUvyfaf%+NAxk?#w2^{?#QxI<)H3O}iL!<(k zEbebTZ11)|mBqy(S;4ovI;rE{a_M!q6i|9^@tcERl{^Z!b%c`kZu{{idn))g`JY=5F0@VUrd|SEZ41Fsa0wfm;4uutoDuo literal 0 HcmV?d00001 diff --git a/commands/__pycache__/admin.cpython-37.pyc b/commands/__pycache__/admin.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a4af971e072942e504c583e1b8537e3d9ecc0558 GIT binary patch literal 2446 zcmd5-&2HO95Z>jI6fMiLYNxW3IDy(jQx=6`1Z@vSYB+X_wn6JdoFJ(ngiyF^o3=!% zyCh-}Y7e!qd4j-zbL_Ft(6`{VC-)I@>dY<`D|V7YPhE(!qn#hld^4Qgn3<^(Sf^kA z`NW+fy+vP5= z9Fum1vu)ygXW)bQwD7{D-|xm;0dI%NuG$JwGF~n)>+q<5fC$p2oU|=YxdomWXWWL} z7S6s4@2Tv2F9>%}EMDQ>b0(bADL%!kAg%6Czhr!x*N({%J)-TJwwU4d(q>lMG@gT} z3pO9{xzc7v+syMTrOk)$v}y8%(x$F$7WviE=Gr@LuJfhRW|rRod~O!bUEYu4(1N^i z;f~KHJPKhe}A*3B`dJcD@nn zAWa6Hds!3?Ht>01)ZUa&Ad)F~L^ z;n@_lND%Ic@BlFwhcatIc`eK5xA&4~swEC1l}7PyYZDqvVo(o!R!noDLKzLxD2WRv zQ{7!rxO)-jB0i&_bA}1NJ)I^}(a8gxQ1&KrdbddMp`3 z-7p8|V9P~7NM1#95oCD{Pp>1vK``-IR!c7c^T!~$40FRY_PJW&N@0M$ulGryjpThm z=kSu@r7 zLGVk~?HP%L>z_y*P7>!~Q7J#^q829cPPB`~gP9HX11WZ*L$HUtJn3Bq2`{3FsP-N^6+~T2Q5d=Xzq>~Y#=yEtzxQa^R^v-gma}gKWk`HOe zF8!HqS~GR+*r}xALyHn1MM@(19;MUSY$8a0ZNI<&LF*$2gJk5KkcL-eP$0CTg9?Cs z*~&_u2~?Op2+S;8t9w;tnB(X{R5{AGq8$IEJW)a{jO)5)jbUkcXAnuw328VaV?_lh zDv5xSDkxM`A&c1?+incsWZ@M^7o>sVp`cr^{3c2nvtZkcs6M#f^HDOtj~1`%cftBl z8~f4j>hqnsYJ7L@-L*A+sBsmH^GHd(s|T3%6*Zl2cCpZUwO;jFkGNq%0iS0KX+E4R z2_#)xH=WfwPPFbEZd>-JTHkD&_UXhI1Ejy;{FwI?nS3Z;K#C2MWZ{*`B*HJrxf5UL zA->WhkO#fI6Za`fgOJOZG4xW!18+O`$?83&IBpOrxJ>0s@J#4GBry-R-){Inq}d9X zfPYR=If~ErbDG=R-t!#d)VTG<>aukWS|8P7UpgiHQ#ic@^NhvO(`1gBQ{etnDAbGm E562RV=l}o! literal 0 HcmV?d00001 diff --git a/commands/admin.py b/commands/admin.py new file mode 100644 index 0000000..a1630f9 --- /dev/null +++ b/commands/admin.py @@ -0,0 +1,65 @@ +from discord.ext import commands +from config import cogs +import configloader + + +class Admin(commands.Cog): + def __init__(self, bot): + self.bot = bot + + async def cog_check(self, ctx): + return await ctx.bot.is_owner(ctx.author) + + @commands.command(description='Shows existing Cogs', + usage=f'{configloader.__prefix__}cogs', + hidden=True) + @commands.cooldown(1, 2, commands.BucketType.user) + async def cogs(self, ctx): + await ctx.send(cogs.__cogs__) + + @commands.command(name='load', + description='Loads a Module', + usage=f'{configloader.__prefix__}load ', + hidden=True) + @commands.cooldown(1, 2, commands.BucketType.user) + async def load_cog(self, ctx, cog): + try: + self.bot.load_extension(f"commands.{cog}") + except Exception as err: + print(f"{cog} couldn't be loaded") + raise err + else: + await ctx.send(f'{cog} : Successfully loaded') + + @commands.command(name='unload', + description='Unloads a Module', + usage=f'{configloader.__prefix__}unload ', + hidden=True) + @commands.cooldown(1, 2, commands.BucketType.user) + async def unload_cog(self, ctx, cog): + try: + self.bot.unload_extension(f"commands.{cog}") + except Exception as err: + print(f"{cog} : couldn't be unloaded") + raise err + else: + await ctx.send(f'{cog} : Successfully unloaded') + + @commands.command(name='reload', + description='Reloads a Module', + usage=f'{configloader.__prefix__}reload ', + hidden=True) + @commands.cooldown(1, 2, commands.BucketType.user) + async def reload_cog(self, ctx, cog): + try: + self.bot.unload_extension(f"commands.{cog}") + self.bot.load_extension(f'commands.{cog}') + except Exception as err: + print(f"'{cog} : couldn't be reloaded") + raise err + else: + await ctx.send(f'{cog} : Successfully reloaded') + + +def setup(bot): + bot.add_cog(Admin(bot)) diff --git a/commands/help.py b/commands/help.py new file mode 100644 index 0000000..b644fdc --- /dev/null +++ b/commands/help.py @@ -0,0 +1,12 @@ +from discord.ext import commands +import configloader + + +class Help(commands.Cog): + def __init__(self, bot): + pass + + +def setup(bot): + bot.remove_command("help") + bot.add_cog(Help(bot)) diff --git a/config/__pycache__/cogs.cpython-37.pyc b/config/__pycache__/cogs.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4dfe7ac673f3b938d2489cf0909e14acc74c2bc5 GIT binary patch literal 225 zcmX|3y9&ZU5WGB!AS9*#U=xC1qaqS5#KJ~wb!l4gOZ)_v{tjFJ zqAM>(&&-^2W@a-PqucFp4DZ_4^9R%KruhfY%#anmV1zk`!@R@emeay*r;UXf*E^_g ztxA_CwtqEwU2LcJ2w7&-pW2I^_>{@Pi!Q2)HCJV4h3&^|t7YR6B?i^2<;+a>{H1d~ zK-ZGmS0q)H6it#58q}QC6Y3LyB8f;0P)Oy#MVwtsP^_dYvCdNqz?{kmBu z_oH++O()a3Yn={U*E{julfDyM=d5f;cAVs?mGcYldTy{AiP-GXig!1@o;;6|vMTn! zQ_)UUn}?!bna{?L!UhN+fB*srAb&5s*36u0Lqv)Sx!8sJ!IkPr}5rK^=dqC!=*q0p_=PzjJ|6fv3|JK33?jDziz zCS*_P6^VN<$&n*>Zu}R%a^hd;q2fKyY!$5#PV9O9c)$01ANJ|NL6boH{Qe(5-fa-_ zH%_jb2f_pB>M;zAFj|md^`%1!bEj~o?$D*xnm6?98Gq=1O_`C{}XSC?AMMvv!Nx;Pa&K1~#lk3a3f|K#}Ocyv*jRwMqFNLEgIvxN!c zI4d(9$9u@aQlrcFcKP-OIL2*dPQJ7cty6}mA|6-;mT+3ue3sbtA7Og ze=a_&5j=}P^Y(ut+`5TD3I3ju()odur!}L_+WC#hH#MUFzlb+D*@OjyFdt zWZKDWR%B_S;UE;iSV&C0IjSuWg#Jp*OJ)wS%+AW$T-%Z`%}iyb(n*Qm29<^-Wm?mU>qGR<1Yl{JXtOUlL?TYcnoHw@Dty8WwBxxfu;RgX zdmw6mYj;hf4z3B3xxNt6be^EE!$hzL>24ZwBRDe;IZ{|*vclQkUX|~ zmZZH^)c_9-F>T;co2pK=U{&3LfjDiaO_+nesR`%{ZP4HZM?a#qm$`q^Nde2v)1?xP37(VUa1#Aztz}Zs0xK8IZoj zdx}~L-;9uku3bstqS}UE+_CRY2ZR;b5Djn7nr7{YiLYaM*sZ>bT<1cjOPNQCtN1!3!#{rpJfE_c| YLz|ZHiz-C-(F27!0q1NYLbntB3l}MyegFUf literal 0 HcmV?d00001 diff --git a/handlers/errorHandling.py b/handlers/errorHandling.py new file mode 100644 index 0000000..f3b9821 --- /dev/null +++ b/handlers/errorHandling.py @@ -0,0 +1,41 @@ +import traceback +import sys +from discord.ext import commands +import discord +import configloader + + +class ErrorHandler(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.Cog.listener() + async def on_command_error(self, ctx, error): + bot_app_info = await self.bot.application_info() + + ignore_error = (commands.CommandNotFound, commands.UserInputError) + + if isinstance(error, ignore_error): + return + elif isinstance(error, commands.CommandOnCooldown): + embed = configloader.embed.messageEmbed(f"This command is ratelimited, please try again in", + "{:.2f}s".format(error.retry_after), + f"{bot_app_info.owner}", f"{bot_app_info.icon_url}") + return await ctx.send(embed=embed) + elif isinstance(error, commands.NoPrivateMessage): + try: + embed = configloader.embed.messageEmbed(f"This Command can't be used in Private Messages.", + "{:.2f}s".format(ctx.command), + f"{bot_app_info.owner}", f"{bot_app_info.icon_url}") + return await ctx.author.send(embed=embed) + except: + pass + elif isinstance(error, commands.MissingPermissions): + embed = configloader.embed.messageEmbed(f"You don't have Permissions to use this command", + "{:.2f}s".format(ctx.command), + f"{bot_app_info.owner}", f"{bot_app_info.icon_url}") + return await ctx.send(embed=embed) + + +def setup(bot): + bot.add_cog(ErrorHandler(bot)) diff --git a/index.py b/index.py new file mode 100644 index 0000000..9b069dc --- /dev/null +++ b/index.py @@ -0,0 +1,60 @@ +import discord +from discord.ext import commands +import sqlite3 +import configloader +import random +import logging +from logging.handlers import RotatingFileHandler + +logger = logging.getLogger('discord') +logger.setLevel(logging.WARNING) +handler = RotatingFileHandler(filename='logs/bot.log', maxBytes=1024 * 5, backupCount=2, encoding='utf-8', mode='w') +handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s')) +logger.addHandler(handler) + +__version__ = '0.0.1' +bot = commands.Bot(command_prefix=configloader.__prefix__) + + +def Database(db): + with sqlite3.connect(db) as con: + c = con.cursor() + c.execute('''CREATE TABLE IF NOT EXISTS `users` (`name`,`id`, `platform`);''') + con.commit() + c.close() + + +@bot.event +async def on_ready(): + bot_app_info = await bot.application_info() + print("------------------------------------") + print(f"Owner: {bot_app_info.owner}") + print(f"Bot-Name: {bot.user.name}") + print(f"Bot-ID: {bot.user.id}") + print(f"Bot Version: {__version__}") + print("------------------------------------") + for cog in configloader.__cogs__: + try: + bot.load_extension(cog) + print(f"{cog} loaded") + except Exception as err: + print(f"Couldn't load cog: {cog}") + raise err + Database("db/db.db") + await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="Juicy developing.")) + + +@bot.event +async def on_member_join(member): + bot_app_info = await bot.application_info() + emoji = [':wink:', ':wave:', ':tada:'] + channel = bot.get_channel(int(configloader.__greet_channel__)) + guild = member.guild + embed = configloader.embed.messageEmbed(f"Willkommen bei {guild.name} {random.choice(emoji)}", + f"{member.mention}", + f"{bot_app_info.owner}", f"{bot_app_info.icon_url}") + await channel.send(embed=embed) + + +if __name__ == "__main__": + bot.run(configloader.__token__) diff --git a/logs/bot.log b/logs/bot.log new file mode 100644 index 0000000..76643e9 --- /dev/null +++ b/logs/bot.log @@ -0,0 +1,10 @@ +2020-05-05 11:41:55,808:WARNING:discord.client: PyNaCl is not installed, voice will NOT be supported +2020-05-05 11:42:44,589:WARNING:discord.client: PyNaCl is not installed, voice will NOT be supported +2020-05-05 12:02:46,688:WARNING:discord.client: PyNaCl is not installed, voice will NOT be supported +2020-05-05 12:05:01,635:WARNING:discord.client: PyNaCl is not installed, voice will NOT be supported +2020-05-05 12:08:16,694:WARNING:discord.client: PyNaCl is not installed, voice will NOT be supported +2020-05-05 12:10:00,026:WARNING:discord.client: PyNaCl is not installed, voice will NOT be supported +2020-05-05 12:11:03,303:WARNING:discord.client: PyNaCl is not installed, voice will NOT be supported +2020-05-05 12:13:57,539:WARNING:discord.client: PyNaCl is not installed, voice will NOT be supported +2020-05-05 12:14:11,853:WARNING:discord.client: PyNaCl is not installed, voice will NOT be supported +2020-05-05 12:21:59,614:WARNING:discord.client: PyNaCl is not installed, voice will NOT be supported diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..148bd51 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +discord.py +pandas +requests \ No newline at end of file diff --git a/utils/__pycache__/embed.cpython-37.pyc b/utils/__pycache__/embed.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5d0b9ec391cb90d044b858822d2fa6b4dde32a4e GIT binary patch literal 512 zcmYjOy-EZz5KeZJ`{OJ;Utqy%8z0~hITTwt5SwH1*xStMp4p2eS@mEA3)_1F5!BAo zSFp9VNvV~uV55^&!GW2~U%qcL*pK1AWD4b&Y}vyH}*85L9nOM1yFHVZ0pLn?ZM zXiLPz45C&6#@wsooH=HpV!xZ#>2H<{AH@!etq!nIQ&#?u_6a2*47JXOkq)_xI= zTP4y(%+blM1nuACxH_MMcFbcs4j$x@=v6Fz_ILWpfdOrj3{GH?3>VpPs*9mkGsvt- zeyJzQT9uSGmnNz2Z=5b%w*X_(BdDkH3p6b>gm!6r&1C X&-CiP%|eM%!WRBAG5&K}v>Sc{m0E+4 literal 0 HcmV?d00001 diff --git a/utils/embed.py b/utils/embed.py new file mode 100644 index 0000000..8fe3659 --- /dev/null +++ b/utils/embed.py @@ -0,0 +1,9 @@ +import discord +from datetime import date + + +def messageEmbed(title, text, owner, icon): + embed = discord.Embed(color=0xffd540) + embed.add_field(name=f"{title}", value=f"{text}") + embed.set_footer(text=f"© {owner} • {date.today()}", icon_url=f"{icon}") + return embed