remove coder, commands, languages cogs. Add roles cog. Add more libs. Extract views and buttons.
This commit is contained in:
parent
85d23dd6ac
commit
4418ccebfc
28
__main__.py
28
__main__.py
|
|
@ -1,8 +1,11 @@
|
||||||
import os
|
import os
|
||||||
import asyncio
|
import asyncio
|
||||||
import discord
|
import discord
|
||||||
|
from discord import Client
|
||||||
from libs.Db import Db
|
from libs.Db import Db
|
||||||
from libs.BotLog import BotLog
|
from libs.BotLog import BotLog
|
||||||
|
from libs.Channels import Channel
|
||||||
|
from libs.Guilds import Guilds
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
|
@ -10,6 +13,7 @@ load_dotenv()
|
||||||
token = os.getenv("DISCORD_TOKEN")
|
token = os.getenv("DISCORD_TOKEN")
|
||||||
prefix = os.getenv("COMMAND_PREFIX")
|
prefix = os.getenv("COMMAND_PREFIX")
|
||||||
guild_id = os.getenv("GUILD_ID")
|
guild_id = os.getenv("GUILD_ID")
|
||||||
|
dev_mode = os.getenv("DEV_MODE")
|
||||||
|
|
||||||
bot_intents = discord.Intents.default()
|
bot_intents = discord.Intents.default()
|
||||||
bot_intents.message_content = True
|
bot_intents.message_content = True
|
||||||
|
|
@ -25,19 +29,24 @@ class FunkyBot(commands.Bot):
|
||||||
self.log_handler = BotLog("bot.log")
|
self.log_handler = BotLog("bot.log")
|
||||||
self.db = Db('sqlite:///data/bot.db', True)
|
self.db = Db('sqlite:///data/bot.db', True)
|
||||||
self.guild_id = guild_id
|
self.guild_id = guild_id
|
||||||
|
self.dev_mode = dev_mode == "1"
|
||||||
|
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
print(f"Logged in as {self.user.name}")
|
print(f"Logged in as {self.user.name}")
|
||||||
# await self.cmd_tree.sync(guild=discord.Object(id=551671017823797248))
|
guild = discord.Object(id=guild_id)
|
||||||
await self.load_cogs()
|
synced = await self.tree.sync(guild=guild)
|
||||||
for cog in self.cogs:
|
|
||||||
print(f"{cog} Commands")
|
|
||||||
cg = self.get_cog(cog)
|
|
||||||
cmds = cg.get_commands()
|
|
||||||
print([f"/{c.name}" for c in cmds])
|
|
||||||
synced = await self.tree.sync(guild=discord.Object(id=guild_id))
|
|
||||||
print(synced)
|
print(synced)
|
||||||
|
|
||||||
|
async def async_cleanup(self):
|
||||||
|
guild = await Guilds().get_guild(self)
|
||||||
|
channel = await Channel().get_channel(guild, "add-roles")
|
||||||
|
await channel.purge()
|
||||||
|
await channel.send("FunkyBot is currently sleeping. Please try again once he has awakened.")
|
||||||
|
|
||||||
|
async def close(self):
|
||||||
|
await self.async_cleanup()
|
||||||
|
await super().close()
|
||||||
|
|
||||||
async def on_member_join(self, member):
|
async def on_member_join(self, member):
|
||||||
channel = discord.utils.get(member.guild.channels, name="general")
|
channel = discord.utils.get(member.guild.channels, name="general")
|
||||||
role = discord.utils.get(await member.guild.fetch_roles(), name="Chinstrap Penguins")
|
role = discord.utils.get(await member.guild.fetch_roles(), name="Chinstrap Penguins")
|
||||||
|
|
@ -46,16 +55,17 @@ class FunkyBot(commands.Bot):
|
||||||
await member.add_roles(role)
|
await member.add_roles(role)
|
||||||
await channel.send(f"Another Penguin has joined the Collective. Everyone say hi to {member.mention}!")
|
await channel.send(f"Another Penguin has joined the Collective. Everyone say hi to {member.mention}!")
|
||||||
|
|
||||||
|
|
||||||
async def load_cogs(self):
|
async def load_cogs(self):
|
||||||
for filename in os.listdir("./cogs"):
|
for filename in os.listdir("./cogs"):
|
||||||
if filename.endswith(".py"):
|
if filename.endswith(".py"):
|
||||||
await self.load_extension(f"cogs.{filename[:-3]}")
|
await self.load_extension(f"cogs.{filename[:-3]}")
|
||||||
print(f"Loaded {filename[:-3]}")
|
print(f"Loaded {filename[:-3]}")
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
bot = FunkyBot()
|
bot = FunkyBot()
|
||||||
async with bot:
|
async with bot:
|
||||||
|
await bot.load_cogs()
|
||||||
await bot.start(token)
|
await bot.start(token)
|
||||||
|
|
||||||
asyncio.run(main())
|
asyncio.run(main())
|
||||||
|
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
||||||
import discord
|
|
||||||
from discord import app_commands
|
|
||||||
from discord.ext import commands
|
|
||||||
from libs.Cog import Cog
|
|
||||||
from libs.Role import Role
|
|
||||||
|
|
||||||
|
|
||||||
class Coder(Cog):
|
|
||||||
|
|
||||||
def __init__(self, bot):
|
|
||||||
super().__init__(bot)
|
|
||||||
self.messages_deletable = True
|
|
||||||
self.role = Role()
|
|
||||||
|
|
||||||
@app_commands.command(
|
|
||||||
name="coder",
|
|
||||||
description="removes the Matrix-Refuser Penguins role if you have it, and adds the Matrix Penguins role"
|
|
||||||
)
|
|
||||||
async def coder(self, interaction: discord.Interaction):
|
|
||||||
await self.role.add_role(interaction, "Matrix Penguins")
|
|
||||||
await self.role.remove_role(interaction, "Matrix-Refuser Penguins")
|
|
||||||
await interaction.response.send_message("You are now a Matrix Penguin", ephemeral=True)
|
|
||||||
|
|
||||||
@app_commands.command(
|
|
||||||
name="nocoder",
|
|
||||||
description="removes the Matrix Penguins role from your status"
|
|
||||||
)
|
|
||||||
async def nocoder(self, interaction: discord.Interaction):
|
|
||||||
await self.role.remove_role(interaction, "Matrix Penguins")
|
|
||||||
await interaction.response.send_message("You are no longer a Matrix Penguin", ephemeral=True)
|
|
||||||
|
|
||||||
@app_commands.command(
|
|
||||||
name="refuse",
|
|
||||||
description="removes the Matrix Penguins role if you have it, and adds the Matrix-Refuser Penguins role"
|
|
||||||
)
|
|
||||||
async def refuse(self, interaction: discord.Interaction):
|
|
||||||
await self.role.add_role(interaction, "Matrix-Refuser Penguins")
|
|
||||||
await self.role.remove_role(interaction, "Matrix Penguins")
|
|
||||||
await interaction.response.send_message("You are now a Matrix-Refuser Penguin", ephemeral=True)
|
|
||||||
|
|
||||||
@app_commands.command(
|
|
||||||
name="norefuse",
|
|
||||||
description="removes the Matrix-Refuser Penguins role from your status"
|
|
||||||
)
|
|
||||||
async def norefuse(self, interaction: discord.Interaction):
|
|
||||||
await self.role.remove_role(interaction, "Matrix-Refuser Penguins")
|
|
||||||
await interaction.response.send_message("You are no longer a Matrix-Refuser Penguin", ephemeral=True)
|
|
||||||
|
|
||||||
async def setup(bot):
|
|
||||||
await bot.add_cog(Coder(bot), guilds=[discord.Object(id=bot.guild_id)])
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
from discord.ext import commands
|
|
||||||
from libs.Cog import Cog
|
|
||||||
|
|
||||||
|
|
||||||
class Commands(Cog):
|
|
||||||
|
|
||||||
def __init__(self, bot):
|
|
||||||
super().__init__(bot)
|
|
||||||
self.messages_deletable = True
|
|
||||||
|
|
||||||
@commands.command()
|
|
||||||
async def commands(self, ctx):
|
|
||||||
current_cmds = []
|
|
||||||
for cog in self.bot.cogs:
|
|
||||||
if cog != "Commands":
|
|
||||||
cg = self.bot.get_cog(cog)
|
|
||||||
cmds = cg.get_commands()
|
|
||||||
current_cmds.append(f"/{c.name} - {c.description}" for c in cmds)
|
|
||||||
await ctx.author.send("\n".join(current_cmds))
|
|
||||||
await self.delete_message(ctx.message)
|
|
||||||
|
|
||||||
|
|
||||||
async def setup(bot):
|
|
||||||
await bot.add_cog(Commands(bot))
|
|
||||||
|
|
@ -1,112 +0,0 @@
|
||||||
import discord
|
|
||||||
from discord import app_commands
|
|
||||||
from discord.ext import commands
|
|
||||||
from libs.Cog import Cog
|
|
||||||
from libs.Role import Role
|
|
||||||
|
|
||||||
|
|
||||||
class Languages(Cog):
|
|
||||||
|
|
||||||
def __init__(self, bot):
|
|
||||||
super().__init__(bot)
|
|
||||||
self.messages_deletable = True
|
|
||||||
self.role = Role()
|
|
||||||
|
|
||||||
@app_commands.command(
|
|
||||||
name="php",
|
|
||||||
description="adds the PHP role"
|
|
||||||
)
|
|
||||||
async def php(self, interaction: discord.Interaction):
|
|
||||||
await self.role.add_role(interaction, "PHP")
|
|
||||||
await interaction.response.send_message("You are now associated with the PHP language group", ephemeral=True)
|
|
||||||
|
|
||||||
@app_commands.command(
|
|
||||||
name="nophp",
|
|
||||||
description="removes the PHP role if you have it"
|
|
||||||
)
|
|
||||||
async def nophp(self, interaction: discord.Interaction):
|
|
||||||
await self.role.remove_role(interaction, "PHP")
|
|
||||||
await interaction.response.send_message("You are no longer associated with the PHP language group", ephemeral=True)
|
|
||||||
|
|
||||||
@app_commands.command(
|
|
||||||
name="python",
|
|
||||||
description="adds the Python role"
|
|
||||||
)
|
|
||||||
async def python(self, interaction: discord.Interaction):
|
|
||||||
await self.role.add_role(interaction, "Python")
|
|
||||||
await interaction.response.send_message("You are now associated with the Python language group", ephemeral=True)
|
|
||||||
|
|
||||||
@app_commands.command(
|
|
||||||
name="nopython",
|
|
||||||
description="removes the Python role if you have it"
|
|
||||||
)
|
|
||||||
async def nophp(self, interaction: discord.Interaction):
|
|
||||||
await self.role.remove_role(interaction, "Python")
|
|
||||||
await interaction.response.send_message("You are no longer associated with the Python language group", ephemeral=True)
|
|
||||||
|
|
||||||
@app_commands.command(
|
|
||||||
name="js",
|
|
||||||
description="adds the JavaScript role"
|
|
||||||
)
|
|
||||||
async def js(self, interaction: discord.Interaction):
|
|
||||||
await self.role.add_role(interaction, "JavaScript")
|
|
||||||
await interaction.response.send_message("You are now associated with the JavaScript language group", ephemeral=True)
|
|
||||||
|
|
||||||
@app_commands.command(
|
|
||||||
name="nojs",
|
|
||||||
description="removes the JavaScript role if you have it"
|
|
||||||
)
|
|
||||||
async def nojs(self, interaction: discord.Interaction):
|
|
||||||
await self.role.remove_role(interaction, "JavaScript")
|
|
||||||
await interaction.response.send_message("You are no longer associated with the JavaScript language group", ephemeral=True)
|
|
||||||
|
|
||||||
@app_commands.command(
|
|
||||||
name="ruby",
|
|
||||||
description="adds the Ruby role"
|
|
||||||
)
|
|
||||||
async def ruby(self, interaction: discord.Interaction):
|
|
||||||
await self.role.add_role(interaction, "Ruby")
|
|
||||||
await interaction.response.send_message("You are now associated with the Ruby language group", ephemeral=True)
|
|
||||||
|
|
||||||
@app_commands.command(
|
|
||||||
name="noruby",
|
|
||||||
description="removes the Ruby role if you have it"
|
|
||||||
)
|
|
||||||
async def noruby(self, interaction: discord.Interaction):
|
|
||||||
await self.role.remove_role(interaction, "Ruby")
|
|
||||||
await interaction.response.send_message("You are no longer associated with the Ruby language group", ephemeral=True)
|
|
||||||
|
|
||||||
@app_commands.command(
|
|
||||||
name="cs",
|
|
||||||
description="adds the C# role"
|
|
||||||
)
|
|
||||||
async def cs(self, interaction: discord.Interaction):
|
|
||||||
await self.role.add_role(interaction, "C#")
|
|
||||||
await interaction.response.send_message("You are now associated with the C# language group", ephemeral=True)
|
|
||||||
|
|
||||||
@app_commands.command(
|
|
||||||
name="nocs",
|
|
||||||
description="removes the C# role if you have it"
|
|
||||||
)
|
|
||||||
async def nocs(self, interaction: discord.Interaction):
|
|
||||||
await self.role.remove_role(interaction, "C#")
|
|
||||||
await interaction.response.send_message("You are no longer associated with the C# language group", ephemeral=True)
|
|
||||||
|
|
||||||
@app_commands.command(
|
|
||||||
name="java",
|
|
||||||
description="adds the Java role"
|
|
||||||
)
|
|
||||||
async def java(self, interaction: discord.Interaction):
|
|
||||||
await self.role.add_role(interaction, "Java")
|
|
||||||
await interaction.response.send_message("You are now associated with the Java language group", ephemeral=True)
|
|
||||||
|
|
||||||
@app_commands.command(
|
|
||||||
name="nojava",
|
|
||||||
description="removes the Java role if you have it"
|
|
||||||
)
|
|
||||||
async def nojava(self, interaction: discord.Interaction):
|
|
||||||
await self.role.remove_role(interaction, "Java")
|
|
||||||
await interaction.response.send_message("You are no longer associated with the Java language group", ephemeral=True)
|
|
||||||
|
|
||||||
async def setup(bot):
|
|
||||||
await bot.add_cog(Languages(bot), guilds=[discord.Object(id=bot.guild_id)])
|
|
||||||
35
cogs/roles.py
Normal file
35
cogs/roles.py
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
import discord
|
||||||
|
from discord import Embed
|
||||||
|
from discord.ext import commands
|
||||||
|
from libs.Channels import Channel
|
||||||
|
from libs.Guilds import Guilds
|
||||||
|
from libs.Cog import Cog
|
||||||
|
from views.MatrixButtons import MatrixButtons
|
||||||
|
from views.LanguageButtons import LanguageButtons
|
||||||
|
|
||||||
|
class RolesCog(Cog):
|
||||||
|
|
||||||
|
def __init__(self, bot):
|
||||||
|
super().__init__(bot)
|
||||||
|
self.bot = bot
|
||||||
|
self.messages_deletable = True
|
||||||
|
|
||||||
|
@commands.Cog.listener()
|
||||||
|
async def on_ready(self):
|
||||||
|
guild = await Guilds().get_guild(self.bot)
|
||||||
|
channel = await Channel().get_channel(guild, "add-roles")
|
||||||
|
matrix_embed = Embed(title="Matrix Roles", color=discord.Color.purple(), description="Please select your choice between these two roles. "
|
||||||
|
"\nClick to add. Click again to remove. "
|
||||||
|
"\nAlso, clicking on one of them will remove the other, if you have it. "
|
||||||
|
"\n(Clicking Matrix Penguins, will remove Matrix-Refuser Penguins and add Matrix Penguins).")
|
||||||
|
language_embed = Embed(title="Language Roles", color=discord.Color.purple(), description="Please select your choice of languages to be associated with. "
|
||||||
|
"\nClick to add. Click again to remove.")
|
||||||
|
|
||||||
|
if channel is not None:
|
||||||
|
await channel.purge()
|
||||||
|
await channel.send(embed=matrix_embed, view=MatrixButtons())
|
||||||
|
await channel.send(embed=language_embed, view=LanguageButtons())
|
||||||
|
|
||||||
|
|
||||||
|
async def setup(bot):
|
||||||
|
await bot.add_cog(RolesCog(bot))
|
||||||
10
libs/Channels.py
Normal file
10
libs/Channels.py
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
class Channel:
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
async def get_channel(self, guild, channel_name):
|
||||||
|
channel = None
|
||||||
|
for c in guild.channels:
|
||||||
|
if c.name == channel_name:
|
||||||
|
channel = c
|
||||||
|
return channel
|
||||||
|
|
@ -13,5 +13,4 @@ class Cog(commands.Cog):
|
||||||
|
|
||||||
async def delete_message(self, interaction: discord.Interaction):
|
async def delete_message(self, interaction: discord.Interaction):
|
||||||
if self.messages_deletable:
|
if self.messages_deletable:
|
||||||
print(interaction.message)
|
|
||||||
await interaction.message.delete()
|
await interaction.message.delete()
|
||||||
12
libs/Guilds.py
Normal file
12
libs/Guilds.py
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
class Guilds:
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
async def get_guild(self, bot):
|
||||||
|
guild = None
|
||||||
|
for g in bot.guilds:
|
||||||
|
if bot.dev_mode and g.name == 'OgmaBotDev':
|
||||||
|
guild = g
|
||||||
|
elif g.name == 'The Penguin Collective':
|
||||||
|
guild = g
|
||||||
|
return guild
|
||||||
22
libs/LanguageButton.py
Normal file
22
libs/LanguageButton.py
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
import discord
|
||||||
|
from libs.Roles import Roles
|
||||||
|
|
||||||
|
|
||||||
|
class LanguageButton(discord.ui.Button):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.style = discord.ButtonStyle.blurple
|
||||||
|
self.label = "Not Set"
|
||||||
|
self.disabled: bool = False
|
||||||
|
|
||||||
|
async def callback(self, interaction: discord.Interaction):
|
||||||
|
role = await Roles().get_role(interaction.guild, self.label)
|
||||||
|
message = None
|
||||||
|
if role in interaction.user.roles:
|
||||||
|
await Roles().remove_role(interaction.guild, self.label, interaction.user)
|
||||||
|
message = f"You are no longer associated with the {self.label} language group"
|
||||||
|
else:
|
||||||
|
await Roles().add_role(interaction.guild, self.label, interaction.user)
|
||||||
|
message = f"You are now associated with the {self.label} language group"
|
||||||
|
await interaction.response.send_message(message, delete_after=5, ephemeral=True)
|
||||||
29
libs/Role.py
29
libs/Role.py
|
|
@ -1,29 +0,0 @@
|
||||||
import discord
|
|
||||||
|
|
||||||
|
|
||||||
class Role:
|
|
||||||
async def get_role(self, interaction, role):
|
|
||||||
fetched_role = None
|
|
||||||
for r in interaction.guild.roles:
|
|
||||||
if r.name == role:
|
|
||||||
fetched_role = r
|
|
||||||
return fetched_role
|
|
||||||
|
|
||||||
async def add_role(self, interaction, role):
|
|
||||||
print(f"Fetching {role}")
|
|
||||||
fetched_role = await self.get_role(interaction, role)
|
|
||||||
print(f"Fetched {fetched_role.name}")
|
|
||||||
if fetched_role is not None:
|
|
||||||
print(f"fetched_role is not None")
|
|
||||||
member = interaction.user
|
|
||||||
print(member)
|
|
||||||
if fetched_role not in member.roles:
|
|
||||||
await member.add_roles(fetched_role)
|
|
||||||
print(member.roles)
|
|
||||||
|
|
||||||
async def remove_role(self, interaction, role):
|
|
||||||
fetched_role = await self.get_role(interaction, role)
|
|
||||||
if fetched_role is not None:
|
|
||||||
member = interaction.user
|
|
||||||
if fetched_role in member.roles:
|
|
||||||
await member.remove_roles(fetched_role)
|
|
||||||
32
libs/Roles.py
Normal file
32
libs/Roles.py
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
class Roles:
|
||||||
|
async def get_role(self, guild, role):
|
||||||
|
fetched_role = None
|
||||||
|
for r in guild.roles:
|
||||||
|
if r.name == role:
|
||||||
|
fetched_role = r
|
||||||
|
return fetched_role
|
||||||
|
|
||||||
|
async def get_roles(self, guild, roles):
|
||||||
|
found_roles = []
|
||||||
|
for r in guild.roles:
|
||||||
|
if r.name in roles:
|
||||||
|
found_roles.append(r)
|
||||||
|
return found_roles
|
||||||
|
|
||||||
|
async def add_role(self, guild, role, user):
|
||||||
|
fetched_role = await self.get_role(guild, role)
|
||||||
|
role_added = False
|
||||||
|
if fetched_role is not None:
|
||||||
|
if fetched_role not in user.roles:
|
||||||
|
await user.add_roles(fetched_role)
|
||||||
|
role_added = True
|
||||||
|
return role_added
|
||||||
|
|
||||||
|
async def remove_role(self, guild, role, user):
|
||||||
|
fetched_role = await self.get_role(guild, role)
|
||||||
|
role_removed = False
|
||||||
|
if fetched_role is not None:
|
||||||
|
if fetched_role in user.roles:
|
||||||
|
await user.remove_roles(fetched_role)
|
||||||
|
role_removed = True
|
||||||
|
return role_removed
|
||||||
18
views/LanguageButtons.py
Normal file
18
views/LanguageButtons.py
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
import discord
|
||||||
|
from views.items.JSLanguageButton import JSLanguageButton
|
||||||
|
from views.items.PHPLanguageButton import PHPLanguageButton
|
||||||
|
from views.items.RubyLanguageButton import RubyLanguageButton
|
||||||
|
from views.items.CSLanguageButton import CSLanguageButton
|
||||||
|
from views.items.JavaLanguageButton import JavaLanguageButton
|
||||||
|
from views.items.PythonLanguageButton import PythonLanguageButton
|
||||||
|
|
||||||
|
class LanguageButtons(discord.ui.View):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(timeout=None)
|
||||||
|
self.add_item(PHPLanguageButton())
|
||||||
|
self.add_item(JSLanguageButton())
|
||||||
|
self.add_item(RubyLanguageButton())
|
||||||
|
self.add_item(CSLanguageButton())
|
||||||
|
self.add_item(JavaLanguageButton())
|
||||||
|
self.add_item(PythonLanguageButton())
|
||||||
51
views/MatrixButtons.py
Normal file
51
views/MatrixButtons.py
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
import discord
|
||||||
|
from libs.Roles import Roles
|
||||||
|
from views.items.MatrixPenguinsButton import MatrixPenguinsButton
|
||||||
|
from views.items.MatrixRefuserPenguinsButton import MatrixRefuserPenguinsButton
|
||||||
|
|
||||||
|
class MatrixButtons(discord.ui.View):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(timeout=None)
|
||||||
|
self.matrix_role = None
|
||||||
|
self.matrix_refuser_role = None
|
||||||
|
self.add_item(MatrixPenguinsButton())
|
||||||
|
self.add_item(MatrixRefuserPenguinsButton())
|
||||||
|
|
||||||
|
# async def set_roles(self, guild):
|
||||||
|
# self.matrix_role = await Roles().get_role(guild, "Matrix Penguins")
|
||||||
|
# self.matrix_refuser_role = await Roles().get_role(guild, "Matrix-Refuser Penguins")
|
||||||
|
#
|
||||||
|
# @discord.ui.button(label="Matrix Penguins", style=discord.ButtonStyle.blurple)
|
||||||
|
# async def matrix_click(self, interaction: discord.Interaction, button):
|
||||||
|
# member = interaction.user
|
||||||
|
# content = []
|
||||||
|
# await self.set_roles(interaction.guild)
|
||||||
|
#
|
||||||
|
# if self.matrix_role in member.roles:
|
||||||
|
# if await Roles().remove_role(interaction.guild, "Matrix Penguins", member):
|
||||||
|
# content.append("Matrix Penguins has been removed")
|
||||||
|
# else:
|
||||||
|
# if await Roles().remove_role(interaction.guild, "Matrix-Refuser Penguins", member):
|
||||||
|
# content.append("Matrix-Refuser Penguins has been removed")
|
||||||
|
# if await Roles().add_role(interaction.guild, "Matrix Penguins", member):
|
||||||
|
# content.append("Matrix Penguins has been added")
|
||||||
|
#
|
||||||
|
# await interaction.response.send_message(" and ".join(content), delete_after=5, ephemeral=True)
|
||||||
|
#
|
||||||
|
# @discord.ui.button(label="Matrix-Refuser Penguin", style=discord.ButtonStyle.red)
|
||||||
|
# async def refuser_click(self, interaction: discord.Interaction, button):
|
||||||
|
# member = interaction.user
|
||||||
|
# content = []
|
||||||
|
# await self.set_roles(interaction.guild)
|
||||||
|
#
|
||||||
|
# if self.matrix_refuser_role in member.roles:
|
||||||
|
# if await Roles().remove_role(interaction.guild, "Matrix-Refuser Penguins", member):
|
||||||
|
# content.append("Matrix-Refuser Penguin has been removed")
|
||||||
|
# else:
|
||||||
|
# if await Roles().remove_role(interaction.guild, "Matrix Penguins", member):
|
||||||
|
# content.append("Matrix Penguins has been removed")
|
||||||
|
# if await Roles().add_role(interaction.guild, "Matrix-Refuser Penguins", member):
|
||||||
|
# content.append("Matrix-Refuser Penguins has been added")
|
||||||
|
#
|
||||||
|
# await interaction.response.send_message(" and ".join(content), delete_after=5, ephemeral=True)
|
||||||
11
views/items/CSLanguageButton.py
Normal file
11
views/items/CSLanguageButton.py
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
import discord
|
||||||
|
from libs.LanguageButton import LanguageButton
|
||||||
|
|
||||||
|
|
||||||
|
class CSLanguageButton(LanguageButton):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.style = discord.ButtonStyle.blurple
|
||||||
|
self.label = "C#"
|
||||||
|
self.disabled: bool = False
|
||||||
11
views/items/JSLanguageButton.py
Normal file
11
views/items/JSLanguageButton.py
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
import discord
|
||||||
|
from libs.LanguageButton import LanguageButton
|
||||||
|
|
||||||
|
|
||||||
|
class JSLanguageButton(LanguageButton):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.style = discord.ButtonStyle.blurple
|
||||||
|
self.label = "JavaScript"
|
||||||
|
self.disabled: bool = False
|
||||||
11
views/items/JavaLanguageButton.py
Normal file
11
views/items/JavaLanguageButton.py
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
import discord
|
||||||
|
from libs.LanguageButton import LanguageButton
|
||||||
|
|
||||||
|
|
||||||
|
class JavaLanguageButton(LanguageButton):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.style = discord.ButtonStyle.blurple
|
||||||
|
self.label = "Java"
|
||||||
|
self.disabled: bool = False
|
||||||
27
views/items/MatrixPenguinsButton.py
Normal file
27
views/items/MatrixPenguinsButton.py
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
import discord
|
||||||
|
from libs.Roles import Roles
|
||||||
|
|
||||||
|
|
||||||
|
class MatrixPenguinsButton(discord.ui.Button):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.style = discord.ButtonStyle.blurple
|
||||||
|
self.label = "Matrix Penguins"
|
||||||
|
self.disabled: bool = False
|
||||||
|
|
||||||
|
async def callback(self, interaction: discord.Interaction):
|
||||||
|
member = interaction.user
|
||||||
|
content = []
|
||||||
|
matrix_role = await Roles().get_role(interaction.guild, "Matrix Penguins")
|
||||||
|
|
||||||
|
if matrix_role in member.roles:
|
||||||
|
if await Roles().remove_role(interaction.guild, "Matrix Penguins", member):
|
||||||
|
content.append("Matrix Penguins has been removed")
|
||||||
|
else:
|
||||||
|
if await Roles().remove_role(interaction.guild, "Matrix-Refuser Penguins", member):
|
||||||
|
content.append("Matrix-Refuser Penguins has been removed")
|
||||||
|
if await Roles().add_role(interaction.guild, "Matrix Penguins", member):
|
||||||
|
content.append("Matrix Penguins has been added")
|
||||||
|
|
||||||
|
await interaction.response.send_message(" and ".join(content), delete_after=5, ephemeral=True)
|
||||||
27
views/items/MatrixRefuserPenguinsButton.py
Normal file
27
views/items/MatrixRefuserPenguinsButton.py
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
import discord
|
||||||
|
from libs.Roles import Roles
|
||||||
|
|
||||||
|
|
||||||
|
class MatrixRefuserPenguinsButton(discord.ui.Button):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.style = discord.ButtonStyle.red
|
||||||
|
self.label = "Matrix-Refuser Penguins"
|
||||||
|
self.disabled: bool = False
|
||||||
|
|
||||||
|
async def callback(self, interaction: discord.Interaction):
|
||||||
|
member = interaction.user
|
||||||
|
content = []
|
||||||
|
matrix_refuser_role = await Roles().get_role(interaction.guild, "Matrix-Refuser Penguins")
|
||||||
|
|
||||||
|
if matrix_refuser_role in member.roles:
|
||||||
|
if await Roles().remove_role(interaction.guild, "Matrix-Refuser Penguins", member):
|
||||||
|
content.append("Matrix-Refuser Penguins has been removed")
|
||||||
|
else:
|
||||||
|
if await Roles().remove_role(interaction.guild, "Matrix Penguins", member):
|
||||||
|
content.append("Matrix-Refuser Penguins has been removed")
|
||||||
|
if await Roles().add_role(interaction.guild, "Matrix-Refuser Penguins", member):
|
||||||
|
content.append("Matrix-Refuser Penguins has been added")
|
||||||
|
|
||||||
|
await interaction.response.send_message(" and ".join(content), delete_after=5, ephemeral=True)
|
||||||
11
views/items/PHPLanguageButton.py
Normal file
11
views/items/PHPLanguageButton.py
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
import discord
|
||||||
|
from libs.LanguageButton import LanguageButton
|
||||||
|
|
||||||
|
|
||||||
|
class PHPLanguageButton(LanguageButton):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.style = discord.ButtonStyle.blurple
|
||||||
|
self.label = "PHP"
|
||||||
|
self.disabled: bool = False
|
||||||
11
views/items/PythonLanguageButton.py
Normal file
11
views/items/PythonLanguageButton.py
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
import discord
|
||||||
|
from libs.LanguageButton import LanguageButton
|
||||||
|
|
||||||
|
|
||||||
|
class PythonLanguageButton(LanguageButton):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.style = discord.ButtonStyle.blurple
|
||||||
|
self.label = "Python"
|
||||||
|
self.disabled: bool = False
|
||||||
11
views/items/RubyLanguageButton.py
Normal file
11
views/items/RubyLanguageButton.py
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
import discord
|
||||||
|
from libs.LanguageButton import LanguageButton
|
||||||
|
|
||||||
|
|
||||||
|
class RubyLanguageButton(LanguageButton):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.style = discord.ButtonStyle.blurple
|
||||||
|
self.label = "Ruby"
|
||||||
|
self.disabled: bool = False
|
||||||
Loading…
Reference in a new issue