Beispiel #1
0
    async def checkTime(self):
        """Checks if there is a session going on."""
        while True:

            await asyncio.sleep(20)

            schedules = await self.get_campaign_data()

            for campaign in schedules:

                await self.bot.wait_until_ready()

                channel = self.bot.get_channel(schedules[campaign]["channel"])

                current_time = (datetime.now() -
                                timedelta(hours=8)).strftime("%A, %H:%M")

                camp_time = schedules[campaign]["time"]

                # print(camp_time, current_time)

                if (current_time == camp_time):
                    # print("match")
                    for i in range(5):
                        await channel.send(
                            "THE TIME IS NOW, REJOICE!\n@everyone")
                    await self.bot.change_presence(
                        activity=nextcord.Game(status[0]))
                else:
                    # print("No match")
                    await self.bot.change_presence(
                        activity=nextcord.Game(status[1]))
Beispiel #2
0
 async def change_activity(self, ctx: commands.Context, Type: str,
                           *act: str):
     """Change l'activité du bot (play,watch,listen,stream)"""
     act = " ".join(act)
     if Type in ['game', 'play']:
         await self.bot.change_presence(activity=nextcord.Game(name=act))
     elif Type in ['watch', 'see']:
         await self.bot.change_presence(
             activity=nextcord.Activity(type=nextcord.ActivityType.watching,
                                        name=act,
                                        timestamps={'start': time.time()}))
     elif Type in ['listen']:
         await self.bot.change_presence(activity=nextcord.Activity(
             type=nextcord.ActivityType.listening,
             name=act,
             timestamps={'start': time.time()}))
     elif Type in ['stream']:
         await self.bot.change_presence(activity=nextcord.Activity(
             type=nextcord.ActivityType.streaming,
             name=act,
             timestamps={'start': time.time()}))
     else:
         return await ctx.send(
             "Sélectionnez *play*, *watch*, *listen* ou *stream* suivi du nom"
         )
     await ctx.message.delete()
Beispiel #3
0
    async def on_ready(self):
        """Performs an action when the bot is ready"""

        for guild in self.guilds:
            # Setup folders
            data = Data(guild)
            data.setup_folders()
            data.setup_files()
            del data

            # Setup database
            setup_database(guild)

        # Set activity
        self.status = nextcord.Status.online

        # Get activity
        with open(config_yaml, "r") as stream:
            try:
                content = yaml.safe_load(stream)
            except yaml.YAMLError as error:
                log.error("Error at getting YAML content: {}".format(error))

        activity = nextcord.Game(content["activity"])
        self.activity = activity

        # Load cogs
        cogs = os.listdir("src/cogs/")

        for c in cogs:
            if c.endswith(".py"):
                self.load_extension("cogs." + c[:-3])
                log.info("Loaded {}".format(c))

        log.info("We have logged in as {}".format(self.user))
 def __init__(self, bot: commands.Bot):
     self.__bot = bot
     self.status_list = (
         nextcord.Activity(type=nextcord.ActivityType.watching,
                           name="you struggle 👀"),
         nextcord.Game(name="around with numbers‍"),
     )
     self.current_status = random.randint(0, len(self.status_list) - 1)
Beispiel #5
0
 async def on_guild_join(self, guild: discord.Guild) -> None:
     """サーバー参加時"""
     # サーバー参加ログを送信
     embed = discord.Embed(title=f"{guild.name} に参加しました。", color=0x00ffff)
     # TODO: インテント修正後に修正
     # embed.description = f"サーバーID: {guild.id}\nメンバー数: {len(guild.members)}\nサーバー管理者: {str(guild.owner)} ({guild.owner.id})"
     embed.description = f"サーバーID: {guild.id}"
     await self.get_channel(self.static_data.log_channel).send(embed=embed)
     # ステータスを更新
     await self.change_presence(
         status=discord.Status.online,
         activity=discord.Game(
             f"{self.PREFIX}help | {len(self.guilds)}servers | {self.static_data.server}"
         ))
Beispiel #6
0
 async def on_ready():
     await client.get_cog("UtilitiesCog").count_lines_code()
     print('\nBot connecté')
     print("Nom : "+client.user.name)
     print("ID : "+str(client.user.id))
     serveurs = []
     for i in client.guilds:
         serveurs.append(i.name)
     ihvbsdi="Connecté sur ["+str(len(client.guilds))+"] "+", ".join(serveurs)
     print(ihvbsdi)
     print(time.strftime("%d/%m  %H:%M:%S"))
     print("Prêt en {}s".format(round(time.time()-t1,3)))
     print('------')
     await client.change_presence(activity=nextcord.Game(name="baaatttle!"))
Beispiel #7
0
async def on_ready():
    # limit commands to run only in the groepkakken server
    for guild in bot.guilds:
        if guild.name == GUILD:
            break

    print(f'{bot.user} has successfully connected to {guild.name}\n')

    await bot.change_presence(activity=nextcord.Game(name='the game of life.'))
    members = '\n - '.join(
        [f'{member.name} : {member.id}' for member in guild.members])
    print(f'Guild Members:\n - {members}')

    print('\nChannels in this server:')
    for channel in guild.text_channels:
        print(f' - {channel} : {channel.id}')
    print('\n')
 async def on_message(self, user_message: nextcord.Message):
     if not self.loading:
         await self.bot.change_presence(activity=nextcord.Game(name=f"Currently Using Model: {self.ModelName}"))
         if user_message.author != self.bot.user:
             pattern = re.compile(r"[^a-zA-Z?.!,'\"<>0-9 :]+")
             message = re.sub(pattern, "", user_message.content)
             words = message.split(' ')
             if words[0] in self.ids:
                 formatted_message = [words[1:]]
                 formatted_message = formatted_message[0]
                 message_for_bot = " ".join(formatted_message)
                 await self.chat(user_message, message_for_bot)
     else:
         if user_message.author != self.bot.user:
             channel_id = int(user_message.channel.id)
             channel = nextcord.utils.get(user_message.guild.text_channels, id=channel_id)
             await channel.send(choice(self.phrases))
