-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
168 lines (147 loc) · 6.98 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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import interactions
from interactions import CommandContext
from interactions.ext.tasks import IntervalTrigger, create_task
from configparser import ConfigParser
import random, os
config = ConfigParser()
config.read('./config/options.ini')
TOKEN = config.get('Bot_Config', 'TOKEN')
#def get_prefix(bot, message):
# if not message.guild:
# return commands.when_mentioned_or(">")(bot, message)
# conn = sqlite3.connect('config/prefixes.sqlite')
# c = conn.cursor()
# c.execute("SELECT prefix FROM prefixes WHERE guild = ?", (message.guild.id,))
# prefix = c.fetchone()[0]
# conn.close()
# return prefix
_ready: bool = False
bot = interactions.Client(token = TOKEN, intents = interactions.Intents.DEFAULT | interactions.Intents.GUILD_PRESENCES | interactions.Intents.GUILD_MEMBERS)
bot.load("interactions.ext.files")
async def presence():
act = random.randint(1, 5)
if act == 1:
dact = interactions.PresenceActivity(
type = interactions.PresenceActivityType.GAME,
name="BMO"
)
elif act == 2:
dact = interactions.PresenceActivity(
type = interactions.PresenceActivityType.STREAMING,
name="Pirates of the Enchiridion",
url="https://www.twitch.tv/0jmaster"
)
elif act == 3:
dact = interactions.PresenceActivity(
type = interactions.PresenceActivityType.LISTENING,
name="Island Song"
)
elif act == 4:
dact = interactions.PresenceActivity(
type = interactions.PresenceActivityType.WATCHING,
name="Distant Lands"
)
elif act == 5:
dact = interactions.PresenceActivity(
type = interactions.PresenceActivityType.COMPETING,
name="Card Wars"
)
return await bot.change_presence(presence=interactions.ClientPresence(status = interactions.StatusType.ONLINE, activities = [dact]))
@bot.event
async def on_ready():
global _ready
if not _ready:
print('------')
print('Logged in as')
u = interactions.User(**await bot._http.get_self())
print(u.username)
print(u.id)
print('------')
await listservers()
await presence()
change_stat.start()
_ready = True
@create_task(IntervalTrigger(10800))
async def change_stat():
await presence()
async def listservers():
print("Server List:")
for guild in bot.guilds:
print(f" Name: {str(guild.name)} || ID: {str(guild.id)}")
#@bot.event
#async def on_guild_create(guild):
# embed = interactions.Embed(title = "**Jake the Dog**",
# description = f"Hello {guild.name}!",
# color = 0xA020F0
# )
# if guild.joined_at
# for channel in guild.channels:
# if channel.type is interactions.ChannelType.GUILD_TEXT and channel.name.contains("general"):
# await channel.send(embeds = embed)
#@bot.event
#async def on_guild_remove(guild):
# conn = sqlite3.connect('config/prefixes.sqlite')
# c = conn.cursor()
# c.execute("DELETE FROM prefixes WHERE guild = ?", (guild.id,))
# conn.commit()
# conn.close()
#
#
for filename in os.listdir('./cogs'):
if filename.endswith('.py') and not filename.startswith('Owner'):
bot.load(f'cogs.{filename[:-3]}')
print(f'cogs.{filename[:-3]}')
@bot.command(description = "All servers bot is in", scope = [651230389171650560])
async def servercount(ctx: CommandContext):
await ctx.get_guild()
count = sum(1 for _ in bot.guilds)
embed = interactions.Embed(title = "**Server Count**", description = count, color = interactions.Color.red())
await ctx.send(embeds = embed)
cogchoices = [
interactions.Choice(
name = "Fun",
value = "Fun"),
interactions.Choice(
name = "Minecraft",
value = "Minecraft"),
interactions.Choice(
name = "Pokemon",
value = "Pokemon"),
interactions.Choice(
name = "Utility",
value = "Utility"),
]
@bot.command(description='Reloads extension (cogs, etc)', scope = [651230389171650560], options = [interactions.Option(
type = interactions.OptionType.STRING,
name = "extension",
description = "What extension to load",
required = True,
choices = cogchoices
)])
async def reload(ctx: CommandContext, extension):
await ctx.get_guild()
bot.reload(f'cogs.{extension}', remove_commands=False)
await ctx.send(f'Extension "{extension}" reloaded!')
@bot.command(description = "Loads extension", scope = [651230389171650560], options = [interactions.Option(
type = interactions.OptionType.STRING,
name = "extension",
description = "What extension to load",
required = True,
choices = cogchoices
)])
async def load(ctx: CommandContext, extension):
await ctx.get_guild()
bot.load(f'cogs.{extension}')
await ctx.send(f'Extension "{extension}" loaded')
@bot.command(description = "Unloads extension", scope = [651230389171650560], options = [interactions.Option(
type = interactions.OptionType.STRING,
name = "extension",
description = "What extension to load",
required = True,
choices = cogchoices
)])
async def unload(ctx: CommandContext, extension):
await ctx.get_guild()
bot.remove(f'cogs.{extension}')
await ctx.send(f'Extension "{extension}" unloaded')
bot.start()