-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorder_sync.py
More file actions
executable file
·50 lines (39 loc) · 1.67 KB
/
order_sync.py
File metadata and controls
executable file
·50 lines (39 loc) · 1.67 KB
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
#!/bin/python3 -u
import os
import time
import discord
from dotenv import load_dotenv
from discord.ext import commands
import re
import asyncio
load_dotenv()
intents = discord.Intents.all()
client = commands.Bot(command_prefix='!', intents=intents)
@client.event
async def on_ready():
print('message sync started on bot {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author.id == client.user.id:
return
if message.channel.category_id == int(os.getenv('ext_order_cat')):
order_ext_file = open("order_ext.list", "r")
order_ext_list = order_ext_file.readlines()
order_ext_file.close()
order_ext_list = list(map(str.strip, order_ext_list))
if str(message.channel.id) in order_ext_list:
index = int(order_ext_list.index(str(message.channel.id)))
ext_guild = client.get_guild(int(order_ext_list[int(index-3)]))
ext_channel = ext_guild.get_channel(int(order_ext_list[int(index-2)]))
await ext_channel.send("[" + str(message.author) + "] " + message.content)
else:
order_ext_file = open("order_ext.list", "r")
order_ext_list = order_ext_file.readlines()
order_ext_file.close()
order_ext_list = list(map(str.strip, order_ext_list))
if str(message.channel.id) in order_ext_list:
index = int(order_ext_list.index(str(message.channel.id)))
main_guild = client.get_guild(int(os.getenv('main_server')))
main_channel = main_guild.get_channel(int(order_ext_list[int(index+2)]))
await main_channel.send("[" + str(message.author) + "] " + message.content)
client.run(os.getenv('TOKEN'))