Beispiel #9
0
 async def on_ready(self) -> None:
     """キャッシュ準備完了"""
     print(f"Logged in to [{self.user}]")
     self.aiohttp_session = aiohttp.ClientSession(loop=self.loop)
     if self.user.id != 742952261176655882:
         self.command_prefix.append(",")
     if not self.db.is_connected():  # データベースに接続しているか確認
         await self.db.connect()  # データベースに接続
         self.cache_users = self.cache_users.union(
             set(await self.db.get_registered_users()))
         self.db_ready = True  # データベース接続完了フラグ
     if not self.backup_database.is_running():
         self.backup_database.start()
     # ステータスを変更
     await self.change_presence(
         status=discord.Status.online,
         activity=discord.Game(
             f"{self.PREFIX}help | {len(self.guilds)}servers | {self.static_data.server}"
         ))
Beispiel #10
0
 async def on_guild_remove(self, guild: discord.Guild) -> None:
     """サーバー退出時"""
     # サーバー退出ログを送信
     embed = discord.Embed(title=f"{guild.name} を退出しました。", color=0xff1493)
     # TODO: インテント修正後に修正
     # embed.description = f"サーバーID: {guild.id}\nメンバー数: {len(guild.members)}\nサーバー管理者: {str(guild.owner)} ({guild.owner.id})"
     embed.description = f"サーバーID: {guild.id}"
     await self.get_channel(self.static_data.log_channel).send(embed=embed)
     # ステータスを更新
     await self.change_presence(
         status=discord.Status.online,
         activity=discord.Game(
             f"{self.PREFIX}help | {len(self.guilds)}servers | {self.static_data.server}"
         ))
     # 承認済みサーバーから退出した場合に自動で承認を取り下げ
     if guild.id in self.cache_guilds:
         self.cache_guilds.discard(guild.id)
         channel = self.get_channel(888017049589260298)
         await success_embed(
             channel, f"{guild.name}({guild.id})を退出したので自動的に承認を取り下げました.")
         with open('guilds.pickle', 'wb') as f:
             pickle.dump(self.cache_guilds, f)
Beispiel #11
0
from Cogs.milkcoffee import MilkCoffee

load_dotenv(verbose=True)
load_dotenv(join(dirname(__file__), '.env'))

TOKEN = os.getenv("TOKEN")
DB_NAME = os.getenv("DB_NAME")
DB_USER = os.getenv("DB_USER")
DB_PSWD = os.getenv("DB_PSWD")

logging.basicConfig(level=logging.INFO)

PREFIX = "m!"
PREFIXES = [
    "m! ", "m! ", "m! ", "m! ", "m! ", "m! ", "m! ", "m! ", "m!", "m!", "m!",
    "m!", "M! ", "M! ", "M! ", "M! ", "M! ", "M! ", "M! ", "M! ", "M!", "M!",
    "M!", "M!", "."
]

if __name__ == '__main__':
    intents = discord.Intents.default()
    intents.typing = False
    intents.members = True  # memberインテント
    bot = MilkCoffee(PREFIX, [DB_NAME, DB_USER, DB_PSWD],
                     command_prefix=PREFIXES,
                     help_command=Help(),
                     status=discord.Status.dnd,
                     activity=discord.Game("Starting..."),
                     intents=intents)
    bot.run(TOKEN)
Beispiel #12
0
 async def status_changer(self):
     await self.change_presence(
         status=nextcord.Status.do_not_disturb,
         activity=nextcord.Game(f"{random.choice(Config.status_messages)}"),
     )
Beispiel #13
0
 async def on_ready(self):
     await self.maid.change_presence(
         status=nextcord.Status.online,
         activity=nextcord.Game(" with catgirls"))
     print(f"Logged in as {self.maid.user.name}")
Beispiel #14
0
 async def changestatus(self, ctx, *, arg):
     await self.bot.change_presence(activity=nextcord.Game(name=arg))
     await ctx.send(":ok_hand: Done.")
Beispiel #15
0
 async def async_set_game_status(self, game_status):
     await client.change_presence(activity=nextcord.Game(game_status))
Beispiel #16
0
async def change_status():
    playing = random.choice(botstatus)
    await bot.change_presence(activity=nextcord.Game(name=playing))
Beispiel #17
0
ytdl_format_options = {
    "cookies": "cookies.txt",
    "user_agent":
    "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0",
    "username": YT_MAIL,
    "password": YT_PASS,
    "format": "bestaudio/best",
    "outtmpl": "%(extractor)s-%(id)s-%(title)s.%(ext)s",
    "restrictfilenames": True,
    "noplaylist": True,
    "nocheckcertificate": True,
    "ignoreerrors": False,
    "logtostderr": False,
    "quiet": True,
    "no_warnings": True,
    "default_search": "auto",
    "source_address":
    "0.0.0.0"  # Bind to IPv4 since IPv6 addresses cause issues sometimes
}

# -vn discards video stream
ffmpeg_options = {"options": "-vn"}

# Bot's discord activities
activities = [
    nextcord.Game(name="with křemík."),
    nextcord.Activity(type=nextcord.ActivityType.listening,
                      name="frequencies."),
    nextcord.Activity(type=nextcord.ActivityType.watching, name="you.")
]
Beispiel #18
0
async def change_status():
    await bot.wait_until_ready()
    await bot.change_presence(status=nextcord.Status.idle,
                              activity=nextcord.Game(next(status)))