summaryrefslogtreecommitdiff
path: root/cogs/test.py
blob: ab395f2c03b54847bad28c7150cb19cb648966b7 (plain)
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
import asyncio
import datetime

from discord.ext import commands
import discord
import re
import upsidedown
import importlib
import utils
importlib.reload(utils)


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

    @commands.command()
    async def test(self, ctx):
        """testing"""
        components = discord.ui.MessageComponents(
            discord.ui.ActionRow(
                discord.ui.Button(label="Do not click me", custom_id="bad_touch", style=discord.ButtonStyle.red)
            ),
            discord.ui.ActionRow(
                discord.ui.Button(label="Click me", custom_id="good_touch", style=discord.ButtonStyle.green)
            ),
        )
        sent_message: discord.Message = await ctx.send("Do not press this button", components=components)

        def check(interaction: discord.Interaction):
            return True

        interaction: discord.Interaction = await self.bot.wait_for("component_interaction", check=check)
        if interaction.component.custom_id == "bad_touch":
            await interaction.message.reply(content=f"{interaction.user.mention} is a nonce!")
        else:
            await interaction.message.reply(content=f"{interaction.user.mention} is an egg!")


def setup(bot):
    print("INFO: Loading [Test]... ", end="")
    bot.add_cog(Test(bot))
    print("Done!")


def teardown(bot):
    print("INFO: Unloading [Test]")