-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
51 lines (40 loc) · 1.37 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
import discord
from discord import option
from utils import vt_file
import time
import os
intents = discord.Intents.all()
bot = discord.Bot(intents=intents)
DT_API_KEY = os.environ.get('DT_API_KEY')
@bot.event
async def on_ready():
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="for files to scan"))
print(f"Connected as {bot.user}")
@bot.slash_command(name="ping", description="Pings the bot")
async def ping(ctx):
embed=discord.Embed(color=0x333aff)
embed.add_field(name="🏓 Pong! ", value=f"The bot latency is {round(bot.latency * 1000)}ms", inline=False)
await ctx.respond(embed=embed)
@bot.slash_command(name="check")
@option(
"attachment",
discord.Attachment,
description="A mischievous attachment to scan...",
# The default value will be None if the user doesn't provide a file.
required=True,
)
async def say(
ctx: discord.ApplicationContext,
attachment: discord.Attachment,
):
if attachment:
await ctx.defer()
file = await attachment.to_file()
await attachment.save(file.filename)
embed, img, f_name = vt_file(file.filename)
os.remove(file.filename)
await ctx.send_followup(embed=embed, file=img)
os.remove(f_name)
else:
await ctx.respond("You didn't give me a file to reply with! :sob:")
bot.run(DT_API_KEY)