-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
56 lines (46 loc) · 1.7 KB
/
bot.py
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
import asyncio
import discord
import os
from dotenv import load_dotenv
from discord.ext import commands, tasks
from web_scraping import sign_content_push, tarot_content_push, horoscope_signs
from utils import format_tarot_embed , format_horoscope_embed
from data_models import Model
import random
intents = discord.Intents.all() # This is for the bot to see the members in the server
intents.typing = False
intents.presences = False
load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")
bot = commands.Bot(command_prefix= "-" , intents=intents) # This is the prefix for the commands
model = Model()
model.create_tables()
@bot.event
async def on_ready():
print(f'Bot is ready. Logged in as {bot.user}')
sign_content_push() # This function scrapes the horoscope content and pushes it to the database
tarot_content_push() # This function scrapes the tarot content and pushes it to the database
model.remove_duplicates_if_exists()
@bot.command()
async def tarot(ctx):
tarot_cards = model.get_tarot_cards()
random_card = random.choice(tarot_cards)
embed = format_tarot_embed(random_card)
await ctx.send(embed=embed)
@bot.command()
async def burc(ctx, arg):
arg = arg.lower()
if arg in horoscope_signs: # Check if the argument is a valid zodiac sign
sign = model.get_zodiac_signs()
for i in sign:
if i.name == arg:
embed = format_horoscope_embed(i)
await ctx.send(embed=embed)
else:
await ctx.send("Geçerli bir burç ismi giriniz. (Türkçe karakter kullanmayınız.)")
def main():
loop = asyncio.get_event_loop()
loop.create_task(bot.start(TOKEN))
loop.run_forever()
if __name__ == "__main__":
main()