Skip to content

Commit

Permalink
Merge pull request #4 from Zingzy/new-commands
Browse files Browse the repository at this point in the history
Add new Bot Commands
  • Loading branch information
IviriusMain authored Oct 1, 2024
2 parents 01f7d30 + 89ce52e commit abfff1d
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 29 deletions.
20 changes: 13 additions & 7 deletions cogs/moderation_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ async def purge(self, interaction:discord.Interaction, amount: int, channel: dis
await interaction.response.send_message(embed=discord.Embed(description="You don't have the permissions to do that!", color=discord.Color.red()), ephemeral=True)
return

await interaction.response.defer()

if channel is None:
channel = interaction.channel

await channel.purge(limit=amount)
def check(msg):
return not msg.pinned

await channel.purge(limit=amount, check=check)

embed = discord.Embed(
title="Purge",
description=f"Purged {amount} messages",
Expand All @@ -123,7 +125,8 @@ async def purge(self, interaction:discord.Interaction, amount: int, channel: dis
)
embed.add_field(name="Channel", value=channel.mention, inline=False)
embed.set_footer(text=f"Purged {amount} messages")
await interaction.followup.send(embed=embed)

await interaction.response.send_message(embed=embed)

@app_commands.command(name="slowmode", description="Sets a slowmode for a channel")
@app_commands.guild_only()
Expand Down Expand Up @@ -209,7 +212,7 @@ async def removerole(self, interaction, user: discord.Member, role: discord.Role
@app_commands.default_permissions(administrator=True)
@app_commands.describe(name="The name of the channel", category="The category to create the channel in", private="Whether the channel should be private or not", emoji="The emoji to use for the channel")
async def createchannel(self, interaction, emoji: str, name: str, category: discord.CategoryChannel = None, private: bool = False):
name = f"{emoji}{name}" if emoji else name
name = f"{emoji}{name}" if emoji else name
if not private:
await interaction.guild.create_text_channel(name=name, category=category)
else:
Expand Down Expand Up @@ -284,7 +287,7 @@ async def deleterole(self, interaction, role: discord.Role):
@app_commands.default_permissions(administrator=True)
@app_commands.describe(name="The name of the category", emoji="The emoji to use for the category")
async def createcategory(self, interaction, emoji:str, name: str):
name = f"{emoji}{name}" if emoji else name
name = f"{emoji}{name}" if emoji else name
category = await interaction.guild.create_category(name=name)
embed = discord.Embed(
title="Category Created",
Expand Down Expand Up @@ -346,7 +349,10 @@ async def createemoji(self, interaction, name: str, url: str):
@app_commands.guild_only()
@app_commands.default_permissions(administrator=True)
@app_commands.describe(channel="The channel to edit", name="The new name of the channel", category="The new category of the channel", private="Whether the channel should be private or not", slowmode="The new slowmode of the channel")
async def editchannel(self, interaction, channel: discord.TextChannel, name: str, category: discord.CategoryChannel = None, private: bool = False, slowmode: int = None):
async def editchannel(self, interaction, channel: discord.TextChannel, emoji: str, name: str, category: discord.CategoryChannel = None, private: bool = False, slowmode: int = None):
name = f"{emoji}{name}" if not emoji.strip()=="" else name
if not category:
category = channel.category
await channel.edit(name=name, category=category, overwrites={interaction.guild.default_role: discord.PermissionOverwrite(read_messages=False)} if private else None, slowmode_delay=slowmode)
embed = discord.Embed(
title="Channel Edited",
Expand Down
21 changes: 0 additions & 21 deletions cogs/poll_cog.py

This file was deleted.

53 changes: 53 additions & 0 deletions cogs/server_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import datetime
from discord import app_commands, ui
from discord.ext import commands
import discord
from utils import *
from constants import *
from api import app
import aiohttp

class server_info(commands.Cog):
def __init__(self, bot):
self.bot = bot

@app_commands.command(name="member-count", description="Get the number of members in the server")
@app_commands.guild_only()
async def member_count(self, interaction:discord.Interaction):
human_members = len([member for member in interaction.guild.members if not member.bot])

embed = discord.Embed(
title="Member Count",
description=f"Total Members: {len(interaction.guild.members)}",
color=discord.Color.green()
)

embed.add_field(name="Humans", value=f"```{human_members}```", inline=True)
embed.add_field(name="Bots", value=f"```{len(interaction.guild.members) - human_members}```", inline=True)

embed.set_footer(text=f"Requested by {interaction.user.display_name}", icon_url=interaction.user.avatar.url)

await interaction.response.send_message(embed=embed)

@app_commands.command(name="links", description="Get Links to various Ivirius Products")
@app_commands.guild_only()
async def links(self, interaction:discord.Interaction):
embed = discord.Embed(
title="Ivirius Links",
description="Here are some links to Ivirius products",
color=discord.Color.green()
)

embed.add_field(name="Website <:Ivirius:1290061289258745896>", value="https://ivirius.vercel.app/", inline=False)
embed.add_field(name="Rebound 11 <:Rebound11:1290061222494081075>", value="https://ivirius.vercel.app/rebound11", inline=False)
embed.add_field(name="Ivirius Text Editor Plus <:TextEditorPlus:1290061177140936704>", value="https://ivirius.vercel.app/ivirius-text-editor-plus", inline=False)
embed.add_field(name="Ivirius Text Editor <:TextEditor:1290061049352949791>", value="https://ivirius.vercel.app/ivirius-text-editor/", inline=False)
embed.add_field(name="Crimson UI <:CrimsonUI:1290061257361064062>", value="https://ivirius.vercel.app/crimsonui", inline=False)

embed.set_footer(text=f"Requested by {interaction.user.display_name}", icon_url=interaction.user.avatar.url if interaction.user.avatar else interaction.user.default_avatar.url)

await interaction.response.send_message(embed=embed)

async def setup(bot):
await bot.add_cog(server_info(bot))
print("Loaded server_info.py")
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class zippyBot(commands.Bot):
def __init__(self):
super().__init__(
command_prefix="$", intents=discord.Intents.all(), help_command=None
command_prefix=">> ", intents=discord.Intents.all(), help_command=None
)
self.synced = False

Expand Down

0 comments on commit abfff1d

Please sign in to comment.