Esempio n. 1
0
        private async Task CallServerAddedBot(SocketGuild guild)
        {
            var discordServerFactory = new DiscordServerContextFactory();
            var restGuild            = await Server.GetGuild(guild.Id);

            var discordServer = discordServerFactory.Create(restGuild);

            OnDiscordServerAddedBot.ForEach(x => x.Invoke(discordServer));
        }
Esempio n. 2
0
        public async Task <IEnumerable <DiscordServerContext> > GetDiscordServers()
        {
            var serverContextFactory = new DiscordServerContextFactory();
            var guilds = await this._restClient.GetGuildsAsync();

            var serverContexts = guilds.Select(x => serverContextFactory.Create(x));

            return(serverContexts);
        }
Esempio n. 3
0
        public DiscordClientServersService(DiscordSocketClient client, DiscordServerContextFactory discordServerContextFactory)
        {
            this._client = client;
            this._discordServerContextFactory = discordServerContextFactory;

            this._client.JoinedGuild  += this.BotAddedToServer;
            this._client.Disconnected += this.BotDisconnected;
            this._client.Connected    += this.BotConnected;
        }
Esempio n. 4
0
 internal Workflow(Assembly botAssembly, IComponentContext context)
 {
     this._controllersService          = new ControllersService(context, botAssembly, context.Resolve <BotCommandsService>(), context.Resolve <CommandsContainer>());
     this._commandParser               = context.Resolve <CommandParser>();
     this._middlewaresService          = context.Resolve <MiddlewaresService>();
     this._discordServerContextFactory = context.Resolve <DiscordServerContextFactory>();
     this._userContextsFactory         = context.Resolve <UserContextsFactory>();
     this._channelContextFactory       = context.Resolve <ChannelContextFactory>();
     this._userRoleFactory             = context.Resolve <UserRoleFactory>();
 }
Esempio n. 5
0
        private async Task CallUserJoined(SocketGuildUser guildUser)
        {
            var userFactory   = new UserContextsFactory();
            var serverFactory = new DiscordServerContextFactory();

            var userContext = userFactory.Create(guildUser);
            var guild       = await Server.GetGuild(guildUser.Guild.Id);

            var discordServerContext = serverFactory.Create(guild);
            var landingChannel       = discordServerContext.LandingChannel;

            var contexts = new Contexts();

            contexts.SetContext(userContext);
            contexts.SetContext(discordServerContext);
            if (landingChannel != null)
            {
                contexts.SetContext(landingChannel);
            }

            OnUserJoined.ForEach(x => x.Invoke(contexts));
        }
Esempio n. 6
0
 public ServerMiddleware(IComponentContext context)
 {
     this._discordServerContextFactory = new DiscordServerContextFactory(context);
 }
Esempio n. 7
0
 public ServerMiddleware()
 {
     this.discordServerContextsFactory = new DiscordServerContextFactory();
 }