Add Hallöhl (Pull to Löh)
This commit is contained in:
62
bot.py
62
bot.py
@@ -9,7 +9,8 @@ import discord
|
|||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord.ext.commands import MemberConverter
|
from discord.ext.commands import MemberConverter
|
||||||
from discord_slash import SlashCommand, SlashContext, SlashCommandOptionType
|
from discord_slash import SlashCommand, SlashContext, SlashCommandOptionType
|
||||||
from discord_slash.utils.manage_commands import create_option, create_choice
|
from discord_slash.model import SlashCommandPermissionType
|
||||||
|
from discord_slash.utils.manage_commands import create_option, create_choice, create_permission
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
from lib.config import config, config_load, config_save, config_get, config_set, config_get_descriptions, \
|
from lib.config import config, config_load, config_save, config_get, config_set, config_get_descriptions, \
|
||||||
@@ -50,8 +51,11 @@ TOPFIT_WORDS = (
|
|||||||
|
|
||||||
# LOEH_ID = 327126546970312739
|
# LOEH_ID = 327126546970312739
|
||||||
LOEH_ID = 254265844928872448
|
LOEH_ID = 254265844928872448
|
||||||
|
LOEH_CHANNEL_ID = 900327877327867944
|
||||||
OWNER_ID = 327126546970312739
|
OWNER_ID = 327126546970312739
|
||||||
|
|
||||||
|
INF19X_GUILD_ID = 651348951538335744
|
||||||
|
|
||||||
OCH_LOEH_SOUND = "assets/och_loeh.mp3"
|
OCH_LOEH_SOUND = "assets/och_loeh.mp3"
|
||||||
|
|
||||||
config_load()
|
config_load()
|
||||||
@@ -281,7 +285,7 @@ async def config_prefix_command(ctx: commands.Context, cmd: str = '', key: str =
|
|||||||
|
|
||||||
# ------------------- The slashy way of life ------------------- #
|
# ------------------- The slashy way of life ------------------- #
|
||||||
|
|
||||||
slash_guild_ids = None
|
slash_guild_ids = [ 785415257308004422 ]
|
||||||
config_choices = [create_choice(name=entry[1][1], value=entry[0]) for entry in config_meta.items() if entry[1][0]]
|
config_choices = [create_choice(name=entry[1][1], value=entry[0]) for entry in config_meta.items() if entry[1][0]]
|
||||||
config_option = create_option("config_key", "A key identifying the config entry to target", str, True, config_choices)
|
config_option = create_option("config_key", "A key identifying the config entry to target", str, True, config_choices)
|
||||||
|
|
||||||
@@ -418,12 +422,64 @@ async def list_messages_slash(ctx: SlashContext, channel: Optional[discord.abc.G
|
|||||||
|
|
||||||
@slash.slash(
|
@slash.slash(
|
||||||
name="flip-pipelin",
|
name="flip-pipelin",
|
||||||
description="Toss a pipelin to your favourite teacher and see whether it's schnel or slo"
|
description="Toss a pipelin to your favourite teacher and see whether it's schnel or slo",
|
||||||
|
guild_ids=slash_guild_ids
|
||||||
)
|
)
|
||||||
async def flip_pipelin_slash(ctx: SlashContext):
|
async def flip_pipelin_slash(ctx: SlashContext):
|
||||||
await ctx.send("Pipelin " + random.choice(['schnel', 'slo']))
|
await ctx.send("Pipelin " + random.choice(['schnel', 'slo']))
|
||||||
|
|
||||||
|
|
||||||
|
@slash.slash(
|
||||||
|
name="hallöhl",
|
||||||
|
description="Pulls any member to the special Löh room",
|
||||||
|
options=[
|
||||||
|
create_option(
|
||||||
|
name="user",
|
||||||
|
description="The user to pull to the Löh room",
|
||||||
|
option_type=SlashCommandOptionType.USER,
|
||||||
|
required=True
|
||||||
|
)
|
||||||
|
],
|
||||||
|
guild_ids=slash_guild_ids
|
||||||
|
)
|
||||||
|
@slash.permission(
|
||||||
|
guild_id = INF19X_GUILD_ID,
|
||||||
|
permissions=[
|
||||||
|
create_permission(LOEH_ID, SlashCommandPermissionType.USER, permission=True),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
async def halloehl_slash(ctx: SlashContext, user: discord.Member):
|
||||||
|
if user.voice is None:
|
||||||
|
await ctx.send("User is not is not connected to a vc", hidden=True)
|
||||||
|
return
|
||||||
|
|
||||||
|
if user.voice.channel.guild.id != ctx.guild_id:
|
||||||
|
await ctx.send("User is not connected to this guild", hidden=True)
|
||||||
|
return
|
||||||
|
|
||||||
|
vc: Optional[discord.VoiceChannel] = ctx.guild.get_channel(902246980124811335)
|
||||||
|
if vc is None:
|
||||||
|
await ctx.send("This command is not available in this guild", hidden=True)
|
||||||
|
return
|
||||||
|
|
||||||
|
loeh = await _get_loeh(ctx.guild)
|
||||||
|
if loeh is None:
|
||||||
|
await ctx.send("404 - Löh not found", hidden=True)
|
||||||
|
return
|
||||||
|
|
||||||
|
if loeh not in vc.members:
|
||||||
|
await ctx.send("You are not in your channel!", hidden=True)
|
||||||
|
return
|
||||||
|
|
||||||
|
perms = loeh.permissions_in(user.voice.channel)
|
||||||
|
if not perms.view_channel or not perms.connect:
|
||||||
|
await ctx.send("Can't move user out of private channel", hidden=True)
|
||||||
|
return
|
||||||
|
|
||||||
|
await user.move_to(vc, reason="Pull to Löh")
|
||||||
|
await ctx.send("done", hidden=True)
|
||||||
|
|
||||||
|
|
||||||
# ____ ____ ___ _ _ ____ ____
|
# ____ ____ ___ _ _ ____ ____
|
||||||
# / ___| _ \ / _ \| | | | _ \/ ___|
|
# / ___| _ \ / _ \| | | | _ \/ ___|
|
||||||
# | | _| |_) | | | | | | | |_) \___ \
|
# | | _| |_) | | | | | | | |_) \___ \
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
from collections import AsyncIterable
|
from typing import Callable, AsyncGenerator, AsyncIterable, Optional, Any
|
||||||
from typing import Callable, AsyncGenerator, Optional, Any
|
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
import gtts
|
import gtts
|
||||||
|
|||||||
Reference in New Issue
Block a user