Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #3 from TheKaushikGoswami/patch
Browse files Browse the repository at this point in the history
Enhancement: Improved Code and made it more Efficient + Removed Useless Imports
  • Loading branch information
TheKaushikGoswami authored Jan 26, 2022
2 parents 3cea1c6 + 443c10d commit 008f4ed
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 27 deletions.
4 changes: 2 additions & 2 deletions cogs/api_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from discord.ext import commands
import io
from logging import error
from discord.commands.commands import Option, slash_command
from discord import Option, slash_command
from discord.ext import commands
import aiohttp
import requests
Expand Down Expand Up @@ -115,7 +115,7 @@ async def pandafact(self, ctx):
# YearFact

@slash_command()
async def yearfact (self, ctx):
async def yearfact(self, ctx):
"""📅 Sends a random Year fact"""
await ctx.defer()
async with aiohttp.ClientSession() as cs:
Expand Down
22 changes: 11 additions & 11 deletions cogs/fun.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import discord
from discord.commands.commands import Option, slash_command
from discord import Option, slash_command
from discord.errors import Forbidden
from discord.ext import commands
import random
Expand All @@ -14,7 +14,7 @@ def __init__(self, bot):

# 8ball

@slash_command(name="8ball", guild_ids=[830504002905964586, 828550575023980554, 820621306797359124])
@slash_command(name="8ball")
async def _8ball(self, ctx, *, question: Option(str, "Write Your Question", required=True)):
"""The Ultimate 8-ball game is now on Discord 🎱"""
responses = ['It is certain.',
Expand Down Expand Up @@ -44,16 +44,11 @@ async def _8ball(self, ctx, *, question: Option(str, "Write Your Question", requ
value=f"**My Magic Foretells me:\n `{random.choice(responses)}`**",)
await ctx.respond(embed=e)

@_8ball.error
async def _8ball_error(self, ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.respond('Please ask a Question!')

# Lovemeter

@slash_command()
async def lovemeter(self, ctx, name1: Option(str, "Enter the name of 1st lovebird", required=True), name2: Option(str, "Enter the name of 2nd lovebird", required=True)):
"""How Much DO You Love Me~ Senpai? 💖"""
"""How Much Do You Love Me~ Senpai? 💖"""
percentage = random.randint(0, 100)

if 0 <= percentage <= 10:
Expand Down Expand Up @@ -370,8 +365,12 @@ def reaction_check(m):
try:
await msg.add_reaction("🍻")
await self.bot.wait_for('raw_reaction_add', timeout=10.0, check=reaction_check)
await msg.edit(content=f"**{user.mention}** and **{ctx.author.mention}** Are enjoying a lovely 🍻 coz\n\n `{reason}`")
await msg.clear_reactions()
if reason == None:
await msg.edit(content=f"**{user.mention}** and **{ctx.author.mention}** Are enjoying a lovely 🍻")
await msg.clear_reactions()
else:
await msg.edit(content=f"**{user.mention}** and **{ctx.author.mention}** Are enjoying a lovely 🍻 coz\n\n `{reason}`")
await msg.clear_reactions()
except asyncio.TimeoutError:
await msg.delete()
await ctx.send(f"Well, it seems **{user.name}** didn't wanted to say 'cheers' with **`{ctx.author.name}`** ;-;")
Expand Down Expand Up @@ -472,7 +471,7 @@ async def kill(self, ctx, user: Option(discord.Member, "Choose The User", requir
'dressing up as a cookie and cookie monster ate them.',
'trying to re-act Indiana Jones, died from a snake bite.',
'tried to short circuit me, not that easy retard',
'tried to fight a bear with there hands',
'tried to fight a bear with their hands',
'getting Billy Heartied in the ball sacks'
]
await ctx.respond(embed=discord.Embed(
Expand Down Expand Up @@ -562,6 +561,7 @@ async def snap(self, ctx, member: Option(discord.Member, "Choose the Member", re

# setup COMMAND


def setup(bot):
bot.add_cog(Fun(bot))
print("Fun Cog is Loaded\n------")
8 changes: 4 additions & 4 deletions cogs/help.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import discord
from discord.commands.commands import slash_command
from discord.ext import commands
from discord import slash_command
from disputils import BotEmbedPaginator

color = 0x1ABC9C
Expand All @@ -26,17 +26,17 @@ async def help(self, ctx):
embed1.add_field(
name="🛡️ Moderation", value=f'`nick` `purge` `purgeuser` `mute` `unmute` `kick` `ban` `nuke` `role` `slowmode` `lock` `unlock` `name_role`', inline=False)
embed1.add_field(
name="⚽ Fun & Games", value=f'`8ball` `lovemeter` `rps` `sad/happy/angry` `hello` `lenny` `flip` `f` `calculator` `diceroll` `meme` `joke` `password` `slots` `cheers` `simp` `iq` `roast` `kill`', inline=False)
name="⚽ Fun & Games", value=f'`8ball` `activity` `lovemeter` `rps` `sad/happy/angry` `hello` `lenny` `flip` `f` `calculator` `diceroll` `meme` `joke` `password` `slots` `cheers` `simp` `iq` `roast` `kill`', inline=False)
embed1.add_field(
name="🖼️ Images", value=f'`cat` `dog` `panda` `koala` `clyde` `facepalm` `wink` `headpat` `triggered` `hug` `snap`', inline=False)
embed1.add_field(
name="🛠️ Utility", value=f'`userinfo` `serverinfo` `avatar` `membercount` `roleinfo` `channelstats` `say` `mentions` `timer`', inline=False)
embed1.add_field(
name="💭 Facts & Advices", value=f'`dogfact` `catfact` `pandafact` `numberfact` `yearfact` `advice`', inline=False)
embed1.add_field(
name="🤖 SPIKE", value=f'`about` `ping` `invite` `support` `help` `uptime`', inline=False)
name="🤖 Olympus", value=f'`about` `ping` `invite` `support` `help` `uptime`', inline=False)
embed1.add_field(
name=f"👑 Owner Only", value=f'`stats` `serverlist` `createinvite`', inline=False)
name=f"👑 Owner Only", value=f'`stats` `serverlist` `createinvite` `leave`', inline=False)

embed1.set_footer(
text=f"Olympus is made with ❤️ | _TheKauchikG_#5300", icon_url=f'{ctx.author.avatar.url}')
Expand Down
6 changes: 3 additions & 3 deletions cogs/mod.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import discord
from discord.commands.commands import Option
from discord import Option
from discord.commands.errors import ApplicationCommandInvokeError
from discord.errors import NotFound
from discord.ext import commands
Expand Down Expand Up @@ -44,7 +44,7 @@ async def nick_error(self, ctx, error):

@slash_command()
@commands.has_permissions(manage_messages=True)
async def purge(self, ctx, amount: Option(int, "Enter the number of messages to be purged", required=False)):
async def purge(self, ctx, amount: Option(int, "Enter the number of messages to be purged(Default = 3)", required=False)):
"""🧹 Clears a certain amount of messages from the channel"""
if amount == None:
amount = 3
Expand All @@ -67,7 +67,7 @@ async def purge_error(self, ctx, error):

@slash_command()
@commands.has_permissions(manage_messages=True)
async def purgeuser(self, ctx, member: Option(discord.Member, "Select the Member", required=True), amount: Option(int, "Enter the number of messages to be purged", required=False)):
async def purgeuser(self, ctx, member: Option(discord.Member, "Select the Member", required=True), amount: Option(int, "Enter the number of messages to be purged(Default = 5)", required=False)):
"""🧹 Clears a certain amount of messages by a specific user"""
if amount == None:
amount = 5
Expand Down
8 changes: 4 additions & 4 deletions cogs/olympus.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import discord, datetime, time
from discord.commands.commands import slash_command
from discord import slash_command
from discord.ext import commands
import datetime
import platform
Expand All @@ -17,7 +17,7 @@ def __init__(self,bot):
@slash_command()
async def ping(self, ctx):
"""🏓 Displays the Latency of the Bot"""
msg = await ctx.respond("Pinging bot\'s latency...")
await ctx.respond("Pinging bot\'s latency...")
times = []
counter=0
embed = discord.Embed(title="More information:", description="Pinged 3 times and calculated the average.", color = ctx.author.color)
Expand Down Expand Up @@ -82,11 +82,11 @@ async def about(self, ctx):
pythonVersion = platform.python_version()
pycVersion = discord.__version__
uptime = str(datetime.timedelta(seconds=int(round(time.time()-startTime))))
embed=discord.Embed(title="About SPIKE", description=f"**Olympus** is an advanced discord bot, written in `Python` using the library named, `py-cord`.\n\n <:slash:910783011035963452> This bot is totally based on **Application Commands** AKA `/Slash commands` supporting other new discord features with it.\n\n <:badge:910783553694994453> The major features of the bot are `Moderation`, `Fun`, `Utility`, `Games`, etc. -based commands.\n\n <:users:910783496937668638> The bot is `user-friendly` too, to make it comfortable for everyone to get familiar with discord bots and stuff.", color=0x5de5c9)
embed=discord.Embed(title="About Olympus", description=f"**Olympus** is an advanced discord bot, written in `Python` using the library named, `py-cord`.\n\n <:slash:910783011035963452> This bot is totally based on **Application Commands** AKA `/Slash commands` supporting other new discord features with it.\n\n <:badge:910783553694994453> The major features of the bot are `Moderation`, `Fun`, `Utility`, `Games`, etc. -based commands.\n\n <:users:910783496937668638> The bot is `user-friendly` too, to make it comfortable for everyone to get familiar with discord bots and stuff.", color=0x5de5c9)
embed.set_thumbnail(url=f'{ctx.me.avatar.url}')
embed.add_field(name=f"__General Details__", value=f"**❯ Bot:** Olympus#5983 (902555662964359228)\n **❯ Created On:** 3rd November 2020, 1:41:38 PM IST\n **❯ Uptime:** `{uptime}`\n **❯ Developer:** `_TheKauchikG_#5300` (<@737903565313409095>)", inline=False)
embed.add_field(name=f"__Front-end Stats__", value=f"**❯ Servers:** {len(self.bot.guilds)}\n **❯ Channels:** {len(set(self.bot.get_all_channels()))}\n **❯ Users:** {len(set(self.bot.get_all_members()))}", inline=True)
embed.add_field(name=f"__Back-end Stats__", value=f"**❯ Version:** [v1](https://github.com/TheKaushikGoswami/Olympus)\n **❯ Python version:** [v{pythonVersion}](https://python.org)\n **❯ py-cord version:** [v{pycVersion}](https://pycord.dev/)\n **❯ Modules:** Total 15 modules", inline=False)
embed.add_field(name=f"__Back-end Stats__", value=f"**❯ Version:** [v2.0](https://github.com/TheKaushikGoswami/Olympus/releases)\n **❯ Python version:** [v{pythonVersion}](https://python.org)\n **❯ py-cord version:** [v{pycVersion}](https://pycord.dev/)\n **❯ Modules:** Total 15 modules", inline=False)
embed.add_field(name="__Check Out:__", value=f'[Invite](https://discord.com/api/oauth2/authorize?client_id=902555662964359228&permissions=8&scope=bot%20applications.commands) • [Support](https://discord.gg/VYDq5AheEU) • [Github(Bot)](https://github.com/TheKaushikGoswami/Olympus) • [Github(Me)](https://github.com/TheKaushikGoswami)')
embed.set_image(url=f"https://i.imgur.com/yPCP0qr.png")
embed.set_footer(icon_url=f'{ctx.me.avatar.url}', text=f"Olympus is made with ❤️ | _TheKauchikG_#5300")
Expand Down
30 changes: 30 additions & 0 deletions cogs/owner.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,36 @@ async def leave_error(self, ctx, error):
if isinstance(error, NotOwner):
await ctx.respond(f"**<:Cross:902943066724388926> Hey! You lack permission to use this command as you don't own me!**")

# Rules

@slash_command(guild_ids=[931474769797316638])
@commands.is_owner()
async def rules(self, ctx):
"""The Rules command for my Private Server"""
color = 0xa100f2
embed = discord.Embed(color=color)

embed.add_field(name='<:badge:910783553694994453> Rules! <:badge:910783553694994453>', value='**1.** Do not be racist, homophobic, or sexist, it can be overlooked if the other party is fine with it.\n\n'
'**2.** You are allowed to curse on someone as long as they do not mind. There are no barred curse words. If there are complaints on one\'s behavior then it may result in certain actions taken from the moderators.\n\n'
'**3.** You should not offend or antagonize other parties. You never know who the other party may be.\n\n'
'**4.** Spamming of texts, emojis, images, etc is strictly prohibited, if found out it may result in a permanent ban from the server.\n\n'
'**5.** The server does allow anything under the [Discord ToS](https://discord.com/terms) but it doesn\'t means that we won\'t take actions if the situation is necessary.\n\n', inline=False)
embed.add_field(name='‎‎‎‏‏‎ ‎', value='**6.** Posts related to the information of another party, private messages, or pictures without their permission will be removed. This is a rigorous policy, may result in a permanent ban.\n\n'
'**7.** Moderators have final judgment on everything, if they ask you to stop doing something then stop. Do not complain if you have been kicked or banned from the server.\n\n'
'**8.** You are free to debate about anything, just don\'t force your beliefs on others.\n\n'
'**9.** There shouldn\'t be any bullying or bad behavior to new members.\n\n'
'**10.** There should not be any sharing of graphical or image posts related to violence, gore, and things that are against Discord ToS \n\n'
'**11.** All NSFW content under ToS are allowed, as long as they are NOT in Non-NSFW channels. This includes gifs, profile pictures, status,etc.\n\n'
'**12.** Self-advertising on main channels won\'t be tolerated, asking for roles, permissions, custom commands will result in warns from the moderators.', inline=False)
embed.set_footer(icon_url=ctx.author.avatar.url, text="React with Tick below If You read everything!")
await ctx.respond(embed=embed)

@rules.error
async def rule_error(self, ctx, error):
print(type(error), "--- Rule Command")
if isinstance(error, NotOwner):
await ctx.respond(f"**<:Cross:902943066724388926> Hey! You lack permission to use this command as you don't own me!**", ephemeral=True)

def setup(bot):
bot.add_cog(Owner(bot))
print("Owner cog is Loaded\n------")
6 changes: 3 additions & 3 deletions cogs/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from discord.ext import commands
from discord.commands import slash_command
from discord.ext.commands.errors import MissingPermissions
from discord.commands.commands import slash_command, Option
from discord import slash_command, Option
from ago import human
import collections
import discord.utils
Expand Down Expand Up @@ -109,6 +109,7 @@ async def serverinfo(self, ctx):
time = ctx.guild.created_at.strftime("%a, %#d %B %Y, %I:%M %p ")
voice = str(len(guild.voice_channels))
text = str(len(guild.text_channels))
verification_level = str(guild.verification_level).capitalize()
statuses = collections.Counter(
[member.status for member in guild.members])

Expand All @@ -125,10 +126,9 @@ async def serverinfo(self, ctx):
embed.set_thumbnail(url=f"{self.me.avatar.url}")
embed.set_author(name=f"Information for {ctx.guild.name}")
embed.add_field(name="__General information__\n", value=f'**Server name : ** `{guild.name}`\n'
f'**Server region : ** `{guild.region}`\n'
f'**Server ID : ** `{guild.id}`\n'
f'**Created at : ** `{time}`\n'
f'**Verification level : ** `{guild.verification_level}`\n'
f'**Verification level : ** `{verification_level}`\n'
f'**Server owner : ** <@{ctx.guild.owner_id}> \n', inline=False)

embed.add_field(name="\n\n\n__Statistics__", value=f'**Member count : ** {ctx.guild.member_count}\n'
Expand Down

0 comments on commit 008f4ed

Please sign in to comment.