forked from Feeenix/tictactoe_bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
102 lines (79 loc) · 3.55 KB
/
main.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
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
import os
from faker import Faker
import string
import sys
import time
import datetime
import json
import requests
import urllib
import nextcord
from nextcord import Interaction, SlashOption, ChannelType
from nextcord.ext import commands
from nextcord.abc import GuildChannel
import random
import ccard
from cogs.buttons import TictactoeButtons
# intents = nextcord.Intents().all()
client = commands.Bot(command_prefix="$", )
# client.remove_command("help")
#
testing_server_ids = [814404883255132181,874954049517154315]
faker = Faker()
@client.event
async def on_ready():
print("client is ready")
print(client.user.name)
print(client.user.id)
print("------")
@client.slash_command(description="hollow erld",guild_ids=testing_server_ids,force_global=True)
async def test(interaction: Interaction, attachment:nextcord.Attachment=None,args:str="asdasdasd"):
await interaction.response.send_message("ehe."+str(args),)
print("test",args)
return
@client.slash_command(description="your very own credit card number generator!",guild_ids=testing_server_ids,force_global=True)
async def random_credit_card(interaction: Interaction):
number = ccard.visa()
name = faker.name()
await interaction.response.send_message("Your random credit card number is: "+" ".join([ number[index:index+4] for index,substring in enumerate(number) if index%4==0])+".\n"+
"CVV: "+str(random.randint(100,999))+"\n"+
"Expiration date: "+str(random.randint(1,12))+"/"+str(random.randint(22,31))+"\n"+
"Name on card: "+"".join([ random.choice(["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]) for i in range(0,10)])+
" "+ name +"\n"
)
return
class tic_tac_toe_game:
def __init__(self,thread_channel,author,challenged,author_name,challenged_name):
self.thread_channel = thread_channel
self.board = [
[" "," "," "],
[" "," "," "],
[" "," "," "]
]
self.author = author
self.challenged = challenged
self.name_author = author_name
self.name_challenged = challenged_name
self.turn = "x"
self.winner = None
self.draw = False
self.game_over = False
self.game_started = False
self.game_ended = False
def make_embed(self):
embed = nextcord.Embed(title="Tic Tac Toe",description=f"Game of {self.author} vs. {self.challenged}\n"+"\n".join([ "".join([f":{cell}:" for cell in row ]) for row in self.board ]))
return embed
async def send_board_buttons(self):
buttons = TictactoeButtons(self.board)
await self.thread_channel.send(embed=self.make_embed(),view=buttons.get_board_buttons())
@client.slash_command(description="tic tac toe",guild_ids=testing_server_ids,force_global=True)
async def tictactoe(interaction: Interaction, challenger:nextcord.Member="AI"):
print(interaction)
author_name = interaction.user.nick if interaction.user.nick else interaction.user.name # str
challenger_name = (challenger.nick if challenger.nick else challenger.name) if not type(challenger) is str else "AI" # str
await interaction.response.send_message("you challenged "+(challenger_name),ephemeral=False,view=TictactoeButtons())
thread = await interaction.channel.create_thread(name=author_name+" vs "+challenger_name,auto_archive_duration=1440,type=ChannelType(11) )
game = tic_tac_toe_game(thread,interaction.user,challenger,author_name,challenger_name)
await game.send_board_buttons()
return
client.run(os.getenv("TOKEN"))