async def test_bind_command(self):
     wrong_id = 787878787
     fakecontext = FakeContext(client= self.fake_guild, author = self.fake_member, channel= self.fake_guild.channels[0])
     await self.target.profile_group_bind_command(self.target, fakecontext)
     assert self.fake_guild.messageLast.content == '<@!{}> 設定升級訊息將會於此。'.format(self.fake_member.id)
     assert self.fake_guild.messageLast.channel.id == self.fake_guild.channels[0].id , 'check message chennal'
     assert ChannelUtil.getMessageChannelId(self.fake_guild.id) != None , 'check database'
Esempio n. 2
0
 async def profile_on_message(self, message: Message):
     if message.author.bot:
         return
     if message.channel == None or not message.channel.guild.id in whitelist or message.author.bot:
         return
     if self.populateChannels(message, self.isTest):
         return
     if not self.channelAllowed(message.channel.id, self.isTest):
         return
     member: Member = self.db.get_member(message.author.id)
     if not member:
         self.db.add_member(message.author.id)
         member = self.db.get_member(message.author.id)
     increaseNumber = randint(10, 25)
     rank = self.db.increase_exp(message.channel.guild.id,
                                 message.channel.id, message.author.id,
                                 increaseNumber)
     assert rank > 0, 'method increase_xp should not retrun less than 1 in profile_on_message'
     if member.rank != rank:
         channel = ChannelUtil.getMessageChannelId(message.guild.id)
         if channel == None:
             channelToUse = message.channel
         else:
             channelToUse = message.guild.get_channel(channel)
         RPGCharacterUtil.levelUpCharacter(message.author.id, member.rank,
                                           rank)
         await channelToUse.send('恭喜<@{}> 等級提升至{}。'.format(
             message.author.id, rank))
         await self.updateUserKfpRoles(message, rank, channelToUse)
     self.db.increase_coin(message.guild.id, message.author.id,
                           increaseNumber)
Esempio n. 3
0
 def test_setRankupChannel_notExist(self):
     assert not ChannelUtil.getMessageChannelId(123)
Esempio n. 4
0
    def test_setRankupChannel(self):
        ChannelUtil.setRankupChannel(0, 123)
        assert ChannelUtil.getMessageChannelId(0) == 123

        ChannelUtil.setRankupChannel(0, 456)
        assert ChannelUtil.getMessageChannelId(0) == 456