forked from Cobular/distest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_target.py
112 lines (98 loc) · 3.97 KB
/
example_target.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
"""
This bot is a sample bot that is used to demonstrate the testing functionality.
It does not run the tests, just exists to have tests run on it.
Run with:
python example_target.py TARGET_TOKEN
"""
import asyncio
import random
import sys
import discord
client = discord.Client()
@client.event
async def on_ready():
print("Ready")
text_channel_id = None
@client.event
async def on_message(message):
if message.author.id is client.user.id:
return
sent = None
if message.content == "ping?":
await asyncio.sleep(1)
sent = await message.channel.send("pong!")
if message.content.startswith("Say something matching the regex"):
await asyncio.sleep(1)
sent = await message.channel.send("61")
if message.content == "Please say 'epic!'":
await asyncio.sleep(1)
sent = await message.channel.send("epic!")
if message.content.startswith("Say something containing 'gamer'"):
await asyncio.sleep(1)
sent = await message.channel.send("gamers r00l")
if message.content.startswith("Post something with an image!"):
await asyncio.sleep(1)
sent = await message.channel.send("https://imgs.xkcd.com/comics/ui_vs_ux.png")
if message.content.startswith("React with"):
await asyncio.sleep(1)
sent = await message.add_reaction("\u2714")
if message.content.startswith("Click the Check!"):
await asyncio.sleep(1)
sent = await message.add_reaction("\u2714")
if message.content.startswith("Test the Embed!"):
await asyncio.sleep(1)
embed = discord.Embed(
title="This is a test!",
description="Descriptive",
url="http://www.example.com",
color=0x00FFCC,
)
embed.set_author(name="Author")
embed.set_image(
url="https://upload.wikimedia.org/wikipedia/commons/4/40/Test_Example_%28cropped%29.jpg"
)
embed.set_thumbnail(
url="https://upload.wikimedia.org/wikipedia/commons/4/40/Test_Example_%28cropped%29.jpg"
)
sent = await message.channel.send(embed=embed)
if message.content.startswith("Test the Part Embed!"):
await asyncio.sleep(1)
embed = discord.Embed(title="Testing Title.", description="Right Description!")
sent = await message.channel.send(embed=embed)
if message.content.startswith("Test the Embed regex!"):
await asyncio.sleep(1)
embed = discord.Embed(
title="Test the Embed regex!",
description="Random Number: " + random.randint(10, 99),
)
sent = await message.channel.send(embed=embed)
if message.content.startswith("Say some stuff, but at 4 seconds, say 'yeet'"):
await asyncio.sleep(1)
await message.channel.send("hahaha!")
await message.channel.send("No!")
await message.channel.send("Ok...")
await asyncio.sleep(2.5)
sent = await message.channel.send("yeet")
if message.content.startswith("Create a tc called yeet"):
global text_channel_id
await asyncio.sleep(1)
text_channel = await message.guild.create_text_channel("yeet")
text_channel_id = text_channel.id
if message.content.startswith("Delete that TC bro!"):
await asyncio.sleep(1)
text_channel = client.get_channel(text_channel_id)
await text_channel.delete()
if sent is not None:
print("Message sent: {}".format(sent.clean_content))
if message.content.startswith("Say stuff in another channel"):
await asyncio.sleep(1)
await client.get_channel(694397509958893640).send("here is a message in another channel")
@client.event
async def on_message_edit(before, after):
sent = None
if after.content.startswith("Say 'Yeah, that is cool!'"):
await asyncio.sleep(1)
sent = await after.channel.send("Yeah, that is cool!")
if sent is not None:
print("Message sent: {}".format(sent.clean_content))
client.run(sys.argv[1])