summaryrefslogtreecommitdiff
path: root/src/teawie_bot/bot.py
blob: cb90804e183d93dc53da1951d9da9720b7544a9e (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
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
import discord
from discord import app_commands
from discord.ext import commands

from teawie_bot.apis import guzzle
from teawie_bot import utils

SERVER_ID = discord.Object(id=1055663552679137310)
intents = discord.Intents.default()
intents.message_content = True  # pylint: disable=assigning-non-slot
bot = commands.Bot(command_prefix="m!",
                   description="teawie time",
                   intents=intents)


@bot.event
async def on_ready():
	print(f"logged in as {bot.user}")
	await bot.tree.sync(guild=SERVER_ID)
	print("ready!")


@bot.event
async def on_message(message: discord.Message):
	if message.author == bot.user:
		return

	echo_messages = [
	    "🗿",
	]
	echo_messages = echo_messages + utils.Teawies(bot).emojis
	try:
		index = echo_messages.index(message.content.lower())
		await message.channel.send(echo_messages[index])
	except ValueError:
		pass

	await bot.process_commands(message)


@bot.command()
async def ask(ctx: commands.Context):
	await ctx.send(utils.get_random_response(bot, utils.Teawies(bot)))


@bot.tree.command(
    name="ask",
    description="ask lord teawie a question and they shall respond",
    guild=SERVER_ID)
async def ask_slash_command(interaction: discord.Interaction):
	msg = utils.get_random_response(bot, utils.Teawies(bot))
	while not msg:
		msg = utils.get_random_response(bot, utils.Teawies(bot))
	await interaction.response.send_message(msg)


@bot.command()
async def teawiespam(ctx: commands.Context):
	if not discord.utils.get(bot.emojis, name="teawiesmile"):
		return
	msg = str()
	for _ in range(50):
		msg += str(discord.utils.get(bot.emojis, name="teawiesmile"))

	await ctx.send(msg)


@bot.tree.command(name="copypasta",
                  description="send funni copypasta",
                  guild=SERVER_ID)
@app_commands.choices(choices=[
    app_commands.Choice(name="happymeal", value="happymeal"),
    app_commands.Choice(name="ismah", value="ismah"),
    app_commands.Choice(name="sus", value="sus"),
    app_commands.Choice(name="ticktock", value="ticktock"),
    app_commands.Choice(name="amongus_sus", value="amongus_sus"),
    app_commands.Choice(name="egrill", value="egrill"),
    app_commands.Choice(name="dvd", value="dvd"),
])
async def copypasta(interaction: discord.Interaction,
                    choices: app_commands.Choice[str]):
	msgs = utils.get_copypasta(choices.value)
	for i, msg in enumerate(msgs):
		if i == 0:
			await interaction.response.send_message(msg)
		else:
			await interaction.channel.send(msg)


@bot.tree.command(name="random_teawie",
                  description="get a random teawie!",
                  guild=SERVER_ID)
async def random_teawie(interaction: discord.Interaction):
	msg = guzzle.get_random_teawie()
	await interaction.response.send_message(msg)