-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbot.py
66 lines (48 loc) · 2.18 KB
/
bot.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
#!/usr/bin/python3
import os
from os import listdir
from os.path import isfile, join
from utils.config import CGPT_PROMPT
import nextcord as discord
from revChatGPT.V3 import Chatbot
from nextcord.errors import HTTPException
from nextcord.ext import commands
import google.generativeai as genai
from utils.config import ROLE_CHANNEL, ROLES_CHANNEL_MESSAGE, SELF_ASSIGN_ROLES
intents = discord.Intents.default()
intents.all()
intents.message_content = True
intents.members = True
TOKEN = os.environ['TOKEN']
def get_prefix(bot, message):
"""A callable Prefix for our bot."""
prefixes = ['!']
# Check to see if we are outside of a guild. e.g DM's etc.
if not message.guild:
# Only allow ? to be used in DMs
return '?'
# If we are in a guild, we allow for the user to mention us or use any of the prefixes in our list.
return commands.when_mentioned_or(*prefixes)(bot, message)
# bot = commands.Bot(command_prefix=get_prefix, description='Gronp Bot.', intents=intents)
bot = commands.Bot(command_prefix="!", description='Gronp Bot.', intents=intents)
# Here we load our extensions(cogs) listed above in [initial_extensions].
if __name__ == '__main__':
cogs_dir = 'cogs'
for extension in [f.replace('.py', '') for f in listdir(cogs_dir) if isfile(join(cogs_dir, f))]:
try:
print(f"loading extension {extension}")
bot.load_extension(cogs_dir + "." + extension)
# except (discord.ClientException, commands.NoEntryPointError, ModuleNotFoundError):
except Exception as e:
raise e
print(f'Failed to load extension {extension}: {e}.')
@bot.event
async def on_ready():
"""http://discordpy.readthedocs.io/en/rewrite/api.html#discord.on_ready"""
print(f'\n\nLogged in as: {bot.user.name} - {bot.user.id}\nVersion: {discord.__version__}\n')
# Changes our bots Playing Status. type=1(streaming) for a standard game you could remove type and url.
await bot.change_presence(
activity=discord.Streaming(name='Dom Jot', url='https://www.facebook.com/groups/1477972915840370'))
bot.cgpt_enabled = True
print(f'Successfully logged in and booted...!')
bot.run(TOKEN, reconnect=True)