-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot_test.py
64 lines (57 loc) · 1.89 KB
/
bot_test.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
import discord
from discord.ext import commands
import json
import os, sys, socket
import datetime as dt
with open('setting.json', mode='r', encoding='utf8') as jfile:
jdata = json.load(jfile)
bot = commands.Bot(command_prefix= '>|')
"""
if len(sys.argv) == 1:
print("please add folder names as argument")
exit
else:
test_folder = (sys.argv[1])
"""
@bot.event
async def on_ready():
print(f"Test Bot host by `{socket.gethostname()}` is online")
channel = bot.get_channel(int(jdata['chennel_bot-playground']))
await channel.send(f"Test Bot `{socket.gethostname()}` As your service!")
# Core的功能僅開放guild_permissions.administrator使用
@bot.command()
async def load(ctx, extension):
if ctx.author.guild_permissions.administrator:
bot.unload_extension(f'cmds.{extension}')
await ctx.send(f'Loaded extension: {extension}.')
else:
msg = "You aren't the `Administrator`"
await ctx.send(msg)
@bot.command()
async def unload(ctx, extension):
if ctx.author.guild_permissions.administrator:
bot.unload_extension(f'cmds.{extension}')
await ctx.send(f'Unloaded extension: {extension}.')
else:
msg = "You aren't the `Administrator`"
await ctx.send(msg)
@bot.command()
async def reload(ctx, extension):
if ctx.author.guild_permissions.administrator:
bot.reload_extension(f'cmds.{extension}')
await ctx.send(f'Reloaded extension: {extension}.')
else:
msg = "You aren't the `Administrator`"
await ctx.send(msg)
extension_name = 'cmds.tweet_forwarder_sql'
bot.load_extension(extension_name)
bot.load_extension('cmds.yt_forwarder')
"""
for filename in os.listdir(f'./cmds'):
if filename.endswith('.py'):
extension_name = f'cmds.{filename[:-3]}'
print(extension_name)
bot.load_extension(extension_name)
"""
if __name__ == '__main__':
bot.run(jdata['TOKEN'])