Compare commits
No commits in common. "c9fc740708c67a30781c7039d1a5a827bb1eb440" and "910638621191ad97a739269fa17cf3e92d3f159c" have entirely different histories.
c9fc740708
...
9106386211
|
@ -2,7 +2,7 @@
|
|||
|
||||
from hellmbot.env import ENV
|
||||
from hellmbot.db import ServersDB
|
||||
from discord import Intents, Member, VoiceState, Permissions, errors
|
||||
from discord import Intents, Member, VoiceState, Permissions
|
||||
from discord.utils import oauth_url
|
||||
from discord.ext import commands
|
||||
|
||||
|
@ -39,7 +39,6 @@ async def on_ready() -> None:
|
|||
"""
|
||||
Displays a link to add a bot to the server
|
||||
"""
|
||||
await bot.tree.sync()
|
||||
client_id = ENV.CLIENT_ID.fget(None)
|
||||
invite = oauth_url(client_id, permissions=Permissions(
|
||||
manage_channels=True,
|
||||
|
@ -48,34 +47,7 @@ async def on_ready() -> None:
|
|||
print(f"Your bot invite link: {invite}")
|
||||
|
||||
|
||||
async def clear_channels(db: ServersDB) -> None:
|
||||
"""
|
||||
Clear previously created channels
|
||||
|
||||
:param db: Database
|
||||
"""
|
||||
channels = db.channels
|
||||
for channel in channels:
|
||||
channel = bot.get_channel(channel)
|
||||
await channel.delete()
|
||||
db.clear_channels()
|
||||
|
||||
|
||||
async def create_group(server: commands.Context.guild, db: ServersDB) -> None:
|
||||
"""
|
||||
Creates a group of voice channels to move the user and adds their id to the database
|
||||
|
||||
:param server: Discord server
|
||||
:param db: Database
|
||||
"""
|
||||
circles_count = ENV.CIRCLES_COUNT.fget(None)
|
||||
group = await server.create_category(f"{circles_count} Circles of Hell")
|
||||
for circle in range(circles_count):
|
||||
vc = await server.create_voice_channel(f"{circle + 1} Circle", category=group)
|
||||
db.add_channel(vc.id, circle + 1)
|
||||
|
||||
|
||||
@bot.hybrid_command(name="create", description="Creates a group of vc to move users")
|
||||
@bot.command()
|
||||
async def create(ctx: commands.Context) -> None:
|
||||
"""
|
||||
Creates a group of voice channels to move the user and adds their id to the database
|
||||
|
@ -84,14 +56,13 @@ async def create(ctx: commands.Context) -> None:
|
|||
"""
|
||||
server = ctx.guild
|
||||
db = ServersDB(server.id)
|
||||
await ctx.send("Creating group...", ephemeral=True)
|
||||
try:
|
||||
if db:
|
||||
await clear_channels(db)
|
||||
await create_group(server, db)
|
||||
await ctx.send("Group was created! HF!", ephemeral=True)
|
||||
except errors.Any:
|
||||
await ctx.send("An error occurred!", ephemeral=True)
|
||||
circles_count = ENV.CIRCLES_COUNT.fget(None)
|
||||
group = await server.create_category(f"{circles_count} Circles of Hell")
|
||||
if db:
|
||||
db.clear_channels()
|
||||
for circle in range(circles_count):
|
||||
vc = await server.create_voice_channel(f"{circle + 1} Circle", category=group)
|
||||
db.add_channel(vc.id, circle + 1)
|
||||
|
||||
|
||||
user_before_channels = {}
|
||||
|
|
Loading…
Reference in New Issue