-
Notifications
You must be signed in to change notification settings - Fork 0
/
BotService.py
62 lines (46 loc) · 1.46 KB
/
BotService.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
# BotService.py
import os
import discord
from dotenv import load_dotenv
import CurrencyService
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')
channel_id = 732615927266541649
client = discord.Client()
@client.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
guild = discord.utils.get(client.guilds, name=GUILD)
print(
f'{client.user} is connected to the following guild:\n'
f'{guild.name}(id: {guild.id})'
)
exalted_price = CurrencyService.get_exalted_price()
print(exalted_price)
channel = client.get_channel(channel_id)
await channel.send('exalted price is ' + str(exalted_price))
## 573780952237473802
# Print list of members
# members = '\n - '.join([member.name for member in guild.members])
# print(f'Guild Members:\n - {members}')
# @tasks.loop(seconds=5.0)
# async def printer(self):
# print(self.index)
# self.index += 1
# @client.event
# async def on_message(message):
# # we do not want the bot to reply to itself
# if message.author == client.user:
# return
#
# if message.content.startswith('!hello'):
# msg = 'Hello {0.author.mention}'.format(message)
# await client.send_message(message.channel, msg)
@client.event
async def on_member_join(member):
await member.create_dm()
await member.dm_channel.send(
f'Hi {member.name}, welcome to the server!'
)
client.run(TOKEN)