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)); }
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); }
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; }
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>(); }
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)); }
public ServerMiddleware(IComponentContext context) { this._discordServerContextFactory = new DiscordServerContextFactory(context); }
public ServerMiddleware() { this.discordServerContextsFactory = new DiscordServerContextFactory(); }