コード例 #1
0
 def __init__(self, runner, user: discord.User):
     self._runner = runner
     self._usr = user
     self.name = viper.String(user.name, -1, runner)
     self.id = viper.Integer(user.id, -1, runner)
     self.discriminator = viper.String(user.discriminator, -1, runner)
     self.mention = viper.String(user.mention, -1, runner)
コード例 #2
0
 def __init__(self, runner, guild: discord.Guild):
     self._guild = guild
     self._runner = runner
     self.member_count = viper.Integer(guild.member_count, -1, runner)
     self.owner = SafeAccessMember(runner, guild.owner,
                                   self) if guild.owner else runner.null
     self.description = viper.String(guild.description, -1, runner)
     self.name = viper.String(guild.name, -1, runner)
     self.id = viper.Integer(guild.id, -1, runner)
コード例 #3
0
 def __init__(self, runner, channel: discord.TextChannel):
     self._chn = channel
     self._runner = runner
     self.guild = SafeAccessGuild(
         runner, channel.guild) if channel.guild else runner.null
     self.id = viper.Integer(channel.id, -1, runner)
     self.nsfw = viper.Boolean(channel.is_nsfw(), -1, runner)
     self.news = viper.Boolean(channel.is_news(), -1, runner)
     self.topic = viper.String(channel.topic, -1, runner)
     self.mention = viper.String(channel.mention, -1, runner)
コード例 #4
0
 def __init__(self, runner, member: discord.Member, guild=None):
     self._mem = member
     self._runner = runner
     self.name = viper.String(member.name, -1, runner)
     self.id = viper.Integer(member.id, -1, runner)
     self.discriminator = viper.String(member.discriminator, -1, runner)
     self.mention = member.mention
     self.guild = guild or SafeAccessGuild(runner, member.guild)
     self.nick = viper.String(member.nick, -1,
                              runner) if member.nick else runner.null
コード例 #5
0
 def __init__(self, runner, message: discord.Message):
     self._runner = runner
     self._msg = message
     self.channel = SafeAccessTextChannel(runner, message.channel)
     self.guild = SafeAccessGuild(
         runner, message.guild) if message.guild else runner.null
     self.author = SafeAccessMember(runner, message.author) if isinstance(
         message.author, discord.Member) else SafeAccessUser(
             runner, message.author)
     self.content = viper.String(message.content, -1, runner)
     self.clean_content = viper.String(message.clean_content, -1, runner)
     self.flags = message.flags
     self.jump_url = viper.String(message.jump_url, -1, runner)
コード例 #6
0
 def _cast(self, typ, lineno):
     if typ is viper.String:
         return viper.String(
             "<Channel id={0} nsfw={1} guild={2}>".format(
                 self.id._value, self.nsfw._value, self.guild), lineno,
             self._runner)
     return self._runner.null
コード例 #7
0
 def _cast(self, typ, lineno):
     if typ is viper.String:
         return viper.String(
             "<Member name={0} id={1} guild={2}>".format(
                 self.name._value, self.id._value, self.guild), lineno,
             self._runner)
     return self._runner.null
コード例 #8
0
 def __init__(self, runner, ctx: commands.Context):
     self._runner = runner
     self._ctx = ctx  # can't access underscored attrs, makes this safe
     self.message = SafeAccessMessage(runner, ctx.message)
     self.author = SafeAccessMember(
         runner, ctx.author) if ctx.guild else SafeAccessUser(
             runner, ctx.author)
     self.channel = SafeAccessTextChannel(runner, ctx.channel)
     self.guild = SafeAccessGuild(runner,
                                  ctx.guild) if ctx.guild else runner.null
     self.bot = SafeAccessMember(
         runner, ctx.me) if ctx.guild else SafeAccessUser(runner, ctx.me)
     self.content = viper.String(ctx.message.content, -1, runner)
コード例 #9
0
 def _cast(self, typ, lineno):
     if typ is viper.String:
         return viper.String(
             "<Message channel={0} guild={1} author={2}>".format(
                 self.channel, self.guild, self.author), lineno,
             self._runner)
コード例 #10
0
 def _cast(self, typ):
     if typ is viper.String:
         return viper.String("<Context message={0}>".format(self.message),
                             -1, self._runner)
     return self._runner.null
コード例 #11
0
 def _cast(self, typ, lineno):
     if typ is viper.String:
         return viper.String(
             "<Guild name={0} id={1} owner={2}>".format(
                 self.name, self.id, self.owner), lineno, self._runner)
     return self._runner.null
コード例 #12
0
 def _cast(self, typ, lineno):
     if typ is viper.String:
         return viper.String(
             "<User name={0} id={1}>".format(self.name, self.id), lineno,
             self._runner)
     return self._runner.null