index — Deutsche-Haus-Bot @ 568c67f85804d7b402ba2855813e545fd7cbd6be

Discord bot to dynamically create voice chats for clubs that boosters can create

bot.py (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
import discord
import discord.ext.commands
import bot_token
import db as database
import logic

# ======================== STARTUP =========================== #

bot = discord.Bot()

role_converter = discord.ext.commands.RoleConverter()
member_converter = discord.ext.commands.MemberConverter()


# ======================= INITIALIZATION ========================== #

@bot.listen()
async def on_guild_join(guild):
    await logic.on_guild_join(guild.id)


# ======================= SETUP ========================= #

@bot.slash_command(description="Gibt alle Commands zurück, die für die Initialisation des Bots nötig sind") 
async def setup(ctx):
    if not ctx.author.guild_permissions.administrator:
        ctx.respond("Du musst Administrator sein, um diesen Command auszuführen")
        return
    await ctx.respond(await logic.setup(ctx.guild.id))

@bot.slash_command(description="Setzt die Booster Rolle intern im Bot")
async def setze_booster_rolle(ctx, booster_rolle):
    if not ctx.author.guild_permissions.administrator:
        ctx.respond("Du musst Administrator sein, um diesen Command auszuführen")
        return
    await ctx.respond(await logic.add_booster_role(ctx.guild.id, int(booster_rolle[3:-1])))

@bot.slash_command(description="Setzt den Verteiler Channel intern im Bot")
async def setze_verteiler_channel(ctx, verteiler_channel_id):
    if not ctx.author.guild_permissions.administrator:
        ctx.respond("Du musst Administrator sein, um diesen Command auszuführen")
        return
    await ctx.respond(await logic.add_distributor_channel(ctx.guild.id, int(verteiler_channel_id)))

@bot.slash_command(description="Setzt die Kategorie, in der die Clubs erstellt werden sollen")
async def setze_club_kategorie(ctx, kategorie_id):
    if not ctx.author.guild_permissions.administrator:
        ctx.respond("Du musst Administrator sein, um diesen Command auszuführen")
        return
    await ctx.respond(await logic.add_club_category(ctx.guild.id, int(kategorie_id)))



"""
@bot.slash_command(description="Füge neue Rollen zu der Datenbank hinzu")
@discord.ext.commands.has_role()
async def
"""

@bot.slash_command()
async def get_existing_roles(ctx):
    results = ctx.guild.roles
    print(results)


@bot.slash_command()
async def test(ctx):
    await ctx.guild.create_role(name = "hi", color=int("0x"+("#5460D9"[1:]), 16)+0x200, mentionable = False)
    await ctx.respond("hi")

# ======================== ADD CLUB ================================ #

@bot.slash_command(description="Erstellt einen Booster Club")
async def club_hinzuftügen(ctx, kanalname, emoji, rollenname, rollenfarbe):

    if ctx.author.get_role(await logic.add_club(ctx.guild.id, kanalname, emoji, rollenname, rollenfarbe, ctx.author.id, 1))== None:
        await ctx.respond("Du bist kein Booster")
        return
    response = await logic.add_club(ctx.guild.id, kanalname, emoji, rollenname, rollenfarbe, ctx.author.id, 2)
    if type(response) == str:
        await ctx.respond(response)
        return
    else:
        await ctx.guild.create_role(name = response[0], color = response[1], mentionable = False)

    role = await role_converter.convert(ctx, rollenname)
    
    response = await logic.add_club(ctx.guild.id, kanalname, emoji, rollenname, role.id, ctx.author.id, 3)
    if response != None:
        await ctx.respond(response)
    await ctx.respond("✅ Club erstellt!")  

# ==================== EDIT CLUBS ====================== #

@bot.slash_command(description="Ändert den Channel Name des Clubs")
async def club_channel_name_aendern(ctx, neuer_name):
    await ctx.respond(await logic.club_change_channel_name(ctx.guild.id, ctx.author.id, neuer_name))

# ========================= dsfsf ======================= #
@bot.slash_command(description="Fügt Member zu eigenem Club hinzu")
async def mitglied_hinzufuegen(ctx, member):
    db = database.Database(f"{ctx.guild.id}.db")
    response = await db.add_member(member[2:-1], ctx.author.id)
    if response != None:
        await ctx.respond(response)
        return

    member = await member_converter.convert(ctx, member)

    response = await db.select_club_by_owner(ctx.author.id)
    if response == None:
        await ctx.respond("Du hast keinen Club")
        return
    role = await role_converter.convert(ctx, str(response))


    await member.add_roles(role)
    await ctx.respond(":white_check_mark:")


@bot.command(description="Sends the bot's latency.") # this decorator makes a slash command
async def ping(ctx): # a slash command will be created with the name "ping"
    await ctx.respond(f"Pong! Latency is {bot.latency}")

# ==================== distributor vc ======================= #

@bot.slash_command(description="Setzt join to create VC")
@discord.ext.commands.has_role(1170646611332956208)
async def verteiler_setzen(kanal_id):
    pass

#@bot.listen()
async def on_voice_state_update(user, before, after):
    if after.channel.id == 1:
        print(f"{user.name} Joined The {after.channel.name} VC")
        print(after.channel.members)



bot.run(bot_token.token)