Donate to the B3 fund!

"even a small donation helps!"
Donate with PayPal!
Most of the plugins here are made by B3 users and the authors may not visit frequently. If you need support for plugins or if questions remain unanswered, you will have to contact the author directly. Read the full Support Disclaimer here

NOTE: Do not attach plugins to your forumtopics! Attachements are periodically removed by maintenance tasks. Upload your plugins to our Downloads section instead!

Author Topic: Kick Event Issue  (Read 456 times)

Offline st0rm

  • Newbie
  • *
  • Posts: 2
Kick Event Issue
« on: October 30, 2016, 11:39:05 PM »

I am kinda working on making a discord bot that post when people get kicked, banned into a discord server. I found some code from mamba of his twitter banned and modified to my needs. I can't seem to get the admin that kicked/banned or the reason for the penalty. Code break when this gets called.
Code: [Select]
 admin = b3.clients.getByCID(p.adminId)

this is the error
161030 17:32:17 ERROR    "Handler DiscordbanPlugin could not handle event Client Kicked: AttributeError: 'module' object has no attribute 'getByCID' [('C:\\\\Games\\\\Cod4HNS\\\\b3\\\\b3\\\\', 1412, 'handleEvents', 'hfunc.parseEvent(event)'), ('C:\\\\Games\\\\Cod4HNS\\\\b3\\\\b3\\\\', 479, 'parseEvent', 'func(event)'), ('C:\\\\Games\\\\Cod4HNS\\\\b3\\\\b3\\\\extplugins\\\\', 77, 'onEvent', 'admin = b3.clients.getByCID(p.adminId)')]"

action = ''

    if event.type ==
   action = 'kicked'

    if event.type ==
   action = 'banned'

    if event.type ==
   action = 'banned'

    p = self.getLastBanKick(event.client)
    clientName =
    admin = b3.clients.getByCID(p.adminId)
    self.debug('Posting Update to discord: %s' % admin.admin)
    text = '%s %s %s' % (self.removeColors(, action, clientName)
    self.debug('Posting Update to discord: %s' % text)
    text = '%s: for %s' % (text, self.removeColors(p.reason))

  def getLastBanKick(self, client):
    q = "select * from `penalties` where client_id = %i and type in ('Ban', 'TempBan', 'Kick') order by time_add desc limit 1 " %
    cursor =
    g = cursor.getOneRow()
    if not g:
      self.debug('Nothing found')
    return None
    self.debug('Found at least one row: %s' % (str(g)))

    penalty = b3.clients.Penalty() = int(g['id'])
    penalty.type = g['type']
    penalty.keyword = g['keyword']
    penalty.reason = g['reason'] = g['data']
    penalty.duration = g['duration']
    penalty.inactive = int(g['inactive'])
    penalty.timeAdd  = int(g['time_add'])
    penalty.timeEdit = int(g['time_edit'])
    penalty.timeExpire = int(g['time_expire'])
    penalty.clientId = int(g['client_id'])
    penalty.adminId = int(g['admin_id'])

    return penalty

Any idea how to fix this?
« Last Edit: October 31, 2016, 12:16:17 AM by st0rm »

Offline 82ndAB.Bravo17

  • Dev. Team
  • Hero Member
  • *
  • Posts: 2534
Re: Kick Event Issue
« Reply #1 on: October 31, 2016, 12:27:49 AM »


Offline Fenix

  • Dev. Team
  • Hero Member
  • *
  • Posts: 984
    • GitHub
Re: Kick Event Issue
« Reply #2 on: November 02, 2016, 11:41:46 AM »

I suggest self.console.clients.getByCID(cid), since he's already referring to the parser using self.console :)


Rate this page +1 at Google Search