This repository has been archived by the owner on Mar 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
135 lines (103 loc) · 4.99 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
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
from discord import Message, Member
from discord.ext import commands
from discord.ext.commands import Context
from discord.utils import get
from datetime import date
import random
import time
import discord.utils
# ---------------------------------------------- #
# ----------- BOT VARIABLES SECTION ------------ #
# ---------------------------------------------- #
TOKEN = '' # BOT TOKEN, DO NOT SHARE
COMMAND_PREFIX = "!"
today = str(date.today())
oraUp = time.strftime("%H", time.localtime())
minutiUp = time.strftime("%M", time.localtime())
colore = 0x822434
# ---------------------------------------------- #
# ----------- BOT STARTUP SECTION ------------ #
# ---------------------------------------------- #
bot = discord.Client()
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix=COMMAND_PREFIX, intents=intents)
bot = commands.Bot(command_prefix=COMMAND_PREFIX, intents=intents)
# ---------------------------------------------- #
# ------------ BOT.EVENT SECTION --------------- #
# ---------------------------------------------- #
@bot.event
async def on_ready():
print('Bot server started as nickname {0.user}'.format(bot))
# ----------------------------------------------------- #
# ------------- BOT.COMMANDS SECTION ------------------ #
# ----------------------------------------------------- #
@bot.command()
async def hello(ctx: Context):
await ctx.channel.send(embed=discord.Embed(title="Ciao!", description="Come va?", color=colore))
@bot.command()
async def ora(ctx: Context):
ora = int(time.strftime("%H", time.localtime()))
minuti = time.strftime("%M")
orario = 'Sono le ore ' + str(ora + 1) + ":" + minuti
await ctx.channel.send(embed=discord.Embed(title="Ora", description=orario, color=colore))
@bot.command()
async def uptime(ctx: Context):
string = 'Sono online dalle ore ' + str(int(oraUp) + 1) + ":" + minutiUp + ' del giorno ' + today
await ctx.channel.send(embed=discord.Embed(title="Uptime", description=string, color=colore))
@bot.command()
async def roll(ctx: Context, *args):
errore = 'I dati inseriti sono errati, utilizzare la formula "!roll LANCIdFACCE", per esempio 1d20 per un lancio di un dado a 20 facce.\n\
Il massimo di facce e lanci è 200, i valori negativi non vengono accettati.\n'
istruzioni = 'Utilizzare la formula "!roll LANCIdFACCE", per esempio 1d20 per un lancio di un dado a 20 facce.\n' \
'Il massimo di facce e lanci è 200, i valori negativi non vengono accettati.\n'
try:
stringok = False
stringa = args[0]
stringok = True
listaDadoRoll = stringa.split('d')
if int(listaDadoRoll[0]) > 200 or int(listaDadoRoll[1]) > 200 or int(listaDadoRoll[0]) <= 0 or int(
listaDadoRoll[1]) <= 0:
await ctx.channel.send(embed=discord.Embed(title="Istruzioni", description=istruzioni, color=colore))
else:
resultStrDadi = ''
rollSomma = 0
for tiri in range(int(listaDadoRoll[0])):
rollTemp = random.randint(0, int(listaDadoRoll[1]) - 1)
resultStrDadi = resultStrDadi + ' ' + str(rollTemp + 1)
rollSomma += rollTemp + 1
if int(listaDadoRoll[0]) == 1:
await ctx.channel.send(
embed=discord.Embed(title="Il risultato del lancio è:", description=str(rollSomma), color=colore))
else:
await ctx.channel.send(embed=discord.Embed(title="Il risultato del lancio è:",description=resultStrDadi + ' ' + '\n' + 'La somma è ' + str(rollSomma), color=0x822434))
except:
if stringok:
await ctx.channel.send(embed=discord.Embed(title="Errore", description=errore, color=colore))
else:
await ctx.channel.send(embed=discord.Embed(title="Istruzioni", description=istruzioni, color=colore))
@bot.command()
async def f(ctx: Context):
await ctx.channel.send(embed=discord.Embed(
description='**FFFFFFFFFFFFFFFF**\n**F**\n**F**\n**F**\n**FFFFFFFFF**\n**F**\n**F**\n**F**\n**F**\n**F**',
color=0x822434))
# ---------------------------------------------- #
# ------------ BOT.EVENT SECTION --------------- #
# ---------------------------------------------- #
@bot.event
async def on_message(message):
if message.author == bot.user:
return
ciao = "fh"
if '*' in message.content:
stringa = message.content.replace('*', 'Ə') + ' #GenderNeutrale'
await message.channel.send(embed=discord.Embed(title="#GenderNeutrale", description=stringa, color=colore))
if message.channel.id == 816773641572057119:
descrizione = ""
channel = bot.get_channel(776145787566161980)
titolo = message.content.split("\n")
for elemento in titolo[1:]:
descrizione += elemento + "\n"
await channel.send(embed=discord.Embed(title=titolo[0], description=descrizione, color=colore))
await bot.process_commands(message)
bot.run(TOKEN)